[clang] [clang] Add diagnostic for usage of implicit constructor with pointer to bool convertion (PR #143990)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 26 07:25:11 PDT 2025
================
@@ -11767,6 +11767,25 @@ static void CheckImplicitArgumentConversions(Sema &S, const CallExpr *TheCall,
SourceLocation CC) {
for (unsigned I = 0, N = TheCall->getNumArgs(); I < N; ++I) {
const Expr *CurrA = TheCall->getArg(I);
+
+ if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(CurrA))
+ // We shouldnt skip over any node here as it may be an attempt to silence
+ // the warning
+ if (auto *CCE = dyn_cast<CXXConstructExpr>(MTE->getSubExpr()))
+ if (CCE->getNumArgs() == 1) {
+ Expr *Inner = CCE->getArg(0)->IgnoreImpCasts();
+ if ((Inner->getType()->isAnyPointerType() &&
+ Inner->getType()->getPointeeType().getUnqualifiedType() ==
+ CCE->getType().getUnqualifiedType())) {
----------------
AaronBallman wrote:
This isn't specific to pointer to bool conversions?
https://github.com/llvm/llvm-project/pull/143990
More information about the cfe-commits
mailing list