10#include "clang/AST/ASTContext.h"
11#include "clang/Lex/Lexer.h"
19 ast_matchers::internal::Matcher<Stmt>, InnerMatcher) {
20 const Stmt *
E = &
Node;
23 if (
const auto *EWC = dyn_cast<ExprWithCleanups>(
E))
24 E = EWC->getSubExpr();
26 else if (
const auto *BTE = dyn_cast<CXXBindTemporaryExpr>(
E))
27 E = BTE->getSubExpr();
29 else if (
const auto *FCE = dyn_cast<CXXFunctionalCastExpr>(
E))
30 E = FCE->getSubExpr();
35 return InnerMatcher.matches(*
E, Finder,
Builder);
41 [&](
const ast_matchers::internal::BoundNodesMap &Nodes) {
42 const auto *Derived = Nodes.getNodeAs<CXXRecordDecl>(
ID);
43 return Derived != &
Node && !Derived->isDerivedFrom(&Node);
58 compoundStmt(hasParent(cxxConstructorDecl(
59 ofClass(cxxRecordDecl().bind(
"parent")))),
60 forEach(ignoringTemporaryExpr(
62 hasDeclaration(cxxConstructorDecl(ofClass(
63 cxxRecordDecl(baseOfBoundNode(
"parent"))))))
65 unless(isInTemplateInstantiation()))),
70 const MatchFinder::MatchResult &Result) {
71 const auto *
E = Result.Nodes.getNodeAs<CXXConstructExpr>(
"construct");
72 diag(
E->getBeginLoc(),
"did you intend to call a delegated constructor? "
73 "A temporary object is created here instead");
CodeCompletionBuilder Builder
::clang::DynTypedNode Node
DiagnosticBuilder diag(SourceLocation Loc, StringRef Description, DiagnosticIDs::Level Level=DiagnosticIDs::Warning)
Add a diagnostic with the check's name.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
AST_MATCHER_P(FunctionDecl, parameterCountGE, unsigned, N)
Matches functions that have at least the specified amount of parameters.