[PATCH] Modify the tests to use FileCheck -implicit-check-not option being proposed in D4462

Alexander Kornienko alexfh at google.com
Thu Jul 10 08:03:13 PDT 2014


Hi djasper, bkramer, sbenza,

http://reviews.llvm.org/D4463

Files:
  test/clang-tidy/check_clang_tidy_fix.sh
  test/clang-tidy/llvm-twine-local.cpp
  test/clang-tidy/redundant-smartptr-get.cpp
  test/clang-tidy/use-override.cpp

Index: test/clang-tidy/check_clang_tidy_fix.sh
===================================================================
--- test/clang-tidy/check_clang_tidy_fix.sh
+++ test/clang-tidy/check_clang_tidy_fix.sh
@@ -10,8 +10,14 @@
 # We need to keep the comments to preserve line numbers while avoiding empty
 # lines which could potentially trigger formatting-related checks.
 sed 's#// *[A-Z-]\+:.*#//#' ${INPUT_FILE} > ${TEMPORARY_FILE}
-clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" -- --std=c++11 > ${TEMPORARY_FILE}.msg 2>&1
-FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} -check-prefix=CHECK-FIXES -strict-whitespace || exit $?
+
+clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" -- --std=c++11 \
+  > ${TEMPORARY_FILE}.msg 2>&1
+
+FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} \
+  -check-prefix=CHECK-FIXES -strict-whitespace || exit $?
+
 if grep -q CHECK-MESSAGES ${INPUT_FILE}; then
-  FileCheck -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} -check-prefix=CHECK-MESSAGES || exit $?
+  FileCheck -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} \
+    -check-prefix=CHECK-MESSAGES -implicit-check-not="warning:" || exit $?
 fi
Index: test/clang-tidy/llvm-twine-local.cpp
===================================================================
--- test/clang-tidy/llvm-twine-local.cpp
+++ test/clang-tidy/llvm-twine-local.cpp
@@ -15,19 +15,19 @@
 void foo(const Twine &x);
 
 static Twine Moo = Twine("bark") + "bah";
-// CHECK-MESSAGES: twine variables are prone to use-after-free bugs
+// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to use-after-free bugs
 // CHECK-MESSAGES: note: FIX-IT applied suggested code changes
 // CHECK-FIXES: static std::string Moo = (Twine("bark") + "bah").str();
 
 int main() {
   const Twine t = Twine("a") + "b" + Twine(42);
-// CHECK-MESSAGES: twine variables are prone to use-after-free bugs
+// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: twine variables are prone to use-after-free bugs
 // CHECK-MESSAGES: note: FIX-IT applied suggested code changes
 // CHECK-FIXES: std::string t = (Twine("a") + "b" + Twine(42)).str();
   foo(Twine("a") + "b");
 
   Twine Prefix = false ? "__INT_FAST" : "__UINT_FAST";
-// CHECK-MESSAGES: twine variables are prone to use-after-free bugs
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: twine variables are prone to use-after-free bugs
 // CHECK-MESSAGES: note: FIX-IT applied suggested code changes
 // CHECK-FIXES: const char * Prefix = false ? "__INT_FAST" : "__UINT_FAST";
 }
Index: test/clang-tidy/redundant-smartptr-get.cpp
===================================================================
--- test/clang-tidy/redundant-smartptr-get.cpp
+++ test/clang-tidy/redundant-smartptr-get.cpp
@@ -1,8 +1,6 @@
 // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-redundant-smartptr-get %t
 // REQUIRES: shell
 
-// CHECK-MESSAGES-NOT: warning
-
 namespace std {
 
 template <typename T>
@@ -103,8 +101,6 @@
   // CHECK-FIXES: bb = nullptr != *ss;
 }
 
-// CHECK-MESSAGES-NOT: warning:
-
 void Negative() {
   struct NegPtr {
     int* get();
Index: test/clang-tidy/use-override.cpp
===================================================================
--- test/clang-tidy/use-override.cpp
+++ test/clang-tidy/use-override.cpp
@@ -1,8 +1,6 @@
 // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-use-override %t
 // REQUIRES: shell
 
-// CHECK-MESSAGES-NOT: warning:
-
 #define ABSTRACT = 0
 
 #define OVERRIDE override
@@ -198,6 +196,7 @@
 
 template <typename T> struct DerivedFromTemplate : public TemplateBase<T> {
   virtual void f(T t);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
   // CHECK-FIXES: {{^  void f\(T t\) override;}}
 };
 void f() { DerivedFromTemplate<int>().f(2); }
@@ -220,5 +219,3 @@
 };
 template <> void MembersOfSpecializations<3>::a() {}
 void f() { MembersOfSpecializations<3>().a(); };
-
-// CHECK-MESSAGES-NOT: warning:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4463.11273.patch
Type: text/x-patch
Size: 3907 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140710/dd44cd8b/attachment.bin>


More information about the cfe-commits mailing list