[clang-tools-extra] r212653 - Check messages and fixes in the same test.

Alexander Kornienko alexfh at google.com
Wed Jul 9 14:09:27 PDT 2014


Author: alexfh
Date: Wed Jul  9 16:09:26 2014
New Revision: 212653

URL: http://llvm.org/viewvc/llvm-project?rev=212653&view=rev
Log:
Check messages and fixes in the same test.

Summary: This reduces duplication of test code and improves locality of checks.

Reviewers: sbenza, djasper

Reviewed By: sbenza, djasper

Subscribers: cfe-commits

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

Removed:
    clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_output.sh
    clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp
    clang-tools-extra/trunk/test/clang-tidy/use-override.cpp
Modified:
    clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh
    clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp
    clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get-fix.cpp
    clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh?rev=212653&r1=212652&r2=212653&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh Wed Jul  9 16:09:26 2014
@@ -6,9 +6,12 @@ INPUT_FILE=$1
 CHECK_TO_RUN=$2
 TEMPORARY_FILE=$3.cpp
 
-grep -Ev "// *[A-Z-]+:" ${INPUT_FILE} > ${TEMPORARY_FILE}
+# Remove the contents of the CHECK lines to avoid CHECKs matching on themselves.
+# 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} -strict-whitespace || exit $?
-if grep CHECK-MESSAGES ${INPUT_FILE}; then
+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 $?
 fi

Removed: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_output.sh
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_output.sh?rev=212652&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_output.sh (original)
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_output.sh (removed)
@@ -1,9 +0,0 @@
-#!/bin/sh
-#
-# Run clang-tidy and verify its command line output.
-
-INPUT_FILE=$1
-CHECK_TO_RUN=$2
-
-clang-tidy --checks="-*,${CHECK_TO_RUN}" ${INPUT_FILE} -- --std=c++11 -x c++ \
-  | FileCheck ${INPUT_FILE}

Modified: clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp?rev=212653&r1=212652&r2=212653&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp Wed Jul  9 16:09:26 2014
@@ -17,17 +17,17 @@ void foo(const Twine &x);
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: twine variables are prone to use-after-free bugs
 // CHECK-MESSAGES: note: FIX-IT applied suggested code changes
-// CHECK: static std::string Moo = (Twine("bark") + "bah").str();
+// 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: note: FIX-IT applied suggested code changes
-// CHECK: std::string t = (Twine("a") + "b" + Twine(42)).str();
+// 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: note: FIX-IT applied suggested code changes
-// CHECK: const char * Prefix = false ? "__INT_FAST" : "__UINT_FAST";
+// CHECK-FIXES: const char * Prefix = false ? "__INT_FAST" : "__UINT_FAST";
 }

Modified: clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get-fix.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get-fix.cpp?rev=212653&r1=212652&r2=212653&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get-fix.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get-fix.cpp Wed Jul  9 16:09:26 2014
@@ -1,6 +1,8 @@
 // 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>
@@ -34,33 +36,96 @@ struct int_ptr {
   int& operator*();
 };
 
