clang-tools 6.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'.
33 class UnnamedNamespaceInHeaderCheck : public ClangTidyCheck {
34 public:
35 UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context);
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
clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::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: UnnamedNamespaceInHeaderCheck.cpp:34
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: UnnamedNamespaceInHeaderCheck.cpp:48
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: UnnamedNamespaceInHeaderCheck.cpp:39
clang::tidy::google::build::UnnamedNamespaceInHeaderCheck::UnnamedNamespaceInHeaderCheck
UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context)
Definition: UnnamedNamespaceInHeaderCheck.cpp:22
clang::tidy::google::build::UnnamedNamespaceInHeaderCheck
Finds anonymous namespaces in headers.
Definition: UnnamedNamespaceInHeaderCheck.h:33
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
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104