10 #include "clang/AST/ASTContext.h" 11 #include "clang/ASTMatchers/ASTMatchFinder.h" 20 const Expr *Init = Node.getInit();
21 if (Init && !Init->isValueDependent()) {
22 if (Node.isConstexpr())
24 return Node.checkInitIsICE();
29 DynamicStaticInitializersCheck::DynamicStaticInitializersCheck(StringRef
Name,
32 RawStringHeaderFileExtensions(Options.getLocalOrGlobal(
35 HeaderFileExtensions,
',')) {
36 llvm::errs() <<
"Invalid header file extension: " 37 << RawStringHeaderFileExtensions <<
"\n";
43 Options.
store(Opts,
"HeaderFileExtensions", RawStringHeaderFileExtensions);
50 varDecl(hasGlobalStorage(), unless(hasConstantDeclaration())).bind(
"var"),
55 const auto *Var = Result.Nodes.getNodeAs<VarDecl>(
"var");
56 SourceLocation
Loc = Var->getLocation();
58 HeaderFileExtensions))
62 diag(Loc,
"static variable %0 may be dynamically initialized in this header file")
SourceLocation Loc
'#' location in the include directive
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
bool parseHeaderFileExtensions(StringRef AllHeaderFileExtensions, HeaderFileExtensionsSet &HeaderFileExtensions, char delimiter)
Parses header file extensions from a semicolon-separated list.
bool isPresumedLocInHeaderFile(SourceLocation Loc, SourceManager &SM, const HeaderFileExtensionsSet &HeaderFileExtensions)
Checks whether presumed location of Loc is in header file.
AST_MATCHER(Expr, isMacroID)
Base class for all clang-tidy checks.
const LangOptions & getLangOpts() const
Returns the language options from the context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
StringRef defaultHeaderFileExtensions()
Returns recommended default value for the list of header file extensions.
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName, StringRef Value) const
Stores an option with the check-local name LocalName with string value Value to Options.
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.