[cfe-commits] r113334 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td test/Analysis/additive-folding.c test/Analysis/null-deref-ps.c

John McCall rjmccall at apple.com
Tue Sep 7 19:01:27 PDT 2010


Author: rjmccall
Date: Tue Sep  7 21:01:27 2010
New Revision: 113334

URL: http://llvm.org/viewvc/llvm-project?rev=113334&view=rev
Log:
Put the tautological-comparison-of-unsigned-against-zero warnings in
-Wtautological-compare instead of -Wsign-compare, which also implies turning
them on by default.

Restoration of r112877.


Modified:
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/test/Analysis/additive-folding.c
    cfe/trunk/test/Analysis/null-deref-ps.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=113334&r1=113333&r2=113334&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Sep  7 21:01:27 2010
@@ -101,6 +101,7 @@
 def : DiagGroup<"stack-protector">;
 def : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
+def TautologicalCompare : DiagGroup<"tautological-compare">;
 
 // Preprocessor warnings.
 def : DiagGroup<"builtin-macro-redefined">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=113334&r1=113333&r2=113334&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep  7 21:01:27 2010
@@ -2204,10 +2204,10 @@
   InGroup<SignCompare>, DefaultIgnore;
 def warn_lunsigned_always_true_comparison : Warning<
   "comparison of unsigned expression %0 is always %1">,
-  InGroup<SignCompare>, DefaultIgnore;
+  InGroup<TautologicalCompare>;
 def warn_runsigned_always_true_comparison : Warning<
   "comparison of %0 unsigned expression is always %1">,
-  InGroup<SignCompare>, DefaultIgnore;
+  InGroup<TautologicalCompare>;
 
 def err_invalid_this_use : Error<
   "invalid use of 'this' outside of a nonstatic member function">;
@@ -3068,7 +3068,7 @@
 // Array comparisons have similar warnings
 def warn_comparison_always : Warning<
   "%select{self-|array }0comparison always evaluates to %select{false|true|a constant}1">,
-  InGroup<DiagGroup<"tautological-compare">>;
+  InGroup<TautologicalCompare>;
 
 def warn_stringcompare : Warning<
   "result of comparison against %select{a string literal|@encode}0 is "

Modified: cfe/trunk/test/Analysis/additive-folding.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/additive-folding.c?rev=113334&r1=113333&r2=113334&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/additive-folding.c (original)
+++ cfe/trunk/test/Analysis/additive-folding.c Tue Sep  7 21:01:27 2010
@@ -183,14 +183,14 @@
 
 void tautologyGE (unsigned a) {
   char* b = malloc(1);
-  if (a >= 0)
+  if (a >= 0) // expected-warning{{always true}}
     free(b);
   return; // no-warning
 }
 
 void tautologyLT (unsigned a) {
   char* b = malloc(1);
-  if (a < 0)
+  if (a < 0) // expected-warning{{always false}}
     return; // expected-warning{{never executed}}
   free(b);
 }

Modified: cfe/trunk/test/Analysis/null-deref-ps.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/null-deref-ps.c?rev=113334&r1=113333&r2=113334&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/null-deref-ps.c (original)
+++ cfe/trunk/test/Analysis/null-deref-ps.c Tue Sep  7 21:01:27 2010
@@ -237,7 +237,7 @@
 // Test case from <rdar://problem/6407949>
 void f11(unsigned i) {
   int *x = 0;
-  if (i >= 0) {
+  if (i >= 0) { // expected-warning{{always true}}
     // always true
   } else {
     *x = 42; // no-warning





More information about the cfe-commits mailing list