+struct Fail1 {
+  Bar* get();
+};
+struct Fail2 {
+  Bar* get();
+  int* operator->();
+  int& operator*();
+};
+
 void Positive() {
   BarPtr u;
-  // CHECK: BarPtr u;
+  // CHECK-FIXES: BarPtr u;
   BarPtr().get()->Do();
-  // CHECK: BarPtr()->Do();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer. [misc-redundant-smartptr-get]
+  // CHECK-MESSAGES: BarPtr().get()->Do();
+  // CHECK-FIXES: BarPtr()->Do();
 
   u.get()->ConstDo();
-  // CHECK: u->ConstDo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: u.get()->ConstDo();
+  // CHECK-FIXES: u->ConstDo();
 
   Bar& b = *BarPtr().get();
-  // CHECK: Bar& b = *BarPtr();
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: Bar& b = *BarPtr().get();
+  // CHECK-FIXES: Bar& b = *BarPtr();
+
+  Bar& b2 = *std::unique_ptr<Bar>().get();
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: Bar& b2 = *std::unique_ptr<Bar>().get();
+  // CHECK-FIXES: Bar& b2 = *std::unique_ptr<Bar>();
 
   (*BarPtr().get()).ConstDo();
-  // CHECK: (*BarPtr()).ConstDo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: (*BarPtr().get()).ConstDo();
+  // CHECK-FIXES: (*BarPtr()).ConstDo();
+
+  (*std::unique_ptr<Bar>().get()).ConstDo();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: (*std::unique_ptr<Bar>().get()).ConstDo();
+  // CHECK-FIXES: (*std::unique_ptr<Bar>()).ConstDo();
 
-  BarPtr* up;
+  std::unique_ptr<Bar>* up;
   (*up->get()).Do();
-  // CHECK: (**up).Do();
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: (*up->get()).Do();
+  // CHECK-FIXES: (**up).Do();
 
   int_ptr ip;
   int i = *ip.get();
-  // CHECK: int i = *ip;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: int i = *ip.get();
+  // CHECK-FIXES: int i = *ip;
 
   std::unique_ptr<int> uu;
   std::shared_ptr<double> *ss;
   bool bb = uu.get() == nullptr;
-  // CHECK: bool bb = uu == nullptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: uu.get() == nullptr;
+  // CHECK-FIXES: bool bb = uu == nullptr;
+
   bb = nullptr != ss->get();
-  // CHECK: bb = nullptr != *ss;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: Redundant get() call on smart pointer.
+  // CHECK-MESSAGES: nullptr != ss->get();
+  // CHECK-FIXES: bb = nullptr != *ss;
+}
+
+// CHECK-MESSAGES-NOT: warning:
+
+void Negative() {
+  struct NegPtr {
+    int* get();
+    int* operator->() {
+      return &*this->get();
+    }
+    int& operator*() {
+      return *get();
+    }
+  };
+
+  std::unique_ptr<Bar>* u;
+  u->get()->Do();
+
+  Fail1().get()->Do();
+  Fail2().get()->Do();
+  const Bar& b = *Fail1().get();
+  (*Fail2().get()).Do();
+
+  int_ptr ip;
+  bool bb = std::unique_ptr<int>().get() == NULL;
+  bb = ip.get() == nullptr;
+  bb = u->get() == NULL;
 }

