10 #include "clang/AST/ASTContext.h" 11 #include "clang/Lex/Lexer.h" 21 ast_matchers::internal::Matcher<Stmt>, InnerMatcher) {
22 const Stmt *E = &Node;
25 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(E))
26 E = EWC->getSubExpr();
28 else if (
const auto *BTE = dyn_cast<CXXBindTemporaryExpr>(E))
29 E = BTE->getSubExpr();
31 else if (
const auto *FCE = dyn_cast<CXXFunctionalCastExpr>(E))
32 E = FCE->getSubExpr();
37 return InnerMatcher.matches(*E, Finder,
Builder);
41 AST_MATCHER_P(CXXRecordDecl, baseOfBoundNode, std::string, ID) {
43 [&](
const ast_matchers::internal::BoundNodesMap &Nodes) {
44 const auto *Derived = Nodes.getNodeAs<CXXRecordDecl>(ID);
45 return Derived != &Node && !Derived->isDerivedFrom(&Node);
50 void UndelegatedConstructorCheck::registerMatchers(MatchFinder *Finder) {
59 if (!getLangOpts().CPlusPlus11)
65 cxxConstructorDecl(ofClass(cxxRecordDecl().bind(
"parent")))),
66 forEach(ignoringTemporaryExpr(
67 cxxConstructExpr(hasDeclaration(cxxConstructorDecl(ofClass(
68 cxxRecordDecl(baseOfBoundNode(
"parent"))))))
70 unless(isInTemplateInstantiation())),
74 void UndelegatedConstructorCheck::check(
75 const MatchFinder::MatchResult &
Result) {
76 const auto *E = Result.Nodes.getNodeAs<CXXConstructExpr>(
"construct");
77 diag(E->getBeginLoc(),
"did you intend to call a delegated constructor? " 78 "A temporary object is created here instead");
CodeCompletionBuilder Builder
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
AST_MATCHER_P(CXXMethodDecl, hasCanonicalDecl, ast_matchers::internal::Matcher< CXXMethodDecl >, InnerMatcher)