[clang] 9f72df7 - Fixing a formatting mistake; NFC

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 3 05:08:08 PDT 2023


Author: Aaron Ballman
Date: 2023-08-03T08:07:59-04:00
New Revision: 9f72df7e30f074b46b18d3de267450236e4e37ea

URL: https://github.com/llvm/llvm-project/commit/9f72df7e30f074b46b18d3de267450236e4e37ea
DIFF: https://github.com/llvm/llvm-project/commit/9f72df7e30f074b46b18d3de267450236e4e37ea.diff

LOG: Fixing a formatting mistake; NFC

There was a brace that was hanging out in the middle of nowhere, this
fixes that issue.

Added: 
    

Modified: 
    clang/lib/Sema/SemaExpr.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2716b667710596..678553a4898c30 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13890,44 +13890,44 @@ void Sema::diagnoseLogicalInsteadOfBitwise(Expr *Op1, Expr *Op2,
       Op2->getType()->isIntegerType() && !Op2->isValueDependent() &&
       // Don't warn in macros or template instantiations.
       !Loc.isMacroID() && !inTemplateInstantiation() &&
-      !Op2->getExprLoc().isMacroID() &&
-      !Op1->getExprLoc().isMacroID()) {
+      !Op2->getExprLoc().isMacroID() && !Op1->getExprLoc().isMacroID()) {
     bool IsOp1InMacro = Op1->getExprLoc().isMacroID();
     bool IsOp2InMacro = Op2->getExprLoc().isMacroID();
 
     // Exclude the specific expression from triggering the warning.
-    if (!(IsOp1InMacro && IsOp2InMacro && Op1->getSourceRange() == Op2->getSourceRange())) {
-    // If the RHS can be constant folded, and if it constant folds to something
-    // that isn't 0 or 1 (which indicate a potential logical operation that
-    // happened to fold to true/false) then warn.
-    // Parens on the RHS are ignored.
-    // If the RHS can be constant folded, and if it constant folds to something
-    // that isn't 0 or 1 (which indicate a potential logical operation that
-    // happened to fold to true/false) then warn.
-    // Parens on the RHS are ignored.
-    Expr::EvalResult EVResult;
-    if (Op2->EvaluateAsInt(EVResult, Context)) {
-      llvm::APSInt Result = EVResult.Val.getInt();
-      if ((getLangOpts().Bool && !Op2->getType()->isBooleanType() &&
-           !Op2->getExprLoc().isMacroID()) ||
-          (Result != 0 && Result != 1)) {
-        Diag(Loc, diag::warn_logical_instead_of_bitwise)
-            << Op2->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
-        // Suggest replacing the logical operator with the bitwise version
-        Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
-            << (Opc == BO_LAnd ? "&" : "|")
-            << FixItHint::CreateReplacement(
-                   SourceRange(Loc, getLocForEndOfToken(Loc)),
-                   Opc == BO_LAnd ? "&" : "|");
-        if (Opc == BO_LAnd)
-          // Suggest replacing "Foo() && kNonZero" with "Foo()"
-          Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
-              << FixItHint::CreateRemoval(SourceRange(
-                     getLocForEndOfToken(Op1->getEndLoc()), Op2->getEndLoc()));
+    if (!(IsOp1InMacro && IsOp2InMacro &&
+          Op1->getSourceRange() == Op2->getSourceRange())) {
+      // If the RHS can be constant folded, and if it constant folds to
+      // something that isn't 0 or 1 (which indicate a potential logical
+      // operation that happened to fold to true/false) then warn. Parens on the
+      // RHS are ignored. If the RHS can be constant folded, and if it constant
+      // folds to something that isn't 0 or 1 (which indicate a potential
+      // logical operation that happened to fold to true/false) then warn.
+      // Parens on the RHS are ignored.
+      Expr::EvalResult EVResult;
+      if (Op2->EvaluateAsInt(EVResult, Context)) {
+        llvm::APSInt Result = EVResult.Val.getInt();
+        if ((getLangOpts().Bool && !Op2->getType()->isBooleanType() &&
+             !Op2->getExprLoc().isMacroID()) ||
+            (Result != 0 && Result != 1)) {
+          Diag(Loc, diag::warn_logical_instead_of_bitwise)
+              << Op2->getSourceRange() << (Opc == BO_LAnd ? "&&" : "||");
+          // Suggest replacing the logical operator with the bitwise version
+          Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
+              << (Opc == BO_LAnd ? "&" : "|")
+              << FixItHint::CreateReplacement(
+                     SourceRange(Loc, getLocForEndOfToken(Loc)),
+                     Opc == BO_LAnd ? "&" : "|");
+          if (Opc == BO_LAnd)
+            // Suggest replacing "Foo() && kNonZero" with "Foo()"
+            Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
+                << FixItHint::CreateRemoval(
+                       SourceRange(getLocForEndOfToken(Op1->getEndLoc()),
+                                   Op2->getEndLoc()));
+        }
       }
     }
   }
-      }
 }
 
 // C99 6.5.[13,14]


        


More information about the cfe-commits mailing list