Removed: clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp?rev=212652&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/redundant-smartptr-get.cpp (removed)
@@ -1,107 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_output.sh %s misc-redundant-smartptr-get
-// REQUIRES: shell
-
-// CHECK-NOT: warning
-
-namespace std {
-
-template <typename T>
-struct unique_ptr {
-  T& operator*() const;
-  T* operator->() const;
-  T* get() const;
-};
-
-template <typename T>
-struct shared_ptr {
-  T& operator*() const;
-  T* operator->() const;
-  T* get() const;
-};
-
-}  // namespace std
-#define NULL __null
-
-struct int_ptr {
-  int* get();
-  int* operator->();
-  int& operator*();
-};
-
-struct Bar {
-  void Do();
-  void ConstDo() const;
-};
-
-struct Fail1 {
-  Bar* get();
-};
-struct Fail2 {
-  Bar* get();
-  int* operator->();
-  int& operator*();
-};
-
-void Positive() {
-  std::unique_ptr<Bar> u;
-  std::unique_ptr<Bar>().get()->Do();
-  // CHECK: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer. [misc-redundant-smartptr-get]
-  // CHECK: std::unique_ptr<Bar>().get()->Do();
-
-  u.get()->ConstDo();
-  // CHECK: :[[@LINE-1]]:3: warning: Redundant get() call on smart pointer.
-  // CHECK: u.get()->ConstDo();
-
-  Bar& b = *std::unique_ptr<Bar>().get();
-  // CHECK: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
-  // CHECK: Bar& b = *std::unique_ptr<Bar>().get();
-
-  (*std::unique_ptr<Bar>().get()).ConstDo();
-  // CHECK: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
-  // CHECK: (*std::unique_ptr<Bar>().get()).ConstDo();
-
-  std::unique_ptr<Bar>* up;
-  (*up->get()).Do();
-  // CHECK: :[[@LINE-1]]:5: warning: Redundant get() call on smart pointer.
-  // CHECK: (*up->get()).Do();
-
-  int_ptr ip;
-  int i = *ip.get();
-  // CHECK: :[[@LINE-1]]:12: warning: Redundant get() call on smart pointer.
-  // CHECK: int i = *ip.get();
-
-  bool bb = u.get() == nullptr;
-  // CHECK: :[[@LINE-1]]:13: warning: Redundant get() call on smart pointer.
-  // CHECK: u.get() == nullptr;
-  std::shared_ptr<double> *sp;
-  bb = nullptr != sp->get();
-  // CHECK: :[[@LINE-1]]:19: warning: Redundant get() call on smart pointer.
-  // CHECK: nullptr != sp->get();
-}
-
-// CHECK-NOT: warning:
-
-void Negative() {
-  struct NegPtr {
-    int* get();
-    int* operator->() {
-      return &*this->get();
-    }
-    int& operator*() {
-      return *get();
-    }
-  };
-
-  std::unique_ptr<Bar>* u;
-  u->get()->Do();
-
-  Fail1().get()->Do();
-  Fail2().get()->Do();
-  const Bar& b = *Fail1().get();
-  (*Fail2().get()).Do();
-
-  int_ptr ip;
-  bool bb = std::unique_ptr<int>().get() == NULL;
-  bb = ip.get() == nullptr;
-  bb = u->get() == NULL;
-}

Modified: clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp?rev=212653&r1=212652&r2=212653&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/use-override-fix.cpp Wed Jul  9 16:09:26 2014
@@ -1,6 +1,8 @@
 // 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
@@ -32,113 +34,161 @@ struct Base {
 struct SimpleCases : public Base {
 public:
   virtual ~SimpleCases();
-  // CHECK: {{^  ~SimpleCases\(\) override;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using 'override' or 'final' instead of 'virtual'
+  // CHECK-FIXES: {{^  ~SimpleCases\(\) override;}}
 
   void a();
-  // CHECK: {{^  void a\(\) override;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Use exactly
+  // CHECK-FIXES: {{^  void a\(\) override;}}
+
   void b() override;
-  // CHECK: {{^  void b\(\) override;}}
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^  void b\(\) override;}}
+
   virtual void c();
-  // CHECK: {{^  void c\(\) override;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  void c\(\) override;}}
+
   virtual void d() override;
-  // CHECK: {{^  void d\(\) override;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  void d\(\) override;}}
 
   virtual void e() = 0;
-  // CHECK: {{^  void e\(\) override = 0;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  void e\(\) override = 0;}}
+
   virtual void f()=0;
-  // CHECK: {{^  void f\(\)override =0;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  void f\(\)override =0;}}
+
   virtual void g() ABSTRACT;
-  // CHECK: {{^  void g\(\) override ABSTRACT;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  void g\(\) override ABSTRACT;}}
 
   virtual void j() const;
-  // CHECK: {{^  void j\(\) const override;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  void j\(\) const override;}}
+
   virtual MustUseResultObject k();  // Has an implicit attribute.
-  // CHECK: {{^  MustUseResultObject k\(\) override;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Prefer using
+  // CHECK-FIXES: {{^  MustUseResultObject k\(\) override;}}
+
   virtual bool l() MUST_USE_RESULT; // Has an explicit attribute
-  // CHECK: {{^  bool l\(\) override MUST_USE_RESULT;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  bool l\(\) override MUST_USE_RESULT;}}
 
   virtual void m() override final;
