18 void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) {
22 ifStmt(hasCondition(findAll(implicitCastExpr(
23 unless(hasParent(unaryOperator(hasOperatorName(
"!")))),
25 expr(hasType(pointerType(pointee(booleanType()))),
26 ignoringParenImpCasts(declRefExpr().bind(
"expr")))),
27 hasCastKind(CK_PointerToBoolean)))),
28 unless(isInTemplateInstantiation()))
33 void BoolPointerImplicitConversionCheck::check(
34 const MatchFinder::MatchResult &
Result) {
35 auto *If = Result.Nodes.getNodeAs<IfStmt>(
"if");
36 auto *Var = Result.Nodes.getNodeAs<DeclRefExpr>(
"expr");
39 if (Var->getBeginLoc().isMacroID())
47 const Decl *
D = Var->getDecl();
48 auto DeclRef = ignoringParenImpCasts(declRefExpr(to(equalsNode(D))));
50 unaryOperator(hasOperatorName(
"*"), hasUnaryOperand(
DeclRef))),
53 !match(findAll(arraySubscriptExpr(hasBase(
DeclRef))), *If,
58 !match(findAll(callExpr(hasAnyArgument(ignoringParenImpCasts(
DeclRef)))),
61 !match(findAll(cxxDeleteExpr(has(ignoringParenImpCasts(expr(
DeclRef))))),
66 diag(Var->getBeginLoc(),
"dubious check of 'bool *' against 'nullptr', did " 67 "you mean to dereference it?")
68 << FixItHint::CreateInsertion(Var->getBeginLoc(),
"*");
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
const DeclRefExpr * DeclRef