17 void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) {
21 ifStmt(hasCondition(findAll(implicitCastExpr(
22 unless(hasParent(unaryOperator(hasOperatorName(
"!")))),
24 expr(hasType(pointerType(pointee(booleanType()))),
25 ignoringParenImpCasts(declRefExpr().bind(
"expr")))),
26 hasCastKind(CK_PointerToBoolean)))),
27 unless(isInTemplateInstantiation()))
32 void BoolPointerImplicitConversionCheck::check(
33 const MatchFinder::MatchResult &
Result) {
34 auto *If = Result.Nodes.getNodeAs<IfStmt>(
"if");
35 auto *Var = Result.Nodes.getNodeAs<DeclRefExpr>(
"expr");
38 if (Var->getBeginLoc().isMacroID())
46 const Decl *
D = Var->getDecl();
47 auto DeclRef = ignoringParenImpCasts(declRefExpr(to(equalsNode(D))));
49 unaryOperator(hasOperatorName(
"*"), hasUnaryOperand(
DeclRef))),
52 !
match(findAll(arraySubscriptExpr(hasBase(
DeclRef))), *If,
57 !
match(findAll(callExpr(hasAnyArgument(ignoringParenImpCasts(
DeclRef)))),
60 !
match(findAll(cxxDeleteExpr(has(ignoringParenImpCasts(expr(
DeclRef))))),
65 diag(Var->getBeginLoc(),
"dubious check of 'bool *' against 'nullptr', did " 66 "you mean to dereference it?")
67 << FixItHint::CreateInsertion(Var->getBeginLoc(),
"*");
std::vector< std::string > match(const SymbolIndex &I, const FuzzyFindRequest &Req, bool *Incomplete)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
const DeclRefExpr * DeclRef