17 return Node.isConstantInitializer(Finder->getASTContext(),
false);
21 return Node.getStorageDuration() == SD_Static && !
Node.isLocalVarDecl();
35 hasDescendant(cxxConstructExpr(unless(allOf(
37 hasDeclaration(cxxConstructorDecl(isConstexpr())),
39 isConstantInitializer())))))
45 const MatchFinder::MatchResult &Result) {
46 if (
const auto *D = Result.Nodes.getNodeAs<VarDecl>(
"decl"))
47 diag(D->getBeginLoc(),
"static objects are disallowed; if possible, use a "
48 "constexpr constructor instead");
::clang::DynTypedNode Node
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
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.
AST_MATCHER(Decl, declHasNoReturnAttr)
matches a Decl if it has a "no return" attribute of any kind