clang-tools  8.0.0
RestrictSystemIncludesCheck.h
Go to the documentation of this file.
1 //===--- RestrictSystemIncludesCheck.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_FUCHSIA_RESTRICTINCLUDESSCHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_RESTRICTINCLUDESSCHECK_H
12 
13 #include "../ClangTidy.h"
14 #include "../ClangTidyDiagnosticConsumer.h"
15 #include "../utils/OptionsUtils.h"
16 
17 namespace clang {
18 namespace tidy {
19 namespace fuchsia {
20 
21 /// Checks for allowed includes and suggests removal of any others. If no
22 /// includes are specified, the check will exit without issuing any warnings.
23 ///
24 /// For the user-facing documentation see:
25 /// http://clang.llvm.org/extra/clang-tidy/checks/fuchsia-restrict-system-includes.html
27 public:
29  : ClangTidyCheck(Name, Context),
30  AllowedIncludes(Options.get("Includes", "*")),
31  AllowedIncludesGlobList(AllowedIncludes) {}
32 
33  void registerPPCallbacks(CompilerInstance &Compiler) override;
34  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
35  bool contains(StringRef FileName) {
36  return AllowedIncludesGlobList.contains(FileName);
37  }
38 
39 private:
40  std::string AllowedIncludes;
41  GlobList AllowedIncludesGlobList;
42 };
43 
44 } // namespace fuchsia
45 } // namespace tidy
46 } // namespace clang
47 
48 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_FUCHSIA_RESTRICTINCLUDESSCHECK_H
Read-only set of strings represented as a list of positive and negative globs.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
bool contains(StringRef S)
Returns true if the pattern matches S.
Checks for allowed includes and suggests removal of any others.
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
RestrictSystemIncludesCheck(StringRef Name, ClangTidyContext *Context)
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
PathRef FileName
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void registerPPCallbacks(CompilerInstance &Compiler) override
Override this to register PPCallbacks with Compiler.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.