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

Reviewers: djasper, sbenza, bkramer

Reviewed By: bkramer

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D4463

llvm-svn: 212814
This commit is contained in:
Alexander Kornienko 2014-07-11 13:44:51 +00:00
parent c97126b1c9
commit a2c4950e6e
4 changed files with 13 additions and 14 deletions

View File

@ -10,8 +10,14 @@ TEMPORARY_FILE=$3.cpp
# We need to keep the comments to preserve line numbers while avoiding empty # We need to keep the comments to preserve line numbers while avoiding empty
# lines which could potentially trigger formatting-related checks. # lines which could potentially trigger formatting-related checks.
sed 's#// *[A-Z-]\+:.*#//#' ${INPUT_FILE} > ${TEMPORARY_FILE} 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 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 fi

View File

@ -15,19 +15,19 @@ using namespace llvm;
void foo(const Twine &x); void foo(const Twine &x);
static Twine Moo = Twine("bark") + "bah"; 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-MESSAGES: note: FIX-IT applied suggested code changes
// CHECK-FIXES: static std::string Moo = (Twine("bark") + "bah").str(); // CHECK-FIXES: static std::string Moo = (Twine("bark") + "bah").str();
int main() { int main() {
const Twine t = Twine("a") + "b" + Twine(42); 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-MESSAGES: note: FIX-IT applied suggested code changes
// CHECK-FIXES: std::string t = (Twine("a") + "b" + Twine(42)).str(); // CHECK-FIXES: std::string t = (Twine("a") + "b" + Twine(42)).str();
foo(Twine("a") + "b"); foo(Twine("a") + "b");
Twine Prefix = false ? "__INT_FAST" : "__UINT_FAST"; 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-MESSAGES: note: FIX-IT applied suggested code changes
// CHECK-FIXES: const char * Prefix = false ? "__INT_FAST" : "__UINT_FAST"; // CHECK-FIXES: const char * Prefix = false ? "__INT_FAST" : "__UINT_FAST";
} }

View File

@ -1,8 +1,6 @@
// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-redundant-smartptr-get %t // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-redundant-smartptr-get %t
// REQUIRES: shell // REQUIRES: shell
// CHECK-MESSAGES-NOT: warning
namespace std { namespace std {
template <typename T> template <typename T>
@ -103,8 +101,6 @@ void Positive() {
// CHECK-FIXES: bb = nullptr != *ss; // CHECK-FIXES: bb = nullptr != *ss;
} }
// CHECK-MESSAGES-NOT: warning:
void Negative() { void Negative() {
struct NegPtr { struct NegPtr {
int* get(); int* get();

View File

@ -1,8 +1,6 @@
// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-use-override %t // RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-use-override %t
// REQUIRES: shell // REQUIRES: shell
// CHECK-MESSAGES-NOT: warning:
#define ABSTRACT = 0 #define ABSTRACT = 0
#define OVERRIDE override #define OVERRIDE override
@ -198,6 +196,7 @@ template <typename T> struct TemplateBase {
template <typename T> struct DerivedFromTemplate : public TemplateBase<T> { template <typename T> struct DerivedFromTemplate : public TemplateBase<T> {
virtual void f(T t); virtual void f(T t);
// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
// CHECK-FIXES: {{^ void f\(T t\) override;}} // CHECK-FIXES: {{^ void f\(T t\) override;}}
}; };
void f() { DerivedFromTemplate<int>().f(2); } void f() { DerivedFromTemplate<int>().f(2); }
@ -220,5 +219,3 @@ struct MembersOfSpecializations : public Base {
}; };
template <> void MembersOfSpecializations<3>::a() {} template <> void MembersOfSpecializations<3>::a() {}
void f() { MembersOfSpecializations<3>().a(); }; void f() { MembersOfSpecializations<3>().a(); };
// CHECK-MESSAGES-NOT: warning: