[PATCH] D37565: [Sema] -Wtautological-compare: handle comparison of unsigned with 0S.

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 7 14:32:58 PDT 2017


rjmccall added a comment.

Great, thanks.  Just a few tweaks.



================
Comment at: docs/ReleaseNotes.rst:76
+  ``0`` constant was adjusted to warn regardless of whether the constant is
+  signed or unsigned.
+
----------------
"now warns when comparing an unsigned integer and 0 regardless of whether the constant is signed or unsigned."


================
Comment at: docs/ReleaseNotes.rst:79
+- ``-Wtautological-compare`` now warns about comparison of signed integer and
+  ``0U`` constant when appropriate.
+
----------------
Probably better to be clear here: "now warns about comparing a signed integer and 0 when the signed integer is coerced to an unsigned type for the comparison."


================
Comment at: docs/ReleaseNotes.rst:83
+  already warned about comparison of signed integer (which is automatically
+  promoted to an unsigned integer) and ``0U`` constant.
+
----------------
I'm not sure this level of detail is necessary in release notes.


================
Comment at: lib/Sema/SemaChecking.cpp:8879
+  // on -Wsign-compare
+  if(CheckTautologicalComparisonWithZero(S, E))
+    return AnalyzeImpConvsInComparison(S, E);
----------------
Space after 'if', and I would suggest for the comment:

  "If this is a tautological comparison, suppress -Wsign-compare."


Repository:
  rL LLVM

https://reviews.llvm.org/D37565





More information about the cfe-commits mailing list