r245250 - Make a test less brittle.

Richard Trieu via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 17 15:18:30 PDT 2015


Author: rtrieu
Date: Mon Aug 17 17:18:30 2015
New Revision: 245250

URL: http://llvm.org/viewvc/llvm-project?rev=245250&view=rev
Log:
Make a test less brittle.

Capture line numbers in a variable for FileCheck instead of hardcoding them.

Modified:
    cfe/trunk/test/SemaCXX/warn-logical-not-compare.cpp

Modified: cfe/trunk/test/SemaCXX/warn-logical-not-compare.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-logical-not-compare.cpp?rev=245250&r1=245249&r2=245250&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/warn-logical-not-compare.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-logical-not-compare.cpp Mon Aug 17 17:18:30 2015
@@ -11,67 +11,73 @@ bool test1(int i1, int i2, bool b1, bool
   // expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{10:10-10:10}:"("
-  // CHECK: fix-it:"{{.*}}":{10:18-10:18}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{10:9-10:9}:"("
-  // CHECK: fix-it:"{{.*}}":{10:12-10:12}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
 
   ret = !i1 != i2;
   //expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{21:10-21:10}:"("
-  // CHECK: fix-it:"{{.*}}":{21:18-21:18}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{21:9-21:9}:"("
-  // CHECK: fix-it:"{{.*}}":{21:12-21:12}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
 
   ret = !i1 < i2;
   //expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{32:10-32:10}:"("
-  // CHECK: fix-it:"{{.*}}":{32:17-32:17}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{32:9-32:9}:"("
-  // CHECK: fix-it:"{{.*}}":{32:12-32:12}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
 
   ret = !i1 > i2;
   //expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{43:10-43:10}:"("
-  // CHECK: fix-it:"{{.*}}":{43:17-43:17}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{43:9-43:9}:"("
-  // CHECK: fix-it:"{{.*}}":{43:12-43:12}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
 
   ret = !i1 <= i2;
   //expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{54:10-54:10}:"("
-  // CHECK: fix-it:"{{.*}}":{54:18-54:18}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{54:9-54:9}:"("
-  // CHECK: fix-it:"{{.*}}":{54:12-54:12}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
 
   ret = !i1 >= i2;
   //expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{65:10-65:10}:"("
-  // CHECK: fix-it:"{{.*}}":{65:18-65:18}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{65:9-65:9}:"("
-  // CHECK: fix-it:"{{.*}}":{65:12-65:12}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:12-[[line]]:12}:")"
 
   ret = i1 == i2;
   ret = i1 != i2;
@@ -99,12 +105,13 @@ bool test1(int i1, int i2, bool b1, bool
   // expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{98:10-98:10}:"("
-  // CHECK: fix-it:"{{.*}}":{98:24-98:24}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:24-[[line]]:24}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{98:9-98:9}:"("
-  // CHECK: fix-it:"{{.*}}":{98:18-98:18}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:18-[[line]]:18}:")"
 
   ret = (!getInt()) == i1;
   ret = !getBool() == b1;
@@ -125,45 +132,49 @@ bool test2 (E e) {
   // expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{124:10-124:10}:"("
-  // CHECK: fix-it:"{{.*}}":{124:17-124:17}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:17-[[line]]:17}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{124:9-124:9}:"("
-  // CHECK: fix-it:"{{.*}}":{124:11-124:11}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:11-[[line]]:11}:")"
 
   ret = !e == getE();
   // expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{135:10-135:10}:"("
-  // CHECK: fix-it:"{{.*}}":{135:21-135:21}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:21-[[line]]:21}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{135:9-135:9}:"("
-  // CHECK: fix-it:"{{.*}}":{135:11-135:11}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:11-[[line]]:11}:")"
 
   ret = !getE() == e1;
   // expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{146:10-146:10}:"("
-  // CHECK: fix-it:"{{.*}}":{146:22-146:22}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:22-[[line]]:22}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{146:9-146:9}:"("
-  // CHECK: fix-it:"{{.*}}":{146:16-146:16}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:16-[[line]]:16}:")"
 
   ret = !getE() == getE();
   // expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:9: warning
   // CHECK: to evaluate the comparison first
-  // CHECK: fix-it:"{{.*}}":{157:10-157:10}:"("
-  // CHECK: fix-it:"{{.*}}":{157:26-157:26}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:10-[[line]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:26-[[line]]:26}:")"
   // CHECK: to silence this warning
-  // CHECK: fix-it:"{{.*}}":{157:9-157:9}:"("
-  // CHECK: fix-it:"{{.*}}":{157:16-157:16}:")"
+  // CHECK: fix-it:"{{.*}}":{[[line]]:9-[[line]]:9}:"("
+  // CHECK: fix-it:"{{.*}}":{[[line]]:16-[[line]]:16}:")"
 
   ret = !(e == e1);
   ret = !(e == getE());
@@ -186,6 +197,7 @@ bool PR16673(int x) {
   // expected-warning at -1 {{logical not is only applied to the left hand side of this comparison}}
   // expected-note at -2 {{add parentheses after the '!' to evaluate the comparison first}}
   // expected-note at -3 {{add parentheses around left hand side expression to silence this warning}}
+  // CHECK: warn-logical-not-compare.cpp:[[line:[0-9]*]]:11: warning
   // CHECK: to evaluate the comparison first
   // CHECK-NOT: fix-it
   // CHECK: to silence this warning




More information about the cfe-commits mailing list