[PATCH] D130510: Missing tautological compare warnings due to unary operators

Muhammad Usman Shahid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 26 11:02:12 PDT 2022


Codesbyusman marked an inline comment as done.
Codesbyusman added inline comments.


================
Comment at: clang/lib/Analysis/CFG.cpp:970-980
+    if (LHSExpr->EvaluateAsInt(IntExprResult, *Context)) {
+       // Evaluating value.
+      BoolExpr = RHSExpr;
+    }
+    else if (RHSExpr->EvaluateAsInt(IntExprResult, *Context)) {
       BoolExpr = LHSExpr;
     }
----------------
aaron.ballman wrote:
> Coding style fix.
ooh ..  nice will update it


================
Comment at: clang/lib/Analysis/CFG.cpp:985
+                  BitOp->getOpcode() == BO_Or  || 
+                  BitOp->getOpcode() == BO_Xor)) {
       const Expr *LHSExpr2 = BitOp->getLHS()->IgnoreParens();
----------------
aaron.ballman wrote:
> Be sure to add test coverage for this change.
Yes working on that


================
Comment at: clang/lib/Analysis/CFG.cpp:1008
                                                      B->getOpcode() != BO_EQ);
         TryResult(B->getOpcode() != BO_EQ);
       }
----------------
aaron.ballman wrote:
> This looks like an existing bug and suggests we're missing test coverage -- we create a `TryResult` object but do nothing with it; I suspect we wanted to return this result.
> 
> Can you try to add test coverage that hits this code path to verify the current behavior is wrong, then change it to return the result to make sure the behavior is corrected?
ok will try to make a test that will cover it


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130510/new/

https://reviews.llvm.org/D130510



More information about the cfe-commits mailing list