================ @@ -554,15 +554,23 @@ bool NarrowingConversionsCheck::handleConditionalOperator( // We have an expression like so: `output = cond ? lhs : rhs` // From the point of view of narrowing conversion we treat it as two // expressions `output = lhs` and `output = rhs`. - handleBinaryOperator(Context, CO->getLHS()->getExprLoc(), Lhs, - *CO->getLHS()); - handleBinaryOperator(Context, CO->getRHS()->getExprLoc(), Lhs, - *CO->getRHS()); + handleConditionalOperatorArgument(Context, Lhs, CO->getLHS()); + handleConditionalOperatorArgument(Context, Lhs, CO->getRHS()); return true; } return false; } +void NarrowingConversionsCheck::handleConditionalOperatorArgument( + const ASTContext &Context, const Expr &Lhs, const Expr *Arg) { + if (const auto *ICE = llvm::dyn_cast<ImplicitCastExpr>(Arg)) { + if (!Arg->getIntegerConstantExpr(Context)) { + Arg = ICE->getSubExpr(); + } + } ---------------- AndreyG wrote:
Fixed: https://github.com/llvm/llvm-project/pull/139474/files#diff-25d304d497ff4aad5697d817f123266e1e78ee7c7e727e6ad9381e1d7fcdcac4R566-R568 https://github.com/llvm/llvm-project/pull/139474 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits