[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
Thu Mar 14 06:25:35 PDT 2019


alexfh added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:50
+public:
+  CharExpressionDetector(const QualType CharType, const ASTContext &Ctx)
+      : CharType(CharType), Ctx(Ctx) {}
----------------
No need for the top-level const in the first parameter.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:70
+
+    // ternary where at least one branch is a likely char expression, e.g.
+    //    i < 265 ? i : ' '
----------------
nit: Please capitalize the first word.


================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringIntegerAssignmentCheck.cpp:115
+    Expr::EvalResult EvalResult;
+    if (!E->EvaluateAsInt(EvalResult, Ctx, Expr::SE_AllowSideEffects))
+      return false;
----------------
I believe you should also check (or assert) that `E` is not instantiation-dependent before running the evaluator.


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