[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 5 06:16:41 PDT 2017


lebedev.ri added inline comments.


================
Comment at: lib/Sema/SemaChecking.cpp:8719
+  // Type limit values are handled later by CheckTautologicalComparison().
+  if (IsTypeLimit(S, Other, Constant, ConstValue) && (!OtherIsBooleanType))
     return;
----------------
rsmith wrote:
> Is this necessary? (Aren't the type limit values always within the range of the type in question?)
> 
> Can we avoid evaluating `Constant` a extra time here? (We already have its value in `Value`.)
Uhm, good question :)
If i remove this, `check-clang-sema` and `check-clang-semacxx` still pass.
I agree that it does not make much sense. Initially it was only checking for `Value == 0`.
Git suggests that initially this branch was added by @rtrieu, maybe can help.


Repository:
  rL LLVM

https://reviews.llvm.org/D38101





More information about the cfe-commits mailing list