Line data Source code
1 : //===--- GlobalNamesInHeadersCheck.h - clang-tidy ---------------*- C++ -*-===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 :
10 : #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_GLOBALNAMESINHEADERSCHECK_H
11 : #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_GLOBALNAMESINHEADERSCHECK_H
12 :
13 : #include "../ClangTidy.h"
14 : #include "../utils/HeaderFileExtensionsUtils.h"
15 :
16 : namespace clang {
17 : namespace tidy {
18 : namespace google {
19 : namespace readability {
20 :
21 : /// Flag global namespace pollution in header files.
22 : /// Right now it only triggers on using declarations and directives.
23 : ///
24 : /// The check supports these options:
25 : /// - `HeaderFileExtensions`: a comma-separated list of filename extensions
26 : /// of header files (the filename extensions should not contain "." prefix).
27 : /// "h" by default.
28 : /// For extension-less header files, using an empty string or leaving an
29 : /// empty string between "," if there are other filename extensions.
30 0 : class GlobalNamesInHeadersCheck : public ClangTidyCheck {
31 : public:
32 : GlobalNamesInHeadersCheck(StringRef Name, ClangTidyContext *Context);
33 : void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
34 : void registerMatchers(ast_matchers::MatchFinder *Finder) override;
35 : void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
36 :
37 : private:
38 : const std::string RawStringHeaderFileExtensions;
39 : utils::HeaderFileExtensionsSet HeaderFileExtensions;
40 : };
41 :
42 : } // namespace readability
43 : } // namespace google
44 : } // namespace tidy
45 : } // namespace clang
46 :
47 : #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_GLOBALNAMESINHEADERSCHECK_H
|