-  // CHECK: {{^  void m\(\) final;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  void m\(\) final;}}
 };
 
+// CHECK-MESSAGES-NOT: warning:
+
 void SimpleCases::i() {}
-// CHECK: {{^void SimpleCases::i\(\) {}}}
+// CHECK-FIXES: {{^void SimpleCases::i\(\) {}}}
 
 SimpleCases::~SimpleCases() {}
-// CHECK: {{^SimpleCases::~SimpleCases\(\) {}}}
+// CHECK-FIXES: {{^SimpleCases::~SimpleCases\(\) {}}}
 
 struct DefaultedDestructor : public Base {
   DefaultedDestructor() {}
   virtual ~DefaultedDestructor() = default;
-  // CHECK: {{^  ~DefaultedDestructor\(\) override = default;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using
+  // CHECK-FIXES: {{^  ~DefaultedDestructor\(\) override = default;}}
 };
 
 struct FinalSpecified : public Base {
 public:
   virtual ~FinalSpecified() final;
-  // CHECK: {{^  ~FinalSpecified\(\) final;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Use exactly
+  // CHECK-FIXES: {{^  ~FinalSpecified\(\) final;}}
 
   void b() final;
-  // CHECK: {{^  void b\(\) final;}}
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^  void b\(\) final;}}
+
   virtual void d() final;
-  // CHECK: {{^  void d\(\) final;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  void d\(\) final;}}
 
   virtual void e() final = 0;
-  // CHECK: {{^  void e\(\) final = 0;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  void e\(\) final = 0;}}
 
   virtual void j() const final;
-  // CHECK: {{^  void j\(\) const final;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  void j\(\) const final;}}
+
   virtual bool l() final MUST_USE_RESULT;
-  // CHECK: {{^  bool l\(\) final MUST_USE_RESULT;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  bool l\(\) final MUST_USE_RESULT;}}
 };
 
 struct InlineDefinitions : public Base {
 public:
   virtual ~InlineDefinitions() {}
-  // CHECK: {{^  ~InlineDefinitions\(\) override {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using
+  // CHECK-FIXES: {{^  ~InlineDefinitions\(\) override {}}}
 
   void a() {}
-  // CHECK: {{^  void a\(\) override {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: Use exactly
+  // CHECK-FIXES: {{^  void a\(\) override {}}}
+
   void b() override {}
-  // CHECK: {{^  void b\(\) override {}}}
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^  void b\(\) override {}}}
+
   virtual void c() {}
-  // CHECK: {{^  void c\(\) override {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  void c\(\) override {}}}
+
   virtual void d() override {}
-  // CHECK: {{^  void d\(\) override {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  void d\(\) override {}}}
 
   virtual void j() const {}
-  // CHECK: {{^  void j\(\) const override {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  void j\(\) const override {}}}
+
   virtual MustUseResultObject k() {}  // Has an implicit attribute.
-  // CHECK: {{^  MustUseResultObject k\(\) override {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: Prefer using
+  // CHECK-FIXES: {{^  MustUseResultObject k\(\) override {}}}
+
   virtual bool l() MUST_USE_RESULT {} // Has an explicit attribute
-  // CHECK: {{^  bool l\(\) override MUST_USE_RESULT {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  bool l\(\) override MUST_USE_RESULT {}}}
 };
 
 struct Macros : public Base {
   // Tests for 'virtual' and 'override' being defined through macros. Basically
   // give up for now.
   NOT_VIRTUAL void a() NOT_OVERRIDE;
-  // CHECK: {{^  NOT_VIRTUAL void a\(\) override NOT_OVERRIDE;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: Use exactly
+  // CHECK-FIXES: {{^  NOT_VIRTUAL void a\(\) override NOT_OVERRIDE;}}
 
   VIRTUAL void b() NOT_OVERRIDE;
-  // CHECK: {{^  VIRTUAL void b\(\) override NOT_OVERRIDE;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Prefer using
+  // CHECK-FIXES: {{^  VIRTUAL void b\(\) override NOT_OVERRIDE;}}
 
   NOT_VIRTUAL void c() OVERRIDE;
-  // CHECK: {{^  NOT_VIRTUAL void c\(\) OVERRIDE;}}
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^  NOT_VIRTUAL void c\(\) OVERRIDE;}}
 
   VIRTUAL void d() OVERRIDE;
