clang-tools 6.0.0

GlobalNamesInHeadersCheck.h
Go to the documentation of this file.
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 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
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::google::readability::GlobalNamesInHeadersCheck
Flag global namespace pollution in header files.
Definition: GlobalNamesInHeadersCheck.h:30
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::google::readability::GlobalNamesInHeadersCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: GlobalNamesInHeadersCheck.cpp:40
clang::tidy::utils::HeaderFileExtensionsSet
llvm::SmallSet< llvm::StringRef, 5 > HeaderFileExtensionsSet
Definition: HeaderFileExtensionsUtils.h:22
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:99
clang::tidy::google::readability::GlobalNamesInHeadersCheck::GlobalNamesInHeadersCheck
GlobalNamesInHeadersCheck(StringRef Name, ClangTidyContext *Context)
Definition: GlobalNamesInHeadersCheck.cpp:23
clang::tidy::google::readability::GlobalNamesInHeadersCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: GlobalNamesInHeadersCheck.cpp:48
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
clang::tidy::google::readability::GlobalNamesInHeadersCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: GlobalNamesInHeadersCheck.cpp:35