Go to the documentation of this file.
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(
37 llvm::errs() <<
"Invalid header file extension: "
38 << RawStringHeaderFileExtensions <<
"\n";
44 Options.
store(Opts,
"HeaderFileExtensions", RawStringHeaderFileExtensions);
49 varDecl(hasGlobalStorage(), unless(hasConstantDeclaration())).bind(
"var"),
54 const auto *Var = Result.Nodes.getNodeAs<VarDecl>(
"var");
55 SourceLocation
Loc = Var->getLocation();
57 HeaderFileExtensions))
61 diag(
Loc,
"static variable %0 may be dynamically initialized in this header file")
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Base class for all clang-tidy checks.
bool isPresumedLocInHeaderFile(SourceLocation Loc, SourceManager &SM, const FileExtensionsSet &HeaderFileExtensions)
Checks whether presumed location of Loc is in header file.
bool parseFileExtensions(StringRef AllFileExtensions, FileExtensionsSet &FileExtensions, StringRef Delimiters)
Parses header file extensions from a semicolon-separated list.
StringRef defaultFileExtensionDelimiters()
Returns recommended default value for the list of file extension delimiters.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
static constexpr llvm::StringLiteral Name
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
AST_MATCHER(Expr, isMacroID)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
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.
SourceLocation Loc
'#' location in the include directive
StringRef defaultHeaderFileExtensions()
Returns recommended default value for the list of header file extensions.
std::map< std::string, ClangTidyValue > OptionMap