-  // CHECK: {{^  VIRTUAL void d\(\) OVERRIDE;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  VIRTUAL void d\(\) OVERRIDE;}}
 
 #define FUNC(name, return_type) return_type name()
   FUNC(void, e);
-  // CHECK: {{^  FUNC\(void, e\);}}
+  // CHECK-FIXES: {{^  FUNC\(void, e\);}}
 
 #define F virtual void f();
   F
-  // CHECK: {{^  F}}
+  // CHECK-FIXES: {{^  F}}
 
   VIRTUAL void g() OVERRIDE final;
-  // CHECK: {{^  VIRTUAL void g\(\) final;}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: Use exactly
+  // CHECK-FIXES: {{^  VIRTUAL void g\(\) final;}}
 };
 
 // Tests for templates.
@@ -148,14 +198,15 @@ template <typename T> struct TemplateBas
 
 template <typename T> struct DerivedFromTemplate : public TemplateBase<T> {
   virtual void f(T t);
-  // CHECK: {{^  void f\(T t\) override;}}
+  // CHECK-FIXES: {{^  void f\(T t\) override;}}
 };
 void f() { DerivedFromTemplate<int>().f(2); }
 
 template <class C>
 struct UnusedMemberInstantiation : public C {
   virtual ~UnusedMemberInstantiation() {}
-  // CHECK: {{^  ~UnusedMemberInstantiation\(\) override {}}}
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: Prefer using
+  // CHECK-FIXES: {{^  ~UnusedMemberInstantiation\(\) override {}}}
 };
 struct IntantiateWithoutUse : public UnusedMemberInstantiation<Base> {};
 
@@ -164,7 +215,10 @@ struct IntantiateWithoutUse : public Unu
 template <int I>
 struct MembersOfSpecializations : public Base {
   void a() override;
-  // CHECK: {{^  void a\(\) override;}}
+  // CHECK-MESSAGES-NOT: warning:
+  // CHECK-FIXES: {{^  void a\(\) override;}}
 };
 template <> void MembersOfSpecializations<3>::a() {}
 void f() { MembersOfSpecializations<3>().a(); };
+
+// CHECK-MESSAGES-NOT: warning:

Removed: clang-tools-extra/trunk/test/clang-tidy/use-override.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/use-override.cpp?rev=212652&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/use-override.cpp (removed)
@@ -1,31 +0,0 @@
-// RUN: $(dirname %s)/check_clang_tidy_output.sh %s misc-use-override %t
-// REQUIRES: shell
-
-struct Base {
-  virtual ~Base() {}
-  virtual void a();
-  virtual void b();
-  virtual void c();
-  virtual void d();
-  virtual void e();
-  virtual void f();
-};
-
-struct SimpleCases : public Base {
-public:
-  virtual ~SimpleCases() {}
-  // CHECK: :[[@LINE-1]]:11: warning: Prefer using 'override' or 'final' instead of 'virtual'
-
-  void a();
-  // CHECK: :[[@LINE-1]]:8: warning: Use exactly
-  virtual void b();
-  // CHECK: :[[@LINE-1]]:16: warning: Prefer using
-  virtual void c() override;
-  // CHECK: :[[@LINE-1]]:16: warning: Use exactly
-  void d() override final;
-  // CHECK: :[[@LINE-1]]:8: warning: Use exactly
-  void e() override;
-  // CHECK-NOT: :[[@LINE-1]]:{{.*}} warning:
-  void f() final;
-  // CHECK-NOT: :[[@LINE-1]]:{{.*}} warning:
-};





More information about the cfe-commits mailing list