================ @@ -16538,6 +16538,21 @@ void Sema::DiagnoseAlwaysNonNullPointer(Expr *E, } } + // Complain if we are converting a lambda expression to a boolean value + if (const auto *MCallExpr = dyn_cast<CXXMemberCallExpr>(E)) { + if (const auto *MRecordDecl = MCallExpr->getRecordDecl(); + MRecordDecl && MRecordDecl->isLambda()) { + std::string Str; + llvm::raw_string_ostream S(Str); + + E->printPretty(S, nullptr, getPrintingPolicy()); + Diag(E->getExprLoc(), diag::warn_impcast_pointer_to_bool) + << /*LambdaPointerConversionOperatorType*/ 3 << S.str() + << MRecordDecl->getSourceRange() << Range << IsEqual; ---------------- AaronBallman wrote:
```suggestion Diag(E->getExprLoc(), diag::warn_impcast_pointer_to_bool) << /*LambdaPointerConversionOperatorType*/ 3 << MRecordDecl->getSourceRange() << Range << IsEqual; ``` This way we don't pretty print the entire lambda body in the diagnostic message. https://github.com/llvm/llvm-project/pull/83152 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits