clang-tools  5.0.0
UnnamedNamespaceInHeaderCheck.h
Go to the documentation of this file.
1 //===--- UnnamedNamespaceInHeaderCheck.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_UNNAMEDNAMESPACEINHEADERCHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_UNNAMEDNAMESPACEINHEADERCHECK_H
12 
13 #include "../ClangTidy.h"
14 #include "../utils/HeaderFileExtensionsUtils.h"
15 
16 namespace clang {
17 namespace tidy {
18 namespace google {
19 namespace build {
20 
21 /// Finds anonymous namespaces in headers.
22 ///
23 /// The check supports these options:
24 /// - `HeaderFileExtensions`: a comma-separated list of filename extensions of
25 /// header files (The filename extensions should not contain "." prefix).
26 /// "h,hh,hpp,hxx" by default.
27 /// For extension-less header files, using an empty string or leaving an
28 /// empty string between "," if there are other filename extensions.
29 ///
30 /// https://google.github.io/styleguide/cppguide.html#Namespaces
31 ///
32 /// Corresponding cpplint.py check name: 'build/namespaces'.
34 public:
36  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
37  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
38  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
39 
40 private:
41  const std::string RawStringHeaderFileExtensions;
42  utils::HeaderFileExtensionsSet HeaderFileExtensions;
43 };
44 
45 } // namespace build
46 } // namespace google
47 } // namespace tidy
48 } // namespace clang
49 
50 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_UNNAMEDNAMESPACEINHEADERCHECK_H
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
StringHandle Name
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:275
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
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.
UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context)
llvm::SmallSet< llvm::StringRef, 5 > HeaderFileExtensionsSet
std::map< std::string, std::string > OptionMap
ClangTidyContext & Context
Definition: ClangTidy.cpp:87
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.