[PATCH] D59360: [clang-tidy] Fix more false positives for bugprone-string-integer-assignment

Alexander Kornienko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 19 09:52:53 PDT 2019


alexfh added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:115
+    Expr::EvalResult EvalResult;
+    if (!E->EvaluateAsInt(EvalResult, Ctx, Expr::SE_AllowSideEffects))
+      return false;
----------------
courbet wrote:
> alexfh wrote:
> > I believe you should also check (or assert) that `E` is not instantiation-dependent before running the evaluator.
> Interesting. AFAICT if I don't check that , I end up warning in the cases when the instantiation does result in a too large constant, which is what we want (the user should add a cast if they want to silence this). 
IIUC, expression evaluation is just not supposed to be used on instantiation-dependent expressions. I've recently fixed a related crash (https://reviews.llvm.org/rL355401). I guess, there's a similar possibility here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59360





More information about the cfe-commits mailing list