19 return Node.isConstantInitializer(Finder->getASTContext(),
false);
23 return Node.getStorageDuration() == SD_Static && !Node.isLocalVarDecl();
27 void StaticallyConstructedObjectsCheck::registerMatchers(MatchFinder *Finder) {
32 traverse(ast_type_traits::TK_AsIs,
37 hasDescendant(cxxConstructExpr(unless(allOf(
39 hasDeclaration(cxxConstructorDecl(isConstexpr())),
41 isConstantInitializer())))))
46 void StaticallyConstructedObjectsCheck::check(
47 const MatchFinder::MatchResult &Result) {
48 if (
const auto *D = Result.Nodes.getNodeAs<VarDecl>(
"decl"))
49 diag(D->getBeginLoc(),
"static objects are disallowed; if possible, use a "
50 "constexpr constructor instead");