[clang] [clang] consistently quote expressions in diagnostics (PR #134769)

via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 8 03:17:26 PDT 2025


================
@@ -11683,7 +11683,10 @@ static void DiagnoseIntInBoolContext(Sema &S, Expr *E) {
         S.Diag(ExprLoc, diag::warn_left_shift_always)
             << (Result.Val.getInt() != 0);
       else if (E->getType()->isSignedIntegerType())
-        S.Diag(ExprLoc, diag::warn_left_shift_in_bool_context) << E;
+        S.Diag(ExprLoc, diag::warn_left_shift_in_bool_context)
+            << FixItHint::CreateInsertion(E->getBeginLoc(), "(")
+            << FixItHint::CreateInsertion(S.getLocForEndOfToken(E->getEndLoc()),
+                                          ") != 0");
----------------
cor3ntin wrote:

How is that related?

https://github.com/llvm/llvm-project/pull/134769


More information about the cfe-commits mailing list