clang-tools  7.0.0svn
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.
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
StringHandle Name
Flag global namespace pollution in header files.
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
llvm::SmallSet< llvm::StringRef, 5 > HeaderFileExtensionsSet
std::map< std::string, std::string > OptionMap
GlobalNamesInHeadersCheck(StringRef Name, ClangTidyContext *Context)
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...