[PATCH] D66046: Add new tautological compare warning for bitwise-or with a non-zero constant

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 12 15:31:27 PDT 2019


NoQ added inline comments.


================
Comment at: lib/Analysis/CFG.cpp:1118
+    Expr::EvalResult Result;
+    if (!Constant->EvaluateAsInt(Result, *Context))
+      return {};
----------------
It's kinda strange to me that we first confirm that it's a constant by doing `tryTransformToIntOrEnumConstant`, but then fire up the heavy machinery of `EvaluateAsInt` anyway. Did you consider using only `EvaluateAsInt()` to begin with? I guess you're trying to make sure that "the user's intent is clear" as other similar warnings do, right? Could you comment on that?


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

https://reviews.llvm.org/D66046





More information about the cfe-commits mailing list