[clang-tools-extra] r374540 - [ClangTidy] Separate tests for infrastructure and checkers
Dmitri Gribenko via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 11 05:05:46 PDT 2019
Removed: clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp (removed)
@@ -1,324 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11-or-later %s google-readability-casting %t
-// FIXME: Fix the checker to work in C++17 mode.
-
-bool g() { return false; }
-
-enum Enum { Enum1 };
-struct X {};
-struct Y : public X {};
-
-void f(int a, double b, const char *cpc, const void *cpv, X *pX) {
- const char *cpc2 = (const char*)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting]
- // CHECK-FIXES: const char *cpc2 = cpc;
-
- typedef const char *Typedef1;
- typedef const char *Typedef2;
- Typedef1 t1;
- (Typedef2)t1;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: C-style casts are discouraged; use static_cast (if needed, the cast may be redundant) [google-readability-casting]
- // CHECK-FIXES: {{^}} static_cast<Typedef2>(t1);
- (const char*)t1;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
- // CHECK-FIXES: {{^}} static_cast<const char*>(t1);
- (Typedef1)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
- // CHECK-FIXES: {{^}} static_cast<Typedef1>(cpc);
- (Typedef1)t1;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant cast to the same type
- // CHECK-FIXES: {{^}} t1;
-
- char *pc = (char*)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use const_cast [google-readability-casting]
- // CHECK-FIXES: char *pc = const_cast<char*>(cpc);
- typedef char Char;
- Char *pChar = (Char*)pc;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}}; use static_cast (if needed
- // CHECK-FIXES: {{^}} Char *pChar = static_cast<Char*>(pc);
-
- (Char)*cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
- // CHECK-FIXES: {{^}} static_cast<Char>(*cpc);
-
- (char)*pChar;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed
- // CHECK-FIXES: {{^}} static_cast<char>(*pChar);
-
- (const char*)cpv;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast [
- // CHECK-FIXES: static_cast<const char*>(cpv);
-
- char *pc2 = (char*)(cpc + 33);
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast [
- // CHECK-FIXES: char *pc2 = const_cast<char*>(cpc + 33);
-
- const char &crc = *cpc;
- char &rc = (char&)crc;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}}; use const_cast [
- // CHECK-FIXES: char &rc = const_cast<char&>(crc);
-
- char &rc2 = (char&)*cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast [
- // CHECK-FIXES: char &rc2 = const_cast<char&>(*cpc);
-
- char ** const* const* ppcpcpc;
- char ****ppppc = (char****)ppcpcpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: {{.*}}; use const_cast [
- // CHECK-FIXES: char ****ppppc = const_cast<char****>(ppcpcpc);
-
- char ***pppc = (char***)*(ppcpcpc);
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: {{.*}}; use const_cast [
- // CHECK-FIXES: char ***pppc = const_cast<char***>(*(ppcpcpc));
-
- char ***pppc2 = (char***)(*ppcpcpc);
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}}; use const_cast [
- // CHECK-FIXES: char ***pppc2 = const_cast<char***>(*ppcpcpc);
-
- char *pc5 = (char*)(const char*)(cpv);
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast [
- // CHECK-MESSAGES: :[[@LINE-2]]:22: warning: {{.*}}; use static_cast [
- // CHECK-FIXES: char *pc5 = const_cast<char*>(static_cast<const char*>(cpv));
-
- int b1 = (int)b;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}; use static_cast [
- // CHECK-FIXES: int b1 = static_cast<int>(b);
- b1 = (const int&)b;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [
- // CHECK-FIXES: b1 = (const int&)b;
-
- b1 = (int) b;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}}
- // CHECK-FIXES: b1 = static_cast<int>(b);
-
- b1 = (int) b;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}}
- // CHECK-FIXES: b1 = static_cast<int>(b);
-
- b1 = (int) (b);
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}}
- // CHECK-FIXES: b1 = static_cast<int>(b);
-
- b1 = (int) (b);
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}}
- // CHECK-FIXES: b1 = static_cast<int>(b);
-
- Y *pB = (Y*)pX;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [
- Y &rB = (Y&)*pX;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [
-
- const char *pc3 = (const char*)cpv;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}; use static_cast [
- // CHECK-FIXES: const char *pc3 = static_cast<const char*>(cpv);
-
- char *pc4 = (char*)cpv;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [
- // CHECK-FIXES: char *pc4 = (char*)cpv;
-
- b1 = (int)Enum1;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast [
- // CHECK-FIXES: b1 = static_cast<int>(Enum1);
-
- Enum e = (Enum)b1;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}; use static_cast [
- // CHECK-FIXES: Enum e = static_cast<Enum>(b1);
-
- e = (Enum)Enum1;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
- // CHECK-FIXES: {{^}} e = Enum1;
-
- e = (Enum)e;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
- // CHECK-FIXES: {{^}} e = e;
-
- e = (Enum) e;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
- // CHECK-FIXES: {{^}} e = e;
-
- e = (Enum) (e);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type
- // CHECK-FIXES: {{^}} e = (e);
-
- static const int kZero = 0;
- (int)kZero;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant cast to the same type
- // CHECK-FIXES: {{^}} kZero;
-
- int b2 = int(b);
- int b3 = static_cast<double>(b);
- int b4 = b;
- double aa = a;
- (void)b2;
- return (void)g();
-}
-
-template <typename T>
-void template_function(T t, int n) {
- int i = (int)t;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [
- // CHECK-FIXES: int i = (int)t;
- int j = (int)n;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant cast to the same type
- // CHECK-FIXES: int j = n;
-}
-
-template <typename T>
-struct TemplateStruct {
- void f(T t, int n) {
- int k = (int)t;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast
- // CHECK-FIXES: int k = (int)t;
- int l = (int)n;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant cast to the same type
- // CHECK-FIXES: int l = n;
- }
-};
-
-void test_templates() {
- template_function(1, 42);
- template_function(1.0, 42);
- TemplateStruct<int>().f(1, 42);
- TemplateStruct<double>().f(1.0, 42);
-}
-
-extern "C" {
-void extern_c_code(const char *cpc) {
- const char *cpc2 = (const char*)cpc;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type
- // CHECK-FIXES: const char *cpc2 = cpc;
- char *pc = (char*)cpc;
-}
-}
-
-#define CAST(type, value) (type)(value)
-void macros(double d) {
- int i = CAST(int, d);
-}
-
-enum E { E1 = 1 };
-template <E e>
-struct A {
- // Usage of template argument e = E1 is represented as (E)1 in the AST for
- // some reason. We have a special treatment of this case to avoid warnings
- // here.
- static const E ee = e;
-};
-struct B : public A<E1> {};
-
-
-void overloaded_function();
-void overloaded_function(int);
-
-template<typename Fn>
-void g(Fn fn) {
- fn();
-}
-
-void function_casts() {
- typedef void (*FnPtrVoid)();
- typedef void (&FnRefVoid)();
- typedef void (&FnRefInt)(int);
-
- g((void (*)())overloaded_function);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: g(static_cast<void (*)()>(overloaded_function));
- g((void (*)())&overloaded_function);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: g(static_cast<void (*)()>(&overloaded_function));
- g((void (&)())overloaded_function);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: g(static_cast<void (&)()>(overloaded_function));
-
- g((FnPtrVoid)overloaded_function);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: g(static_cast<FnPtrVoid>(overloaded_function));
- g((FnPtrVoid)&overloaded_function);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: g(static_cast<FnPtrVoid>(&overloaded_function));
- g((FnRefVoid)overloaded_function);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: g(static_cast<FnRefVoid>(overloaded_function));
-
- FnPtrVoid fn0 = (void (*)())&overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: FnPtrVoid fn0 = static_cast<void (*)()>(&overloaded_function);
- FnPtrVoid fn1 = (void (*)())overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: FnPtrVoid fn1 = static_cast<void (*)()>(overloaded_function);
- FnPtrVoid fn1a = (FnPtrVoid)overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: FnPtrVoid fn1a = static_cast<FnPtrVoid>(overloaded_function);
- FnRefInt fn2 = (void (&)(int))overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: FnRefInt fn2 = static_cast<void (&)(int)>(overloaded_function);
- auto fn3 = (void (*)())&overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: auto fn3 = static_cast<void (*)()>(&overloaded_function);
- auto fn4 = (void (*)())overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: auto fn4 = static_cast<void (*)()>(overloaded_function);
- auto fn5 = (void (&)(int))overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: auto fn5 = static_cast<void (&)(int)>(overloaded_function);
-
- void (*fn6)() = (void (*)())&overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: void (*fn6)() = static_cast<void (*)()>(&overloaded_function);
- void (*fn7)() = (void (*)())overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: void (*fn7)() = static_cast<void (*)()>(overloaded_function);
- void (*fn8)() = (FnPtrVoid)overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: void (*fn8)() = static_cast<FnPtrVoid>(overloaded_function);
- void (&fn9)(int) = (void (&)(int))overloaded_function;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: void (&fn9)(int) = static_cast<void (&)(int)>(overloaded_function);
-
- void (*correct1)() = static_cast<void (*)()>(overloaded_function);
- FnPtrVoid correct2 = static_cast<void (*)()>(&overloaded_function);
- FnRefInt correct3 = static_cast<void (&)(int)>(overloaded_function);
-}
-
-struct S {
- S(const char *);
-};
-struct ConvertibleToS {
- operator S() const;
-};
-struct ConvertibleToSRef {
- operator const S&() const;
-};
-
-void conversions() {
- //auto s1 = (const S&)"";
- // C HECK-MESSAGES: :[[@LINE-1]]:10: warning: C-style casts are discouraged; use static_cast [
- // C HECK-FIXES: S s1 = static_cast<const S&>("");
- auto s2 = (S)"";
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use constructor call syntax [
- // CHECK-FIXES: auto s2 = S("");
- auto s2a = (struct S)"";
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [
- // CHECK-FIXES: auto s2a = static_cast<struct S>("");
- auto s2b = (const S)"";
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [
- // FIXME: This should be constructor call syntax: S("").
- // CHECK-FIXES: auto s2b = static_cast<const S>("");
- ConvertibleToS c;
- auto s3 = (const S&)c;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [
- // CHECK-FIXES: auto s3 = (const S&)c;
- // FIXME: This should be a static_cast.
- // C HECK-FIXES: auto s3 = static_cast<const S&>(c);
- auto s4 = (S)c;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use constructor call syntax [
- // CHECK-FIXES: auto s4 = S(c);
- ConvertibleToSRef cr;
- auto s5 = (const S&)cr;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [
- // CHECK-FIXES: auto s5 = (const S&)cr;
- // FIXME: This should be a static_cast.
- // C HECK-FIXES: auto s5 = static_cast<const S&>(cr);
- auto s6 = (S)cr;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use constructor call syntax [
- // CHECK-FIXES: auto s6 = S(cr);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.mm (removed)
@@ -1,179 +0,0 @@
-// RUN: clang-tidy %s -checks=-*,google-readability-casting -- \
-// RUN: -xobjective-c++ -fobjc-abi-version=2 -fobjc-arc | count 0
-
-// Note: this test expects no diagnostics, but FileCheck cannot handle that,
-// hence the use of | count 0.
-
-bool g() { return false; }
-
-enum Enum { Enum1 };
-struct X {};
-struct Y : public X {};
-
-void f(int a, double b, const char *cpc, const void *cpv, X *pX) {
-
- typedef const char *Typedef1;
- typedef const char *Typedef2;
- Typedef1 t1;
- (Typedef2)t1;
- (const char*)t1;
- (Typedef1)cpc;
-
- typedef char Char;
- char *pc;
- Char *pChar = (Char*)pc;
-
- (Char)*cpc;
-
- (char)*pChar;
-
- (const char*)cpv;
-
- char *pc2 = (char*)(cpc + 33);
-
- const char &crc = *cpc;
- char &rc = (char&)crc;
-
- char &rc2 = (char&)*cpc;
-
- char ** const* const* ppcpcpc;
- char ****ppppc = (char****)ppcpcpc;
-
- char ***pppc = (char***)*(ppcpcpc);
-
- char ***pppc2 = (char***)(*ppcpcpc);
-
- char *pc5 = (char*)(const char*)(cpv);
-
- int b1 = (int)b;
- b1 = (const int&)b;
-
- b1 = (int) b;
-
- b1 = (int) b;
-
- b1 = (int) (b);
-
- b1 = (int) (b);
-
- Y *pB = (Y*)pX;
- Y &rB = (Y&)*pX;
-
- const char *pc3 = (const char*)cpv;
-
- char *pc4 = (char*)cpv;
-
- b1 = (int)Enum1;
-
- Enum e = (Enum)b1;
-
- int b2 = int(b);
- int b3 = static_cast<double>(b);
- int b4 = b;
- double aa = a;
- (void)b2;
- return (void)g();
-}
-
-template <typename T>
-void template_function(T t, int n) {
- int i = (int)t;
-}
-
-template <typename T>
-struct TemplateStruct {
- void f(T t, int n) {
- int k = (int)t;
- }
-};
-
-void test_templates() {
- template_function(1, 42);
- template_function(1.0, 42);
- TemplateStruct<int>().f(1, 42);
- TemplateStruct<double>().f(1.0, 42);
-}
-
-extern "C" {
-void extern_c_code(const char *cpc) {
- char *pc = (char*)cpc;
-}
-}
-
-#define CAST(type, value) (type)(value)
-void macros(double d) {
- int i = CAST(int, d);
-}
-
-enum E { E1 = 1 };
-template <E e>
-struct A {
- // Usage of template argument e = E1 is represented as (E)1 in the AST for
- // some reason. We have a special treatment of this case to avoid warnings
- // here.
- static const E ee = e;
-};
-struct B : public A<E1> {};
-
-
-void overloaded_function();
-void overloaded_function(int);
-
-template<typename Fn>
-void g(Fn fn) {
- fn();
-}
-
-void function_casts() {
- typedef void (*FnPtrVoid)();
- typedef void (&FnRefVoid)();
- typedef void (&FnRefInt)(int);
-
- g((void (*)())overloaded_function);
- g((void (*)())&overloaded_function);
- g((void (&)())overloaded_function);
-
- g((FnPtrVoid)overloaded_function);
- g((FnPtrVoid)&overloaded_function);
- g((FnRefVoid)overloaded_function);
-
- FnPtrVoid fn0 = (void (*)())&overloaded_function;
- FnPtrVoid fn1 = (void (*)())overloaded_function;
- FnPtrVoid fn1a = (FnPtrVoid)overloaded_function;
- FnRefInt fn2 = (void (&)(int))overloaded_function;
- auto fn3 = (void (*)())&overloaded_function;
- auto fn4 = (void (*)())overloaded_function;
- auto fn5 = (void (&)(int))overloaded_function;
-
- void (*fn6)() = (void (*)())&overloaded_function;
- void (*fn7)() = (void (*)())overloaded_function;
- void (*fn8)() = (FnPtrVoid)overloaded_function;
- void (&fn9)(int) = (void (&)(int))overloaded_function;
-
- void (*correct1)() = static_cast<void (*)()>(overloaded_function);
- FnPtrVoid correct2 = static_cast<void (*)()>(&overloaded_function);
- FnRefInt correct3 = static_cast<void (&)(int)>(overloaded_function);
-}
-
-struct S {
- S(const char *);
-};
-struct ConvertibleToS {
- operator S() const;
-};
-struct ConvertibleToSRef {
- operator const S&() const;
-};
-
-void conversions() {
- //auto s1 = (const S&)"";
- auto s2 = (S)"";
- auto s2a = (struct S)"";
- auto s2b = (const S)"";
- ConvertibleToS c;
- auto s3 = (const S&)c;
- auto s4 = (S)c;
- ConvertibleToSRef cr;
- auto s5 = (const S&)cr;
- auto s6 = (S)cr;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-namespace-comments.cpp (removed)
@@ -1,54 +0,0 @@
-// RUN: %check_clang_tidy %s google-readability-namespace-comments %t
-
-namespace n1 {
-namespace n2 {
-
-
-void f(); // So that the namespace isn't empty.
-
-
-// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n2' not terminated with a closing comment [google-readability-namespace-comments]
-// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n2' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1' not terminated with
-// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1' starts here
-}}
-// CHECK-FIXES: } // namespace n2
-// CHECK-FIXES: } // namespace n1
-
-#define MACRO macro_expansion
-namespace MACRO {
-void f(); // So that the namespace isn't empty.
-// 1
-// 2
-// 3
-// 4
-// 5
-// 6
-// 7
-// CHECK-MESSAGES: :[[@LINE+2]]:1: warning: namespace 'macro_expansion' not terminated with
-// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'macro_expansion' starts here
-}
-// CHECK-FIXES: } // namespace macro_expansion
-
-namespace short1 {
-namespace short2 {
-// Namespaces covering 10 lines or fewer are exempt from this rule.
-
-
-
-
-
-}
-}
-
-namespace n3 {
-
-
-
-
-
-
-
-
-
-}; // namespace n3
Removed: clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-nested-namespace-comments.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: %check_clang_tidy %s google-readability-namespace-comments %t
-
-namespace n1::n2 {
-namespace n3 {
-
-// So that namespace is not empty.
-void f();
-
-
-// CHECK-MESSAGES: :[[@LINE+4]]:1: warning: namespace 'n3' not terminated with
-// CHECK-MESSAGES: :[[@LINE-7]]:11: note: namespace 'n3' starts here
-// CHECK-MESSAGES: :[[@LINE+2]]:2: warning: namespace 'n1::n2' not terminated with a closing comment [google-readability-namespace-comments]
-// CHECK-MESSAGES: :[[@LINE-10]]:11: note: namespace 'n1::n2' starts here
-}}
-// CHECK-FIXES: } // namespace n3
-// CHECK-FIXES: } // namespace n1::n2
-
Removed: clang-tools-extra/trunk/test/clang-tidy/google-readability-todo.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-todo.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-todo.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-todo.cpp (removed)
@@ -1,26 +0,0 @@
-// RUN: %check_clang_tidy %s google-readability-todo %t -- -config="{User: 'some user'}" --
-
-// TODOfix this1
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
-// CHECK-FIXES: // TODO(some user): fix this1
-
-// TODO fix this2
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
-// CHECK-FIXES: // TODO(some user): fix this2
-
-// TODO fix this3
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
-// CHECK-FIXES: // TODO(some user): fix this3
-
-// TODO: fix this4
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: missing username/bug in TODO
-// CHECK-FIXES: // TODO(some user): fix this4
-
-// TODO(clang)fix this5
-
-// TODO(foo):shave yaks
-// TODO(bar):
-// TODO(foo): paint bikeshed
-// TODO(b/12345): find the holy grail
-// TODO (b/12345): allow spaces before parentheses
-// TODO(asdf) allow missing semicolon
Removed: clang-tools-extra/trunk/test/clang-tidy/google-runtime-int-std.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-int-std.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-int-std.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-int-std.cpp (removed)
@@ -1,57 +0,0 @@
-// RUN: %check_clang_tidy %s google-runtime-int %t -- \
-// RUN: -config='{CheckOptions: [ \
-// RUN: {key: google-runtime-int.UnsignedTypePrefix, value: "std::uint"}, \
-// RUN: {key: google-runtime-int.SignedTypePrefix, value: "std::int"}, \
-// RUN: {key: google-runtime-int.TypeSuffix, value: "_t"}, \
-// RUN: ]}'
-
-long a();
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'long' with 'std::int{{..}}_t'
-
-typedef unsigned long long uint64; // NOLINT
-
-long b(long = 1);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'long' with 'std::int{{..}}_t'
-// CHECK-MESSAGES: [[@LINE-2]]:8: warning: consider replacing 'long' with 'std::int{{..}}_t'
-
-template <typename T>
-void tmpl() {
- T i;
-}
-
-short bar(const short, unsigned short) {
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'short' with 'std::int16_t'
-// CHECK-MESSAGES: [[@LINE-2]]:17: warning: consider replacing 'short' with 'std::int16_t'
-// CHECK-MESSAGES: [[@LINE-3]]:24: warning: consider replacing 'unsigned short' with 'std::uint16_t'
- long double foo = 42;
- uint64 qux = 42;
- unsigned short port;
-
- const unsigned short bar = 0;
-// CHECK-MESSAGES: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'std::uint16_t'
- long long *baar;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'std::int64_t'
- const unsigned short &bara = bar;
-// CHECK-MESSAGES: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'std::uint16_t'
- long const long moo = 1;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'std::int64_t'
- long volatile long wat = 42;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'std::int64_t'
- unsigned long y;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long' with 'std::uint{{..}}_t'
- unsigned long long **const *tmp;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'std::uint64_t'
- unsigned long long **const *&z = tmp;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'std::uint64_t'
- unsigned short porthole;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned short' with 'std::uint16_t'
-
- uint64 cast = (short)42;
-// CHECK-MESSAGES: [[@LINE-1]]:18: warning: consider replacing 'short' with 'std::int16_t'
-
-#define l long
- l x;
-
- tmpl<short>();
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: consider replacing 'short' with 'std::int16_t'
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.c (removed)
@@ -1,27 +0,0 @@
-// RUN: clang-tidy -checks=-*,google-runtime-int %s -- -x c 2>&1 | not grep 'warning:\|error:'
-
-long a();
-
-long b(long x);
-
-short bar(const short q, unsigned short w) {
- long double foo;
- unsigned short port;
-
- const unsigned short bar;
- long long *baar;
- const unsigned short bara;
- long const long moo;
- long volatile long wat;
- unsigned long y;
- unsigned long long **const *tmp;
- unsigned short porthole;
-
- unsigned cast;
- cast = (short)42;
- return q;
-}
-
-void qux() {
- short port;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.cpp (removed)
@@ -1,91 +0,0 @@
-// RUN: %check_clang_tidy %s google-runtime-int %t
-
-long a();
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'long' with 'int{{..}}'
-
-typedef unsigned long long uint64; // NOLINT
-
-long b(long = 1);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'long' with 'int{{..}}'
-// CHECK-MESSAGES: [[@LINE-2]]:8: warning: consider replacing 'long' with 'int{{..}}'
-
-template <typename T>
-void tmpl() {
- T i;
-}
-
-short bar(const short, unsigned short) {
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: consider replacing 'short' with 'int16'
-// CHECK-MESSAGES: [[@LINE-2]]:17: warning: consider replacing 'short' with 'int16'
-// CHECK-MESSAGES: [[@LINE-3]]:24: warning: consider replacing 'unsigned short' with 'uint16'
- long double foo = 42;
- uint64 qux = 42;
- unsigned short port;
-
- const unsigned short bar = 0;
-// CHECK-MESSAGES: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'uint16'
- long long *baar;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64'
- const unsigned short &bara = bar;
-// CHECK-MESSAGES: [[@LINE-1]]:9: warning: consider replacing 'unsigned short' with 'uint16'
- long const long moo = 1;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64'
- long volatile long wat = 42;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'long long' with 'int64'
- unsigned long y;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long' with 'uint{{..}}'
- unsigned long long **const *tmp;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'uint64'
- unsigned long long **const *&z = tmp;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned long long' with 'uint64'
- unsigned short porthole;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'unsigned short' with 'uint16'
-
- uint64 cast = (short)42;
-// CHECK-MESSAGES: [[@LINE-1]]:18: warning: consider replacing 'short' with 'int16'
-
-#define l long
- l x;
-
- tmpl<short>();
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: consider replacing 'short' with 'int16'
- return 0;
-}
-
-void p(unsigned short port);
-
-void qux() {
- short port;
-// CHECK-MESSAGES: [[@LINE-1]]:3: warning: consider replacing 'short' with 'int16'
-}
-
-// FIXME: This shouldn't warn, as UD-literal operators require one of a handful
-// of types as an argument.
-struct some_value {};
-constexpr some_value operator"" _some_literal(unsigned long long int i);
-// CHECK-MESSAGES: [[@LINE-1]]:47: warning: consider replacing 'unsigned long long'
-
-struct A { A& operator=(const A&); };
-class B { A a[0]; };
-
-void fff() {
- B a, b;
- a = b;
-}
-
-__attribute__((__format__ (__printf__, 1, 2)))
-void myprintf(const char* s, ...);
-
-void doprint_no_warning() {
- uint64 foo = 23;
- myprintf("foo %lu %lu", (unsigned long)42, (unsigned long)foo);
-}
-
-void myprintf_no_attribute(const char* s, ...);
-
-void doprint_warning() {
- uint64 foo = 23;
- myprintf_no_attribute("foo %lu %lu", (unsigned long)42, (unsigned long)foo);
-// CHECK-MESSAGES: [[@LINE-1]]:41: warning: consider replacing 'unsigned long'
-// CHECK-MESSAGES: [[@LINE-2]]:60: warning: consider replacing 'unsigned long'
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-int.m (removed)
@@ -1,32 +0,0 @@
-// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- | count 0
-// RUN: clang-tidy -checks=-*,google-runtime-int %s 2>&1 -- -x objective-c++ | count 0
-
-typedef long NSInteger;
-typedef unsigned long NSUInteger;
-
- at interface NSString
- at property(readonly) NSInteger integerValue;
- at property(readonly) long long longLongValue;
- at property(readonly) NSUInteger length;
- at end
-
-NSInteger Foo(NSString *s) {
- return [s integerValue];
-}
-
-long long Bar(NSString *s) {
- return [s longLongValue];
-}
-
-NSUInteger Baz(NSString *s) {
- return [s length];
-}
-
-unsigned short NSSwapShort(unsigned short inv);
-
-long DoSomeMath(long a, short b) {
- short c = NSSwapShort(b);
- long a2 = a * 5L;
- return a2 + c;
-}
-
Removed: clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-runtime-references.cpp (removed)
@@ -1,155 +0,0 @@
-// RUN: %check_clang_tidy %s google-runtime-references %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: google-runtime-references.WhiteListTypes, \
-// RUN: value: 'whitelist::A; whitelist::B'}]}"
-
-int a;
-int &b = a;
-int *c;
-void f1(int a);
-void f2(int *b);
-void f3(const int &c);
-void f4(int const &d);
-
-// Don't warn on implicit operator= in c++11 mode.
-class A {
- virtual void f() {}
-};
-// Don't warn on rvalue-references.
-struct A2 {
- A2(A2&&) = default;
- void f(A2&&) {}
-};
-
-// Don't warn on iostream parameters.
-namespace xxx {
-class istream { };
-class ostringstream { };
-}
-void g1(xxx::istream &istr);
-void g1(xxx::ostringstream &istr);
-
-void g1(int &a);
-// CHECK-MESSAGES: [[@LINE-1]]:14: warning: non-const reference parameter 'a', make it const or use a pointer [google-runtime-references]
-
-struct s {};
-void g2(int a, int b, s c, s &d);
-// CHECK-MESSAGES: [[@LINE-1]]:31: warning: non-const reference parameter 'd', {{.*}}
-
-typedef int &ref;
-void g3(ref a);
-// CHECK-MESSAGES: [[@LINE-1]]:13: warning: non-const reference {{.*}}
-
-void g4(int &a, int &b, int &);
-// CHECK-MESSAGES: [[@LINE-1]]:14: warning: non-const reference parameter 'a', {{.*}}
-// CHECK-MESSAGES: [[@LINE-2]]:22: warning: non-const reference parameter 'b', {{.*}}
-// CHECK-MESSAGES: [[@LINE-3]]:30: warning: non-const reference parameter at index 2, {{.*}}
-
-class B {
- B(B& a) {}
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: non-const reference {{.*}}
- virtual void f(int &a) {}
-// CHECK-MESSAGES: [[@LINE-1]]:23: warning: non-const reference {{.*}}
- void g(int &b);
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: non-const reference {{.*}}
-
- // Don't warn on the parameter of stream extractors defined as members.
- B& operator>>(int& val) { return *this; }
-};
-
-// Only warn on the first declaration of each function to reduce duplicate
-// warnings.
-void B::g(int &b) {}
-
-// Don't warn on the first parameter of stream inserters.
-A& operator<<(A& s, int&) { return s; }
-// CHECK-MESSAGES: [[@LINE-1]]:25: warning: non-const reference parameter at index 1, {{.*}}
-
-// Don't warn on either parameter of stream extractors. Both need to be
-// non-const references by convention.
-A& operator>>(A& input, int& val) { return input; }
-
-// Don't warn on lambdas.
-auto lambda = [] (int&) {};
-
-// Don't warn on typedefs, as we'll warn on the function itself.
-typedef int (*fp)(int &);
-
-// Don't warn on function references.
-typedef void F();
-void g5(const F& func) {}
-void g6(F& func) {}
-
-template<typename T>
-void g7(const T& t) {}
-
-template<typename T>
-void g8(T t) {}
-
-void f5() {
- g5(f5);
- g6(f5);
- g7(f5);
- g7<F&>(f5);
- g8(f5);
- g8<F&>(f5);
-}
-
-// Don't warn on dependent types.
-template<typename T>
-void g9(T& t) {}
-template<typename T>
-void g10(T t) {}
-
-void f6() {
- int i;
- float f;
- g9<int>(i);
- g9<const int>(i);
- g9<int&>(i);
- g10<int&>(i);
- g10<float&>(f);
-}
-
-// Warn only on the overridden methods from the base class, as the child class
-// only implements the interface.
-class C : public B {
- C();
- virtual void f(int &a) {}
-};
-
-// Don't warn on operator<< with streams-like interface.
-A& operator<<(A& s, int) { return s; }
-
-// Don't warn on swap().
-void swap(C& c1, C& c2) {}
-
-// Don't warn on standalone operator++, operator--, operator+=, operator-=,
-// operator*=, etc. that all need non-const references to be functional.
-A& operator++(A& a) { return a; }
-A operator++(A& a, int) { return a; }
-A& operator--(A& a) { return a; }
-A operator--(A& a, int) { return a; }
-A& operator+=(A& a, const A& b) { return a; }
-A& operator-=(A& a, const A& b) { return a; }
-A& operator*=(A& a, const A& b) { return a; }
-A& operator/=(A& a, const A& b) { return a; }
-A& operator%=(A& a, const A& b) { return a; }
-A& operator<<=(A& a, const A& b) { return a; }
-A& operator>>=(A& a, const A& b) { return a; }
-A& operator|=(A& a, const A& b) { return a; }
-A& operator^=(A& a, const A& b) { return a; }
-A& operator&=(A& a, const A& b) { return a; }
-
-namespace whitelist {
-class A {};
-class B {};
-void f7(A &);
-void f8(B &);
-}
-void f9(whitelist::A &);
-void f10(whitelist::B &);
-
-#define DEFINE_F(name) void name(int& a)
-
-DEFINE_F(func) {}
Removed: clang-tools-extra/trunk/test/clang-tidy/google-upgrade-googletest-case.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-upgrade-googletest-case.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/google-upgrade-googletest-case.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-upgrade-googletest-case.cpp (removed)
@@ -1,1016 +0,0 @@
-// RUN: %check_clang_tidy %s google-upgrade-googletest-case %t -- -- -I%S/Inputs
-// RUN: %check_clang_tidy -check-suffix=NOSUITE %s google-upgrade-googletest-case %t -- -- -DNOSUITE -I%S/Inputs/gtest/nosuite
-
-#include "gtest/gtest.h"
-
-// When including a version of googletest without the replacement names, this
-// check should not produce any diagnostics. The following dummy fix is present
-// because `check_clang_tidy.py` requires at least one warning, fix or note.
-void Dummy() {}
-// CHECK-FIXES-NOSUITE: void Dummy() {}
-
-// ----------------------------------------------------------------------------
-// Macros
-
-TYPED_TEST_CASE(FooTest, FooTypes);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case' are deprecated; use equivalent APIs named with 'suite'
-// CHECK-FIXES: TYPED_TEST_SUITE(FooTest, FooTypes);
-TYPED_TEST_CASE_P(FooTest);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: TYPED_TEST_SUITE_P(FooTest);
-REGISTER_TYPED_TEST_CASE_P(FooTest, FooTestName);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: REGISTER_TYPED_TEST_SUITE_P(FooTest, FooTestName);
-INSTANTIATE_TYPED_TEST_CASE_P(FooPrefix, FooTest, FooTypes);
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: INSTANTIATE_TYPED_TEST_SUITE_P(FooPrefix, FooTest, FooTypes);
-
-#ifdef TYPED_TEST_CASE
-// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
-#undef TYPED_TEST_CASE
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
-#define TYPED_TEST_CASE(CaseName, Types, ...)
-#endif
-
-#ifdef TYPED_TEST_CASE_P
-// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
-#undef TYPED_TEST_CASE_P
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
-#define TYPED_TEST_CASE_P(SuiteName)
-#endif
-
-#ifdef REGISTER_TYPED_TEST_CASE_P
-// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
-#undef REGISTER_TYPED_TEST_CASE_P
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
-#define REGISTER_TYPED_TEST_CASE_P(SuiteName, ...)
-#endif
-
-#ifdef INSTANTIATE_TYPED_TEST_CASE_P
-// CHECK-MESSAGES: [[@LINE-1]]:2: warning: Google Test APIs named with 'case'
-#undef INSTANTIATE_TYPED_TEST_CASE_P
-// CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
-#define INSTANTIATE_TYPED_TEST_CASE_P(Prefix, SuiteName, Types, ...)
-#endif
-
-TYPED_TEST_CASE(FooTest, FooTypes);
-TYPED_TEST_CASE_P(FooTest);
-REGISTER_TYPED_TEST_CASE_P(FooTest, FooTestName);
-INSTANTIATE_TYPED_TEST_CASE_P(FooPrefix, FooTest, FooTypes);
-
-// ----------------------------------------------------------------------------
-// testing::Test
-
-class FooTest : public testing::Test {
-public:
- static void SetUpTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: static void SetUpTestSuite();
- static void TearDownTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: static void TearDownTestSuite();
-};
-
-void FooTest::SetUpTestCase() {}
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: void FooTest::SetUpTestSuite() {}
-
-void FooTest::TearDownTestCase() {}
-// CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: void FooTest::TearDownTestSuite() {}
-
-template <typename T> class FooTypedTest : public testing::Test {
-public:
- static void SetUpTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: static void SetUpTestSuite();
- static void TearDownTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: static void TearDownTestSuite();
-};
-
-template <typename T> void FooTypedTest<T>::SetUpTestCase() {}
-// CHECK-MESSAGES: [[@LINE-1]]:45: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: void FooTypedTest<T>::SetUpTestSuite() {}
-
-template <typename T> void FooTypedTest<T>::TearDownTestCase() {}
-// CHECK-MESSAGES: [[@LINE-1]]:45: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: void FooTypedTest<T>::TearDownTestSuite() {}
-
-class BarTest : public testing::Test {
-public:
- using Test::SetUpTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using Test::SetUpTestSuite;
- using Test::TearDownTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using Test::TearDownTestSuite;
-};
-
-class BarTest2 : public FooTest {
-public:
- using FooTest::SetUpTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using FooTest::SetUpTestSuite;
- using FooTest::TearDownTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using FooTest::TearDownTestSuite;
-};
-
-// If a derived type already has the replacements, we only provide a warning
-// since renaming or deleting the old declarations may not be safe.
-class BarTest3 : public testing::Test {
- public:
- static void SetUpTestCase() {}
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- static void SetUpTestSuite() {}
-
- static void TearDownTestCase() {}
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- static void TearDownTestSuite() {}
-};
-
-namespace nesting_ns {
-namespace testing {
-
-class Test {
-public:
- static void SetUpTestCase();
- static void TearDownTestCase();
-};
-
-} // namespace testing
-
-void Test() {
- testing::Test::SetUpTestCase();
- testing::Test::TearDownTestCase();
-}
-
-} // namespace nesting_ns
-
-template <typename T>
-void testInstantiationOnlyWarns() {
- T::SetUpTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Google Test APIs named with 'case'
- T::TearDownTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:6: warning: Google Test APIs named with 'case'
-}
-
-#define SET_UP_TEST_CASE_MACRO_REPLACE SetUpTestCase
-#define TEST_SET_UP_TEST_CASE_MACRO_WARN_ONLY ::testing::Test::SetUpTestCase
-
-void setUpTearDownCallAndReference() {
- testing::Test::SetUpTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::Test::SetUpTestSuite();
- FooTest::SetUpTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: FooTest::SetUpTestSuite();
-
- testing::Test::TearDownTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::Test::TearDownTestSuite();
- FooTest::TearDownTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: FooTest::TearDownTestSuite();
-
- auto F = &testing::Test::SetUpTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F = &testing::Test::SetUpTestSuite;
- F = &testing::Test::TearDownTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: F = &testing::Test::TearDownTestSuite;
- F = &FooTest::SetUpTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: F = &FooTest::SetUpTestSuite;
- F = &FooTest::TearDownTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:17: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: F = &FooTest::TearDownTestSuite;
-
- using MyTest = testing::Test;
- MyTest::SetUpTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: MyTest::SetUpTestSuite();
- MyTest::TearDownTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: MyTest::TearDownTestSuite();
-
- BarTest3::SetUpTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: BarTest3::SetUpTestSuite();
- BarTest3::TearDownTestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: BarTest3::TearDownTestSuite();
-
- testInstantiationOnlyWarns<testing::Test>();
-
- testing::Test::SET_UP_TEST_CASE_MACRO_REPLACE();
- // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::Test::SetUpTestSuite();
- TEST_SET_UP_TEST_CASE_MACRO_WARN_ONLY();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
-}
-
-// ----------------------------------------------------------------------------
-// testing::TestInfo
-
-class FooTestInfo : public testing::TestInfo {
-public:
- const char *test_case_name() const;
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const char *test_suite_name() const;
-};
-
-const char *FooTestInfo::test_case_name() const {}
-// CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: const char *FooTestInfo::test_suite_name() const {}
-
-class BarTestInfo : public testing::TestInfo {
-public:
- using TestInfo::test_case_name;
- // CHECK-MESSAGES: [[@LINE-1]]:19: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using TestInfo::test_suite_name;
-};
-
-class BarTestInfo2 : public FooTestInfo {
-public:
- using FooTestInfo::test_case_name;
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using FooTestInfo::test_suite_name;
-};
-
-class BarTestInfo3 : public testing::TestInfo {
- public:
- const char* test_case_name() const;
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: Google Test APIs named with 'case'
- const char* test_suite_name() const;
-};
-
-namespace nesting_ns {
-namespace testing {
-
-class TestInfo {
-public:
- const char *test_case_name() const;
-};
-
-} // namespace testing
-
-void FuncInfo() {
- testing::TestInfo t;
- (void)t.test_case_name();
-}
-
-} // namespace nesting_ns
-
-template <typename T>
-void testInfoInstantiationOnlyWarns() {
- T t;
- (void)t.test_case_name();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
-}
-
-#define TEST_CASE_NAME_MACRO_REPLACE test_case_name
-#define TEST_CASE_NAME_MACRO_WARN_ONLY testing::TestInfo().test_case_name
-
-void testInfoCallAndReference() {
- (void)testing::TestInfo().test_case_name();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::TestInfo().test_suite_name();
- (void)FooTestInfo().test_case_name();
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)FooTestInfo().test_suite_name();
- auto F1 = &testing::TestInfo::test_case_name;
- // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F1 = &testing::TestInfo::test_suite_name;
- auto F2 = &FooTestInfo::test_case_name;
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F2 = &FooTestInfo::test_suite_name;
- using MyTestInfo = testing::TestInfo;
- (void)MyTestInfo().test_case_name();
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)MyTestInfo().test_suite_name();
- (void)BarTestInfo3().test_case_name();
- // CHECK-MESSAGES: [[@LINE-1]]:24: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)BarTestInfo3().test_suite_name();
-
- testInfoInstantiationOnlyWarns<testing::TestInfo>();
-
- (void)testing::TestInfo().TEST_CASE_NAME_MACRO_REPLACE();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::TestInfo().test_suite_name();
- (void)TEST_CASE_NAME_MACRO_WARN_ONLY();
- // CHECK-MESSAGES: [[@LINE-1]]:9: warning: Google Test APIs named with 'case'
-}
-
-// ----------------------------------------------------------------------------
-// testing::TestEventListener
-
-class FooTestEventListener : public testing::TestEventListener {
-public:
- void OnTestCaseStart(const testing::TestCase &) override;
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
- // CHECK-MESSAGES: [[@LINE-2]]:39: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: void OnTestSuiteStart(const testing::TestSuite &) override;
- void OnTestCaseEnd(const testing::TestCase &) override;
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
- // CHECK-MESSAGES: [[@LINE-2]]:37: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: void OnTestSuiteEnd(const testing::TestSuite &) override;
-};
-
-void FooTestEventListener::OnTestCaseStart(const testing::TestCase &) {}
-// CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
-// CHECK-MESSAGES: [[@LINE-2]]:59: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: void FooTestEventListener::OnTestSuiteStart(const testing::TestSuite &) {}
-
-void FooTestEventListener::OnTestCaseEnd(const testing::TestCase &) {}
-// CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
-// CHECK-MESSAGES: [[@LINE-2]]:57: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: void FooTestEventListener::OnTestSuiteEnd(const testing::TestSuite &) {}
-
-class BarTestEventListener : public testing::TestEventListener {
-public:
- using TestEventListener::OnTestCaseStart;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using TestEventListener::OnTestSuiteStart;
- using TestEventListener::OnTestCaseEnd;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using TestEventListener::OnTestSuiteEnd;
-};
-
-class BarTestEventListener2 : public BarTestEventListener {
-public:
- using BarTestEventListener::OnTestCaseStart;
- // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarTestEventListener::OnTestSuiteStart;
- using BarTestEventListener::OnTestCaseEnd;
- // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarTestEventListener::OnTestSuiteEnd;
-};
-
-#ifndef NOSUITE
-
-class BarTestEventListener3 : public testing::TestEventListener {
-public:
- void OnTestCaseStart(const testing::TestSuite &) override;
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
- void OnTestSuiteStart(const testing::TestSuite &) override;
-
- void OnTestCaseEnd(const testing::TestSuite &) override;
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: Google Test APIs named with 'case'
- void OnTestSuiteEnd(const testing::TestSuite &) override;
-};
-
-#endif
-
-namespace nesting_ns {
-namespace testing {
-
-class TestEventListener {
-public:
- virtual void OnTestCaseStart(const ::testing::TestCase &);
- // CHECK-MESSAGES: [[@LINE-1]]:49: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: virtual void OnTestCaseStart(const ::testing::TestSuite &);
- virtual void OnTestCaseEnd(const ::testing::TestCase &);
- // CHECK-MESSAGES: [[@LINE-1]]:47: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: virtual void OnTestCaseEnd(const ::testing::TestSuite &);
-};
-
-} // namespace testing
-
-void FuncTestEventListener(::testing::TestCase &Case) {
- // CHECK-MESSAGES: [[@LINE-1]]:39: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: void FuncTestEventListener(::testing::TestSuite &Case) {
- testing::TestEventListener().OnTestCaseStart(Case);
- testing::TestEventListener().OnTestCaseEnd(Case);
-}
-
-} // namespace nesting_ns
-
-#ifndef NOSUITE
-
-template <typename T>
-void testEventListenerInstantiationOnlyWarns() {
- T().OnTestCaseStart(testing::TestSuite());
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- T().OnTestCaseEnd(testing::TestSuite());
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
-}
-
-#endif
-
-#define ON_TEST_CASE_START_MACRO_REPLACE OnTestCaseStart
-#define ON_TEST_CASE_START_MACRO_WARN_ONLY \
- testing::TestEventListener().OnTestCaseStart
-
-#define ON_TEST_CASE_END_MACRO_REPLACE OnTestCaseEnd
-#define ON_TEST_CASE_END_MACRO_WARN_ONLY \
- testing::TestEventListener().OnTestCaseEnd
-
-void testEventListenerCallAndReference(testing::TestCase &Case) {
- // CHECK-MESSAGES: [[@LINE-1]]:49: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: void testEventListenerCallAndReference(testing::TestSuite &Case) {
- testing::TestEventListener().OnTestCaseStart(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestEventListener().OnTestSuiteStart(Case);
- testing::TestEventListener().OnTestCaseEnd(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestEventListener().OnTestSuiteEnd(Case);
-
- FooTestEventListener().OnTestCaseStart(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: FooTestEventListener().OnTestSuiteStart(Case);
- FooTestEventListener().OnTestCaseEnd(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: FooTestEventListener().OnTestSuiteEnd(Case);
-
- auto F1 = &testing::TestEventListener::OnTestCaseStart;
- // CHECK-MESSAGES: [[@LINE-1]]:42: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F1 = &testing::TestEventListener::OnTestSuiteStart;
- F1 = &testing::TestEventListener::OnTestCaseEnd;
- // CHECK-MESSAGES: [[@LINE-1]]:37: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: F1 = &testing::TestEventListener::OnTestSuiteEnd;
-
- auto F2 = &FooTestEventListener::OnTestCaseStart;
- // CHECK-MESSAGES: [[@LINE-1]]:36: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F2 = &FooTestEventListener::OnTestSuiteStart;
- F2 = &FooTestEventListener::OnTestCaseEnd;
- // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: F2 = &FooTestEventListener::OnTestSuiteEnd;
-
-#ifndef NOSUITE
-
- BarTestEventListener3().OnTestCaseStart(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: BarTestEventListener3().OnTestSuiteStart(Case);
- BarTestEventListener3().OnTestCaseEnd(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: BarTestEventListener3().OnTestSuiteEnd(Case);
-
- testEventListenerInstantiationOnlyWarns<testing::TestEventListener>();
-
-#endif
-
- testing::TestEventListener().ON_TEST_CASE_START_MACRO_REPLACE(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestEventListener().OnTestSuiteStart(Case);
- ON_TEST_CASE_START_MACRO_WARN_ONLY(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
-
- testing::TestEventListener().ON_TEST_CASE_END_MACRO_REPLACE(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestEventListener().OnTestSuiteEnd(Case);
- ON_TEST_CASE_END_MACRO_WARN_ONLY(Case);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
-}
-
-// ----------------------------------------------------------------------------
-// testing::UnitTest
-
-class FooUnitTest : public testing::UnitTest {
-public:
- testing::TestCase *current_test_case() const;
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
- // CHECK-MESSAGES: [[@LINE-2]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestSuite *current_test_suite() const;
- int successful_test_case_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: int successful_test_suite_count() const;
- int failed_test_case_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: int failed_test_suite_count() const;
- int total_test_case_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: int total_test_suite_count() const;
- int test_case_to_run_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: int test_suite_to_run_count() const;
- const testing::TestCase *GetTestCase(int) const;
- // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
- // CHECK-MESSAGES: [[@LINE-2]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const testing::TestSuite *GetTestSuite(int) const;
-};
-
-testing::TestCase *FooUnitTest::current_test_case() const {}
-// CHECK-MESSAGES: [[@LINE-1]]:10: warning: Google Test APIs named with 'case'
-// CHECK-MESSAGES: [[@LINE-2]]:33: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: testing::TestSuite *FooUnitTest::current_test_suite() const {}
-int FooUnitTest::successful_test_case_count() const {}
-// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: int FooUnitTest::successful_test_suite_count() const {}
-int FooUnitTest::failed_test_case_count() const {}
-// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: int FooUnitTest::failed_test_suite_count() const {}
-int FooUnitTest::total_test_case_count() const {}
-// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: int FooUnitTest::total_test_suite_count() const {}
-int FooUnitTest::test_case_to_run_count() const {}
-// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: int FooUnitTest::test_suite_to_run_count() const {}
-const testing::TestCase *FooUnitTest::GetTestCase(int) const {}
-// CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'
-// CHECK-MESSAGES: [[@LINE-2]]:39: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: const testing::TestSuite *FooUnitTest::GetTestSuite(int) const {}
-
-// Type derived from testing::TestCase
-class BarUnitTest : public testing::UnitTest {
-public:
- using testing::UnitTest::current_test_case;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using testing::UnitTest::current_test_suite;
- using testing::UnitTest::successful_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using testing::UnitTest::successful_test_suite_count;
- using testing::UnitTest::failed_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using testing::UnitTest::failed_test_suite_count;
- using testing::UnitTest::total_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using testing::UnitTest::total_test_suite_count;
- using testing::UnitTest::test_case_to_run_count;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using testing::UnitTest::test_suite_to_run_count;
- using testing::UnitTest::GetTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using testing::UnitTest::GetTestSuite;
-};
-
-class BarUnitTest2 : public BarUnitTest {
- using BarUnitTest::current_test_case;
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarUnitTest::current_test_suite;
- using BarUnitTest::successful_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarUnitTest::successful_test_suite_count;
- using BarUnitTest::failed_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarUnitTest::failed_test_suite_count;
- using BarUnitTest::total_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarUnitTest::total_test_suite_count;
- using BarUnitTest::test_case_to_run_count;
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarUnitTest::test_suite_to_run_count;
- using BarUnitTest::GetTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: using BarUnitTest::GetTestSuite;
-};
-
-#ifndef NOSUITE
-
-class BarUnitTest3 : public testing::UnitTest {
- testing::TestSuite *current_test_case() const;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- int successful_test_case_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- int failed_test_case_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- int total_test_case_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- int test_case_to_run_count() const;
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- const testing::TestSuite *GetTestCase(int) const;
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
-
- testing::TestSuite *current_test_suite() const;
- int successful_test_suite_count() const;
- int failed_test_suite_count() const;
- int total_test_suite_count() const;
- int test_suite_to_run_count() const;
- const testing::TestSuite *GetTestSuite(int) const;
-};
-
-#endif
-
-namespace nesting_ns {
-namespace testing {
-
-class TestSuite;
-
-class UnitTest {
-public:
- TestSuite *current_test_case() const;
- int successful_test_case_count() const;
- int failed_test_case_count() const;
- int total_test_case_count() const;
- int test_case_to_run_count() const;
- const TestSuite *GetTestCase(int) const;
-};
-
-} // namespace testing
-
-void FuncUnitTest() {
- testing::UnitTest t;
- (void)t.current_test_case();
- (void)t.successful_test_case_count();
- (void)t.failed_test_case_count();
- (void)t.total_test_case_count();
- (void)t.test_case_to_run_count();
- (void)t.GetTestCase(0);
-}
-
-} // namespace nesting_ns
-
-template <typename T>
-void unitTestInstantiationOnlyWarns() {
- T t;
- (void)t.current_test_case();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
- (void)t.successful_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
- (void)t.failed_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
- (void)t.total_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
- (void)t.test_case_to_run_count();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
- (void)t.GetTestCase(0);
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
-}
-
-#define UNIT_TEST_NAME_MACRO_REPLACE1 current_test_case
-#define UNIT_TEST_NAME_MACRO_REPLACE2 successful_test_case_count
-#define UNIT_TEST_NAME_MACRO_REPLACE3 failed_test_case_count
-#define UNIT_TEST_NAME_MACRO_REPLACE4 total_test_case_count
-#define UNIT_TEST_NAME_MACRO_REPLACE5 test_case_to_run_count
-#define UNIT_TEST_NAME_MACRO_REPLACE6 GetTestCase
-#define UNIT_TEST_NAME_MACRO_WARN_ONLY1 testing::UnitTest().current_test_case
-#define UNIT_TEST_NAME_MACRO_WARN_ONLY2 \
- testing::UnitTest().successful_test_case_count
-#define UNIT_TEST_NAME_MACRO_WARN_ONLY3 \
- testing::UnitTest().failed_test_case_count
-#define UNIT_TEST_NAME_MACRO_WARN_ONLY4 \
- testing::UnitTest().total_test_case_count
-#define UNIT_TEST_NAME_MACRO_WARN_ONLY5 \
- testing::UnitTest().test_case_to_run_count
-#define UNIT_TEST_NAME_MACRO_WARN_ONLY6 testing::UnitTest().GetTestCase
-
-void unitTestCallAndReference() {
- (void)testing::UnitTest().current_test_case();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().current_test_suite();
- (void)testing::UnitTest().successful_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().successful_test_suite_count();
- (void)testing::UnitTest().failed_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().failed_test_suite_count();
- (void)testing::UnitTest().total_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().total_test_suite_count();
- (void)testing::UnitTest().test_case_to_run_count();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().test_suite_to_run_count();
- (void)testing::UnitTest().GetTestCase(0);
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().GetTestSuite(0);
-
- (void)FooUnitTest().current_test_case();
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)FooUnitTest().current_test_suite();
- (void)FooUnitTest().successful_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)FooUnitTest().successful_test_suite_count();
- (void)FooUnitTest().failed_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)FooUnitTest().failed_test_suite_count();
- (void)FooUnitTest().total_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)FooUnitTest().total_test_suite_count();
- (void)FooUnitTest().test_case_to_run_count();
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)FooUnitTest().test_suite_to_run_count();
- (void)FooUnitTest().GetTestCase(0);
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)FooUnitTest().GetTestSuite(0);
-
- auto U1 = &testing::UnitTest::current_test_case;
- // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto U1 = &testing::UnitTest::current_test_suite;
- auto U2 = &testing::UnitTest::successful_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto U2 = &testing::UnitTest::successful_test_suite_count;
- auto U3 = &testing::UnitTest::failed_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto U3 = &testing::UnitTest::failed_test_suite_count;
- auto U4 = &testing::UnitTest::total_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto U4 = &testing::UnitTest::total_test_suite_count;
- auto U5 = &testing::UnitTest::test_case_to_run_count;
- // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto U5 = &testing::UnitTest::test_suite_to_run_count;
- auto U6 = &testing::UnitTest::GetTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto U6 = &testing::UnitTest::GetTestSuite;
-
- auto F1 = &FooUnitTest::current_test_case;
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F1 = &FooUnitTest::current_test_suite;
- auto F2 = &FooUnitTest::successful_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F2 = &FooUnitTest::successful_test_suite_count;
- auto F3 = &FooUnitTest::failed_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F3 = &FooUnitTest::failed_test_suite_count;
- auto F4 = &FooUnitTest::total_test_case_count;
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F4 = &FooUnitTest::total_test_suite_count;
- auto F5 = &FooUnitTest::test_case_to_run_count;
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F5 = &FooUnitTest::test_suite_to_run_count;
- auto F6 = &FooUnitTest::GetTestCase;
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: auto F6 = &FooUnitTest::GetTestSuite;
-
- using MyUnitTest = testing::UnitTest;
- (void)MyUnitTest().current_test_case();
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)MyUnitTest().current_test_suite();
- (void)MyUnitTest().successful_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)MyUnitTest().successful_test_suite_count();
- (void)MyUnitTest().failed_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)MyUnitTest().failed_test_suite_count();
- (void)MyUnitTest().total_test_case_count();
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)MyUnitTest().total_test_suite_count();
- (void)MyUnitTest().test_case_to_run_count();
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)MyUnitTest().test_suite_to_run_count();
- (void)MyUnitTest().GetTestCase(0);
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)MyUnitTest().GetTestSuite(0);
-
- unitTestInstantiationOnlyWarns<testing::UnitTest>();
-
- (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE1();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().current_test_suite();
- (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE2();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().successful_test_suite_count();
- (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE3();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().failed_test_suite_count();
- (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE4();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().total_test_suite_count();
- (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE5();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().test_suite_to_run_count();
- (void)testing::UnitTest().UNIT_TEST_NAME_MACRO_REPLACE6(0);
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)testing::UnitTest().GetTestSuite(0);
-
- UNIT_TEST_NAME_MACRO_WARN_ONLY1();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
- UNIT_TEST_NAME_MACRO_WARN_ONLY2();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
- UNIT_TEST_NAME_MACRO_WARN_ONLY3();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
- UNIT_TEST_NAME_MACRO_WARN_ONLY4();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
- UNIT_TEST_NAME_MACRO_WARN_ONLY5();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
- UNIT_TEST_NAME_MACRO_WARN_ONLY6(0);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
-}
-
-// ----------------------------------------------------------------------------
-// testing::TestCase
-
-template <typename T>
-void TestCaseInTemplate() {
- T t;
-
- testing::TestCase Case;
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestSuite Case;
-}
-
-#define TEST_CASE_CAN_FIX TestCase
-#define TEST_CASE_WARN_ONLY testing::TestCase
-
-const testing::TestCase *testCaseUses(const testing::TestCase &Case) {
- // CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'
- // CHECK-MESSAGES: [[@LINE-2]]:54: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const testing::TestSuite *testCaseUses(const testing::TestSuite &Case) {
-
- // No change for implicit declarations:
- auto Lambda = [&Case]() {};
-
- TestCaseInTemplate<testing::TestCase>();
- // CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: TestCaseInTemplate<testing::TestSuite>();
-
- testing::TEST_CASE_CAN_FIX C1;
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestSuite C1;
- TEST_CASE_WARN_ONLY C2;
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
-
- (void)new testing::TestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)new testing::TestSuite();
- const testing::TestCase *Result = &Case;
- // CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const testing::TestSuite *Result = &Case;
- return Result;
-}
-
-struct TestCaseHolder {
- testing::TestCase Case;
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: testing::TestSuite Case;
-};
-
-class MyTest : public testing::TestCase {};
-// CHECK-MESSAGES: [[@LINE-1]]:32: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: class MyTest : public testing::TestSuite {};
-
-template <typename T = testing::TestCase>
-// CHECK-MESSAGES: [[@LINE-1]]:33: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: template <typename T = testing::TestSuite>
-class TestTypeHolder {};
-
-template <>
-class TestTypeHolder<testing::TestCase> {};
-// CHECK-MESSAGES: [[@LINE-1]]:31: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: class TestTypeHolder<testing::TestSuite> {};
-
-namespace shadow_using_ns {
-
-using testing::TestCase;
-// CHECK-MESSAGES: [[@LINE-1]]:16: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: using testing::TestSuite;
-
-const TestCase *testCaseUses(const TestCase &Case) {
- // CHECK-MESSAGES: [[@LINE-1]]:7: warning: Google Test APIs named with 'case'
- // CHECK-MESSAGES: [[@LINE-2]]:36: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const TestSuite *testCaseUses(const TestSuite &Case) {
-
- // No change for implicit declarations:
- auto Lambda = [&Case]() {};
-
- (void)new TestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)new TestSuite();
- const TestCase *Result = &Case;
- // CHECK-MESSAGES: [[@LINE-1]]:9: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const TestSuite *Result = &Case;
- return Result;
-}
-
-struct TestCaseHolder {
- TestCase Case;
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: TestSuite Case;
-};
-
-class MyTest : public TestCase {};
-// CHECK-MESSAGES: [[@LINE-1]]:23: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: class MyTest : public TestSuite {};
-
-template <typename T = TestCase>
-// CHECK-MESSAGES: [[@LINE-1]]:24: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: template <typename T = TestSuite>
-class TestTypeHolder {};
-
-template <>
-class TestTypeHolder<TestCase> {};
-// CHECK-MESSAGES: [[@LINE-1]]:22: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: class TestTypeHolder<TestSuite> {};
-
-} // namespace shadow_using_ns
-
-const shadow_using_ns::TestCase *shadowTestCaseUses(
- const shadow_using_ns::TestCase &Case) {
- // CHECK-MESSAGES: [[@LINE-2]]:24: warning: Google Test APIs named with 'case'
- // CHECK-MESSAGES: [[@LINE-2]]:28: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const shadow_using_ns::TestSuite *shadowTestCaseUses(
- // CHECK-FIXES: const shadow_using_ns::TestSuite &Case) {
-
- // No match for implicit declarations, as in the lambda capture:
- auto Lambda = [&Case]() {};
-
- (void)new shadow_using_ns::TestCase();
- // CHECK-MESSAGES: [[@LINE-1]]:30: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: (void)new shadow_using_ns::TestSuite();
- const shadow_using_ns::TestCase *Result = &Case;
- // CHECK-MESSAGES: [[@LINE-1]]:26: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: const shadow_using_ns::TestSuite *Result = &Case;
- return Result;
-}
-
-struct ShadowTestCaseHolder {
- shadow_using_ns::TestCase Case;
- // CHECK-MESSAGES: [[@LINE-1]]:20: warning: Google Test APIs named with 'case'
- // CHECK-FIXES: shadow_using_ns::TestSuite Case;
-};
-
-class ShadowMyTest : public shadow_using_ns::TestCase {};
-// CHECK-MESSAGES: [[@LINE-1]]:46: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: class ShadowMyTest : public shadow_using_ns::TestSuite {};
-
-template <typename T = shadow_using_ns::TestCase>
-// CHECK-MESSAGES: [[@LINE-1]]:41: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: template <typename T = shadow_using_ns::TestSuite>
-class ShadowTestTypeHolder {};
-
-template <>
-class ShadowTestTypeHolder<shadow_using_ns::TestCase> {};
-// CHECK-MESSAGES: [[@LINE-1]]:45: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: class ShadowTestTypeHolder<shadow_using_ns::TestSuite> {};
-
-namespace typedef_ns {
-
-typedef testing::TestCase MyTestCase;
-// CHECK-MESSAGES: [[@LINE-1]]:18: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: typedef testing::TestSuite MyTestCase;
-
-const MyTestCase *testCaseUses(const MyTestCase &Case) {
- auto Lambda = [&Case]() {};
- (void)new MyTestCase();
- const MyTestCase *Result = &Case;
- return Result;
-}
-
-struct TestCaseHolder {
- MyTestCase Case;
-};
-
-class MyTest : public MyTestCase {};
-
-template <typename T = MyTestCase>
-class TestTypeHolder {};
-
-template <>
-class TestTypeHolder<MyTestCase> {};
-
-} // namespace typedef_ns
-
-const typedef_ns::MyTestCase *typedefTestCaseUses(
- const typedef_ns::MyTestCase &Case) {
- auto Lambda = [&Case]() {};
- (void)new typedef_ns::MyTestCase();
- const typedef_ns::MyTestCase *Result = &Case;
- return Result;
-}
-
-struct TypedefTestCaseHolder {
- typedef_ns::MyTestCase Case;
-};
-
-class TypedefMyTest : public typedef_ns::MyTestCase {};
-template <typename T = typedef_ns::MyTestCase> class TypedefTestTypeHolder {};
-template <> class TypedefTestTypeHolder<typedef_ns::MyTestCase> {};
-
-namespace alias_ns {
-
-using MyTestCase = testing::TestCase;
-// CHECK-MESSAGES: [[@LINE-1]]:29: warning: Google Test APIs named with 'case'
-// CHECK-FIXES: using MyTestCase = testing::TestSuite;
-
-const MyTestCase *testCaseUses(const MyTestCase &Case) {
- auto Lambda = [&Case]() {};
- (void)new MyTestCase();
- const MyTestCase *Result = &Case;
- return Result;
-}
-
-struct TestCaseHolder {
- MyTestCase Case;
-};
-
-class MyTest : public MyTestCase {};
-template <typename T = MyTestCase> class TestTypeHolder {};
-template <> class TestTypeHolder<MyTestCase> {};
-
-} // namespace alias_ns
-
-const alias_ns::MyTestCase *aliasTestCaseUses(
- const alias_ns::MyTestCase &Case) {
- auto Lambda = [&Case]() {};
- (void)new alias_ns::MyTestCase();
- const alias_ns::MyTestCase *Result = &Case;
- return Result;
-}
-
-struct AliasTestCaseHolder {
- alias_ns::MyTestCase Case;
-};
-
-class AliasMyTest : public alias_ns::MyTestCase {};
-template <typename T = alias_ns::MyTestCase> class AliasTestTypeHolder {};
-template <> class AliasTestTypeHolder<alias_ns::MyTestCase> {};
-
-template <typename T>
-void templateFunction(const T& t) {
- (void)t.current_test_case();
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: Google Test APIs named with 'case'
-}
-
-void instantiateTemplateFunction(const testing::UnitTest &Test) {
- templateFunction(Test);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-exception-baseclass.cpp (removed)
@@ -1,284 +0,0 @@
-// RUN: %check_clang_tidy %s hicpp-exception-baseclass %t -- -- -fcxx-exceptions
-
-namespace std {
-class exception {};
-class invalid_argument : public exception {};
-} // namespace std
-
-class derived_exception : public std::exception {};
-class deep_hierarchy : public derived_exception {};
-class non_derived_exception {};
-class terrible_idea : public non_derived_exception, public derived_exception {};
-
-// FIXME: More complicated kinds of inheritance should be checked later, but there is
-// currently no way use ASTMatchers for this kind of task.
-#if 0
-class bad_inheritance : private std::exception {};
-class no_good_inheritance : protected std::exception {};
-class really_creative : public non_derived_exception, private std::exception {};
-#endif
-
-void problematic() {
- try {
- throw int(42);
- // CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
- } catch (int e) {
- }
- throw int(42);
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-
- try {
- throw 12;
- // CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
- } catch (...) {
- throw; // Ok, even if the type is not known, conforming code can never rethrow a non-std::exception object.
- }
-
- try {
- throw non_derived_exception();
- // CHECK-NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
- // CHECK-NOTES: 10:1: note: type defined here
- } catch (non_derived_exception &e) {
- }
- throw non_derived_exception();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
- // CHECK-NOTES: 10:1: note: type defined here
-
-// FIXME: More complicated kinds of inheritance should be checked later, but there is
-// currently no way use ASTMatchers for this kind of task.
-#if 0
- // Handle private inheritance cases correctly.
- try {
- throw bad_inheritance();
- // CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
- // CHECK NOTES: 11:1: note: type defined here
- throw no_good_inheritance();
- // CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
- // CHECK NOTES: 12:1: note: type defined here
- throw really_creative();
- // CHECK NOTES: [[@LINE-1]]:11: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
- // CHECK NOTES: 13:1: note: type defined here
- } catch (...) {
- }
- throw bad_inheritance();
- // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_inheritance' is not derived from 'std::exception'
- // CHECK NOTES: 11:1: note: type defined here
- throw no_good_inheritance();
- // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'no_good_inheritance' is not derived from 'std::exception'
- // CHECK NOTES: 12:1: note: type defined here
- throw really_creative();
- // CHECK NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'really_creative' is not derived from 'std::exception'
- // CHECK NOTES: 13:1: note: type defined here
-#endif
-}
-
-void allowed_throws() {
- try {
- throw std::exception(); // Ok
- } catch (std::exception &e) { // Ok
- }
- throw std::exception();
-
- try {
- throw derived_exception(); // Ok
- } catch (derived_exception &e) { // Ok
- }
- throw derived_exception(); // Ok
-
- try {
- throw deep_hierarchy(); // Ok, multiple levels of inheritance
- } catch (deep_hierarchy &e) { // Ok
- }
- throw deep_hierarchy(); // Ok
-
- try {
- throw terrible_idea(); // Ok, but multiple inheritance isn't clean
- } catch (std::exception &e) { // Can be caught as std::exception, even with multiple inheritance
- }
- throw terrible_idea(); // Ok, but multiple inheritance
-}
-
-void test_lambdas() {
- auto BadLambda = []() { throw int(42); };
- // CHECK-NOTES: [[@LINE-1]]:33: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
- auto GoodLambda = []() { throw derived_exception(); };
-}
-
-// Templated function that throws exception based on template type
-template <typename T>
-void ThrowException() { throw T(); }
-// CHECK-NOTES: [[@LINE-1]]:31: warning: throwing an exception whose type 'bad_generic_exception<int>' is not derived from 'std::exception'
-// CHECK-NOTES: [[@LINE-2]]:31: note: type 'bad_generic_exception<int>' is a template instantiation of 'T'
-// CHECK-NOTES: [[@LINE+25]]:1: note: type defined here
-
-// CHECK-NOTES: [[@LINE-5]]:31: warning: throwing an exception whose type 'bad_generic_exception<std::exception>' is not derived from 'std::exception'
-// CHECK-NOTES: [[@LINE-6]]:31: note: type 'bad_generic_exception<std::exception>' is a template instantiation of 'T'
-// CHECK-NOTES: [[@LINE+21]]:1: note: type defined here
-
-// CHECK-NOTES: [[@LINE-9]]:31: warning: throwing an exception whose type 'exotic_exception<non_derived_exception>' is not derived from 'std::exception'
-// CHECK-NOTES: [[@LINE-10]]:31: note: type 'exotic_exception<non_derived_exception>' is a template instantiation of 'T'
-// CHECK-NOTES: [[@LINE+20]]:1: note: type defined here
-
-// CHECK-NOTES: [[@LINE-13]]:31: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-// CHECK-NOTES: [[@LINE-14]]:31: note: type 'int' is a template instantiation of 'T'
-
-// CHECK-NOTES: [[@LINE-16]]:31: warning: throwing an exception whose type 'non_derived_exception' is not derived from 'std::exception'
-// CHECK-NOTES: [[@LINE-17]]:31: note: type 'non_derived_exception' is a template instantiation of 'T'
-// CHECK-NOTES: 10:1: note: type defined here
-
-#define THROW_EXCEPTION(CLASS) ThrowException<CLASS>()
-#define THROW_BAD_EXCEPTION throw int(42);
-#define THROW_GOOD_EXCEPTION throw std::exception();
-#define THROW_DERIVED_EXCEPTION throw deep_hierarchy();
-
-template <typename T>
-class generic_exception : std::exception {};
-
-template <typename T>
-class bad_generic_exception {};
-
-template <typename T>
-class exotic_exception : public T {};
-
-void generic_exceptions() {
- THROW_EXCEPTION(int);
- THROW_EXCEPTION(non_derived_exception);
- THROW_EXCEPTION(std::exception); // Ok
- THROW_EXCEPTION(derived_exception); // Ok
- THROW_EXCEPTION(deep_hierarchy); // Ok
-
- THROW_BAD_EXCEPTION;
- // CHECK-NOTES: [[@LINE-1]]:3: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
- // CHECK-NOTES: [[@LINE-22]]:35: note: expanded from macro 'THROW_BAD_EXCEPTION'
- THROW_GOOD_EXCEPTION;
- THROW_DERIVED_EXCEPTION;
-
- throw generic_exception<int>(); // Ok,
- THROW_EXCEPTION(generic_exception<float>); // Ok
-
- throw bad_generic_exception<int>();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_generic_exception<int>' is not derived from 'std::exception'
- // CHECK-NOTES: [[@LINE-24]]:1: note: type defined here
- throw bad_generic_exception<std::exception>();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'bad_generic_exception<std::exception>' is not derived from 'std::exception'
- // CHECK-NOTES: [[@LINE-27]]:1: note: type defined here
- THROW_EXCEPTION(bad_generic_exception<int>);
- THROW_EXCEPTION(bad_generic_exception<std::exception>);
-
- throw exotic_exception<non_derived_exception>();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'exotic_exception<non_derived_exception>' is not derived from 'std::exception'
- // CHECK-NOTES: [[@LINE-30]]:1: note: type defined here
- THROW_EXCEPTION(exotic_exception<non_derived_exception>);
-
- throw exotic_exception<derived_exception>(); // Ok
- THROW_EXCEPTION(exotic_exception<derived_exception>); // Ok
-}
-
-// Test for typedefed exception types
-typedef int TypedefedBad;
-typedef derived_exception TypedefedGood;
-using UsingBad = int;
-using UsingGood = deep_hierarchy;
-
-void typedefed() {
- throw TypedefedBad();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'TypedefedBad' (aka 'int') is not derived from 'std::exception'
- // CHECK-NOTES: [[@LINE-8]]:1: note: type defined here
- throw TypedefedGood(); // Ok
-
- throw UsingBad();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'UsingBad' (aka 'int') is not derived from 'std::exception'
- // CHECK-NOTES: [[@LINE-11]]:1: note: type defined here
- throw UsingGood(); // Ok
-}
-
-// Fix PR37913
-struct invalid_argument_maker {
- ::std::invalid_argument operator()() const;
-};
-struct int_maker {
- int operator()() const;
-};
-
-template <typename T>
-void templated_thrower() {
- throw T{}();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-}
-template <typename T>
-void templated_thrower2() {
- T ExceptionFactory; // This test found a <dependant-type> which did not happend with 'throw T{}()'
- throw ExceptionFactory();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-}
-
-void exception_created_with_function() {
- templated_thrower<invalid_argument_maker>();
- templated_thrower<int_maker>();
-
- templated_thrower2<invalid_argument_maker>();
- templated_thrower2<int_maker>();
-
- throw invalid_argument_maker{}();
- throw int_maker{}();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-}
-
-struct invalid_argument_factory {
- ::std::invalid_argument make_exception() const;
-};
-
-struct int_factory {
- int make_exception() const;
-};
-
-template <typename T>
-void templated_factory() {
- T f;
- throw f.make_exception();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-}
-template <typename T>
-void templated_factory2() {
- throw T().make_exception();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-}
-
-void exception_from_factory() {
- templated_factory<invalid_argument_factory>();
- templated_factory<int_factory>();
-
- templated_factory2<invalid_argument_factory>();
- templated_factory2<int_factory>();
-
- throw invalid_argument_factory().make_exception();
- throw int_factory().make_exception();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-
- invalid_argument_factory inv_f;
- throw inv_f.make_exception();
-
- int_factory int_f;
- throw int_f.make_exception();
- // CHECK-NOTES: [[@LINE-1]]:9: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-}
-
-template <typename T>
-struct ThrowClassTemplateParam {
- ThrowClassTemplateParam() { throw T(); }
- // CHECK-NOTES: [[@LINE-1]]:37: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
- // CHECK-NOTES: [[@LINE-2]]:37: note: type 'int' is a template instantiation of 'T'
-};
-
-template <int V>
-struct ThrowValueTemplate {
- ThrowValueTemplate() { throw V; }
- // CHECK-NOTES: [[@LINE-1]]:32: warning: throwing an exception whose type 'int' is not derived from 'std::exception'
-};
-
-void class_templates() {
- ThrowClassTemplateParam<int> IntThrow;
- ThrowClassTemplateParam<std::invalid_argument> ArgThrow;
-
- ThrowValueTemplate<42> ValueThrow;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered-else.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered-else.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered-else.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered-else.cpp (removed)
@@ -1,57 +0,0 @@
-// RUN: %check_clang_tidy %s hicpp-multiway-paths-covered %t \
-// RUN: -config='{CheckOptions: \
-// RUN: [{key: hicpp-multiway-paths-covered.WarnOnMissingElse, value: 1}]}'\
-// RUN: --
-
-enum OS { Mac,
- Windows,
- Linux };
-
-void problematic_if(int i, enum OS os) {
- if (i > 0) {
- return;
- } else if (i < 0) {
- // CHECK-MESSAGES: [[@LINE-1]]:10: warning: potentially uncovered codepath; add an ending else statement
- return;
- }
-
- // Could be considered as false positive because all paths are covered logically.
- // I still think this is valid since the possibility of a final 'everything else'
- // codepath is expected from if-else if.
- if (i > 0) {
- return;
- } else if (i <= 0) {
- // CHECK-MESSAGES: [[@LINE-1]]:10: warning: potentially uncovered codepath; add an ending else statement
- return;
- }
-
- // Test if nesting of if-else chains does get caught as well.
- if (os == Mac) {
- return;
- } else if (os == Linux) {
- // These checks are kind of degenerated, but the check will not try to solve
- // if logically all paths are covered, which is more the area of the static analyzer.
- if (true) {
- return;
- } else if (false) {
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: potentially uncovered codepath; add an ending else statement
- return;
- }
- return;
- } else {
- /* unreachable */
- if (true) // check if the parent would match here as well
- return;
- // No warning for simple if statements, since it is common to just test one condition
- // and ignore the opposite.
- }
-
- // Ok, because all paths are covered
- if (i > 0) {
- return;
- } else if (i < 0) {
- return;
- } else {
- /* error, maybe precondition failed */
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-multiway-paths-covered.cpp (removed)
@@ -1,468 +0,0 @@
-// RUN: %check_clang_tidy %s hicpp-multiway-paths-covered %t
-
-enum OS { Mac,
- Windows,
- Linux };
-
-struct Bitfields {
- unsigned UInt : 3;
- int SInt : 1;
-};
-
-int return_integer() { return 42; }
-
-void bad_switch(int i) {
- switch (i) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch with only one case; use an if statement
- case 0:
- break;
- }
- // No default in this switch
- switch (i) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
- case 0:
- break;
- case 1:
- break;
- case 2:
- break;
- }
-
- // degenerate, maybe even warning
- switch (i) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch statement without labels has no effect
- }
-
- switch (int j = return_integer()) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
- case 0:
- case 1:
- case 2:
- break;
- }
-
- // Degenerated, only default case.
- switch (i) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch with default label only
- default:
- break;
- }
-
- // Degenerated, only one case label and default case -> Better as if-stmt.
- switch (i) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch could be better written as an if/else statement
- case 0:
- break;
- default:
- break;
- }
-
- unsigned long long BigNumber = 0;
- switch (BigNumber) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
- case 0:
- case 1:
- break;
- }
-
- const int &IntRef = i;
- switch (IntRef) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
- case 0:
- case 1:
- break;
- }
-
- char C = 'A';
- switch (C) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
- case 'A':
- break;
- case 'B':
- break;
- }
-
- Bitfields Bf;
- // UInt has 3 bits size.
- switch (Bf.UInt) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: potential uncovered code path; add a default label
- case 0:
- case 1:
- break;
- }
- // All paths explicitly covered.
- switch (Bf.UInt) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- break;
- }
- // SInt has 1 bit size, so this is somewhat degenerated.
- switch (Bf.SInt) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: switch with only one case; use an if statement
- case 0:
- break;
- }
- // All paths explicitly covered.
- switch (Bf.SInt) {
- case 0:
- case 1:
- break;
- }
-
- bool Flag = false;
- switch (Flag) {
- // CHECK-MESSAGES:[[@LINE-1]]:3: warning: switch with only one case; use an if statement
- case true:
- break;
- }
-
- switch (Flag) {
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: degenerated switch with default label only
- default:
- break;
- }
-
- // This `switch` will create a frontend warning from '-Wswitch-bool' but is
- // ok for this check.
- switch (Flag) {
- case true:
- break;
- case false:
- break;
- }
-}
-
-void unproblematic_switch(unsigned char c) {
- //
- switch (c) {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- case 32:
- case 33:
- case 34:
- case 35:
- case 36:
- case 37:
- case 38:
- case 39:
- case 40:
- case 41:
- case 42:
- case 43:
- case 44:
- case 45:
- case 46:
- case 47:
- case 48:
- case 49:
- case 50:
- case 51:
- case 52:
- case 53:
- case 54:
- case 55:
- case 56:
- case 57:
- case 58:
- case 59:
- case 60:
- case 61:
- case 62:
- case 63:
- case 64:
- case 65:
- case 66:
- case 67:
- case 68:
- case 69:
- case 70:
- case 71:
- case 72:
- case 73:
- case 74:
- case 75:
- case 76:
- case 77:
- case 78:
- case 79:
- case 80:
- case 81:
- case 82:
- case 83:
- case 84:
- case 85:
- case 86:
- case 87:
- case 88:
- case 89:
- case 90:
- case 91:
- case 92:
- case 93:
- case 94:
- case 95:
- case 96:
- case 97:
- case 98:
- case 99:
- case 100:
- case 101:
- case 102:
- case 103:
- case 104:
- case 105:
- case 106:
- case 107:
- case 108:
- case 109:
- case 110:
- case 111:
- case 112:
- case 113:
- case 114:
- case 115:
- case 116:
- case 117:
- case 118:
- case 119:
- case 120:
- case 121:
- case 122:
- case 123:
- case 124:
- case 125:
- case 126:
- case 127:
- case 128:
- case 129:
- case 130:
- case 131:
- case 132:
- case 133:
- case 134:
- case 135:
- case 136:
- case 137:
- case 138:
- case 139:
- case 140:
- case 141:
- case 142:
- case 143:
- case 144:
- case 145:
- case 146:
- case 147:
- case 148:
- case 149:
- case 150:
- case 151:
- case 152:
- case 153:
- case 154:
- case 155:
- case 156:
- case 157:
- case 158:
- case 159:
- case 160:
- case 161:
- case 162:
- case 163:
- case 164:
- case 165:
- case 166:
- case 167:
- case 168:
- case 169:
- case 170:
- case 171:
- case 172:
- case 173:
- case 174:
- case 175:
- case 176:
- case 177:
- case 178:
- case 179:
- case 180:
- case 181:
- case 182:
- case 183:
- case 184:
- case 185:
- case 186:
- case 187:
- case 188:
- case 189:
- case 190:
- case 191:
- case 192:
- case 193:
- case 194:
- case 195:
- case 196:
- case 197:
- case 198:
- case 199:
- case 200:
- case 201:
- case 202:
- case 203:
- case 204:
- case 205:
- case 206:
- case 207:
- case 208:
- case 209:
- case 210:
- case 211:
- case 212:
- case 213:
- case 214:
- case 215:
- case 216:
- case 217:
- case 218:
- case 219:
- case 220:
- case 221:
- case 222:
- case 223:
- case 224:
- case 225:
- case 226:
- case 227:
- case 228:
- case 229:
- case 230:
- case 231:
- case 232:
- case 233:
- case 234:
- case 235:
- case 236:
- case 237:
- case 238:
- case 239:
- case 240:
- case 241:
- case 242:
- case 243:
- case 244:
- case 245:
- case 246:
- case 247:
- case 248:
- case 249:
- case 250:
- case 251:
- case 252:
- case 253:
- case 254:
- case 255:
- break;
- }
-
- // Some paths are covered by the switch and a default case is present.
- switch (c) {
- case 1:
- case 2:
- case 3:
- default:
- break;
- }
-}
-
-OS return_enumerator() {
- return Linux;
-}
-
-// Enumpaths are already covered by a warning, this is just to ensure, that there is
-// no interference or false positives.
-// -Wswitch warns about uncovered enum paths and each here described case is already
-// covered.
-void switch_enums(OS os) {
- switch (os) {
- case Linux:
- break;
- }
-
- switch (OS another_os = return_enumerator()) {
- case Linux:
- break;
- }
-
- switch (os) {
- }
-}
-
-/// All of these cases will not emit a warning per default, but with explicit activation.
-/// Covered in extra test file.
-void problematic_if(int i, enum OS os) {
- if (i > 0) {
- return;
- } else if (i < 0) {
- return;
- }
-
- if (os == Mac) {
- return;
- } else if (os == Linux) {
- if (true) {
- return;
- } else if (false) {
- return;
- }
- return;
- } else {
- /* unreachable */
- if (true) // check if the parent would match here as well
- return;
- }
-
- // Ok, because all paths are covered
- if (i > 0) {
- return;
- } else if (i < 0) {
- return;
- } else {
- /* error, maybe precondition failed */
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler-msvc.cpp (removed)
@@ -1,11 +0,0 @@
-// REQUIRES: system-windows
-// FIXME: Re-enable test on windows (PR36855)
-// UNSUPPORTED: system-windows
-// RUN: %check_clang_tidy %s hicpp-no-assembler %t
-
-void f() {
- _asm {
- mov al, 2;
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-no-assembler.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: %check_clang_tidy %s hicpp-no-assembler %t
-
-__asm__(".symver foo, bar at v");
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
-
-static int s asm("spam");
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
-
-void f() {
- __asm("mov al, 2");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not use inline assembler in safety-critical code [hicpp-no-assembler]
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-bug34747.cpp (removed)
@@ -1,29 +0,0 @@
-// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t --
-
-// Note: this test expects no diagnostics, but FileCheck cannot handle that,
-// hence the use of | count 0.
-
-template <typename C>
-struct OutputStream {
- OutputStream &operator<<(C);
-};
-
-template <typename C>
-struct foo {
- typedef OutputStream<C> stream_type;
- foo(stream_type &o) {
- o << 'x'; // warning occured here, fixed now
- }
-};
-
-void bar(OutputStream<signed char> &o) {
- foo<signed char> f(o);
-}
-
-void silence_lit() {
- int SValue = 42;
- int SResult;
-
- SResult = SValue & 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp (removed)
@@ -1,198 +0,0 @@
-// RUN: clang-tidy %s -checks='-*,hicpp-signed-bitwise' -- -std=c++11
-// FIXME: Make the test work in all language modes.
-
-#include "hicpp-signed-bitwise-standard-types.h"
-
-void pure_bitmask_types() {
- // std::locale::category
- int SResult = 0;
- std::locale::category C = std::locale::category::ctype;
-
- SResult = std::locale::category::none | std::locale::category::collate;
- SResult|= std::locale::category::collate;
- SResult = std::locale::category::ctype & std::locale::category::monetary;
- SResult&= std::locale::category::monetary;
- SResult = std::locale::category::numeric ^ std::locale::category::time;
- SResult^= std::locale::category::time;
- SResult = std::locale::category::messages | std::locale::category::all;
-
- SResult = std::locale::category::all & C;
- SResult&= std::locale::category::all;
- SResult = std::locale::category::all | C;
- SResult|= std::locale::category::all;
- SResult = std::locale::category::all ^ C;
- SResult^= std::locale::category::all;
-
- // std::ctype_base::mask
- std::ctype_base::mask M = std::ctype_base::mask::punct;
-
- SResult = std::ctype_base::mask::space | std::ctype_base::mask::print;
- SResult = std::ctype_base::mask::cntrl & std::ctype_base::mask::upper;
- SResult = std::ctype_base::mask::lower ^ std::ctype_base::mask::alpha;
- SResult|= std::ctype_base::mask::digit | std::ctype_base::mask::punct;
- SResult&= std::ctype_base::mask::xdigit & std::ctype_base::mask::alnum;
- SResult^= std::ctype_base::mask::alnum ^ std::ctype_base::mask::graph;
-
- SResult&= std::ctype_base::mask::space & M;
- SResult|= std::ctype_base::mask::space | M;
- SResult^= std::ctype_base::mask::space ^ M;
-
- // std::ios_base::fmtflags
- std::ios_base::fmtflags F = std::ios_base::fmtflags::floatfield;
-
- SResult = std::ios_base::fmtflags::dec | std::ios_base::fmtflags::oct;
- SResult = std::ios_base::fmtflags::hex & std::ios_base::fmtflags::basefield;
- SResult = std::ios_base::fmtflags::left ^ std::ios_base::fmtflags::right;
- SResult|= std::ios_base::fmtflags::internal | std::ios_base::fmtflags::adjustfield;
- SResult&= std::ios_base::fmtflags::scientific & std::ios_base::fmtflags::fixed;
- SResult^= std::ios_base::fmtflags::floatfield ^ std::ios_base::fmtflags::boolalpha;
- SResult = std::ios_base::fmtflags::showbase | std::ios_base::fmtflags::showpoint;
- SResult = std::ios_base::fmtflags::showpos & std::ios_base::fmtflags::skipws;
- SResult = std::ios_base::fmtflags::unitbuf ^ std::ios_base::fmtflags::uppercase;
-
- SResult|= std::ios_base::fmtflags::unitbuf | F;
- SResult&= std::ios_base::fmtflags::unitbuf & F;
- SResult^= std::ios_base::fmtflags::unitbuf ^ F;
-
- // std::ios_base::iostate
- std::ios_base::iostate S = std::ios_base::iostate::goodbit;
-
- SResult^= std::ios_base::iostate::goodbit | std::ios_base::iostate::badbit;
- SResult|= std::ios_base::iostate::failbit & std::ios_base::iostate::eofbit;
- SResult&= std::ios_base::iostate::failbit ^ std::ios_base::iostate::eofbit;
-
- SResult = std::ios_base::iostate::goodbit | S;
- SResult = std::ios_base::iostate::goodbit & S;
- SResult = std::ios_base::iostate::goodbit ^ S;
-
- // std::ios_base::openmode
- std::ios_base::openmode B = std::ios_base::openmode::binary;
-
- SResult = std::ios_base::openmode::app | std::ios_base::openmode::binary;
- SResult = std::ios_base::openmode::in & std::ios_base::openmode::out;
- SResult = std::ios_base::openmode::trunc ^ std::ios_base::openmode::ate;
-
- SResult&= std::ios_base::openmode::trunc | B;
- SResult^= std::ios_base::openmode::trunc & B;
- SResult|= std::ios_base::openmode::trunc ^ B;
-}
-
-void still_forbidden() {
- // std::locale::category
- unsigned int UResult = 0u;
- int SResult = 0;
-
- SResult = std::ctype_base::mask::print ^ 8u;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult = std::ctype_base::mask::cntrl | 8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult = std::ctype_base::mask::upper & 8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult = std::ctype_base::mask::lower ^ -8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- // Staying within the allowed standard types is ok for bitwise assignment
- // operations.
- std::ctype_base::mask var = std::ctype_base::mask::print;
- SResult<<= std::ctype_base::mask::upper;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult>>= std::ctype_base::mask::upper;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult &= std::ctype_base::mask::upper;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult |= std::ctype_base::mask::upper;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult ^= std::ctype_base::mask::upper;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = std::locale::category::collate << 1u;
- UResult = std::locale::category::ctype << 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::locale::category::monetary >> 1u;
- UResult = std::locale::category::numeric >> 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = ~std::locale::category::messages;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
- SResult = ~std::locale::category::all;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
-
- // std::ctype_base::mask
- UResult = std::ctype_base::mask::space | 8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ctype_base::mask::print & 8u;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ctype_base::mask::cntrl ^ -8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = std::ctype_base::mask::upper << 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ctype_base::mask::lower << 1u;
- UResult = std::ctype_base::mask::alpha >> 1u;
- UResult = std::ctype_base::mask::digit >> 1u;
-
- UResult = ~std::ctype_base::mask::punct;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
- SResult = ~std::ctype_base::mask::xdigit;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
-
- // std::ios_base::fmtflags
- UResult = std::ios_base::fmtflags::dec | 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::fmtflags::oct & 1u;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::fmtflags::hex ^ -1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = std::ios_base::fmtflags::basefield >> 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::fmtflags::left >> 1u;
- UResult = std::ios_base::fmtflags::right << 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::fmtflags::internal << 1u;
-
- UResult = ~std::ios_base::fmtflags::adjustfield;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
- SResult = ~std::ios_base::fmtflags::scientific;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
-
- // std::ios_base::iostate
- UResult = std::ios_base::iostate::goodbit | 8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::iostate::badbit & 8u;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::iostate::failbit ^ -8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = std::ios_base::iostate::eofbit << 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::iostate::goodbit << 1u;
- UResult = std::ios_base::iostate::badbit >> 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::iostate::failbit >> 1u;
-
- UResult = ~std::ios_base::iostate::eofbit;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
- SResult = ~std::ios_base::iostate::goodbit;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
-
- // std::ios_base::openmode
- UResult = std::ios_base::app | 8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::binary & 8u;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::in ^ -8;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = std::ios_base::out >> 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::trunc >> 1u;
- UResult = std::ios_base::ate << 1;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = std::ios_base::ate << 1u;
-
- UResult = ~std::ios_base::openmode::app;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
- SResult = ~std::ios_base::openmode::binary;
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: use of a signed integer operand with a unary bitwise operator
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.h?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.h (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise-standard-types.h (removed)
@@ -1,81 +0,0 @@
-#pragma clang system_header
-
-// Implement standard types that are known to be defined as unsigned in some
-// implementations like MSVC.
-namespace std {
-namespace locale {
-enum category : int {
- none = 0u,
- collate = 1u << 1u,
- ctype = 1u << 2u,
- monetary = 1u << 3u,
- numeric = 1u << 4u,
- time = 1u << 5u,
- messages = 1u << 6u,
- all = none | collate | ctype | monetary | numeric | time | messages
- // CHECK MESSAGES: [[@LINE-1]]:9: warning: use of a signed integer operand with a binary bitwise operator
-};
-} // namespace locale
-
-namespace ctype_base {
-enum mask : int {
- space,
- print,
- cntrl,
- upper,
- lower,
- alpha,
- digit,
- punct,
- xdigit,
- /* blank, // C++11 */
- alnum = alpha | digit,
- // CHECK MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator
- graph = alnum | punct
- // CHECK MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator
-};
-} // namespace ctype_base
-
-namespace ios_base {
-enum fmtflags : int {
- dec = 0u,
- oct = 1u << 2u,
- hex = 1u << 3u,
- basefield = dec | oct | hex | 0u,
- // CHECK MESSAGES: [[@LINE-1]]:15: warning: use of a signed integer operand with a binary bitwise operator
- left = 1u << 4u,
- right = 1u << 5u,
- internal = 1u << 6u,
- adjustfield = left | right | internal,
- // CHECK MESSAGES: [[@LINE-1]]:17: warning: use of a signed integer operand with a binary bitwise operator
- scientific = 1u << 7u,
- fixed = 1u << 8u,
- floatfield = scientific | fixed | (scientific | fixed) | 0u,
- // CHECK MESSAGES: [[@LINE-1]]:16: warning: use of a signed integer operand with a binary bitwise operator
- // CHECK MESSAGES: [[@LINE-2]]:38: warning: use of a signed integer operand with a binary bitwise operator
- boolalpha = 1u << 9u,
- showbase = 1u << 10u,
- showpoint = 1u << 11u,
- showpos = 1u << 12u,
- skipws = 1u << 13u,
- unitbuf = 1u << 14u,
- uppercase = 1u << 15u
-};
-
-enum iostate : int {
- goodbit = 0u,
- badbit = 1u << 1u,
- failbit = 1u << 2u,
- eofbit = 1u << 3u
-};
-
-enum openmode : int {
- app = 0u,
- binary = 0u << 1u,
- in = 0u << 2u,
- out = 0u << 3u,
- trunc = 0u << 4u,
- ate = 0u << 5u
-};
-} // namespace ios_base
-} // namespace std
Removed: clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/hicpp-signed-bitwise.cpp (removed)
@@ -1,240 +0,0 @@
-// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t -- -- --target=x86_64-linux
-
-// These could cause false positives and should not be considered.
-struct StreamClass {
-};
-StreamClass &operator<<(StreamClass &os, unsigned int i) {
- return os;
-}
-StreamClass &operator<<(StreamClass &os, int i) {
- return os;
-}
-StreamClass &operator>>(StreamClass &os, unsigned int i) {
- return os;
-}
-StreamClass &operator>>(StreamClass &os, int i) {
- return os;
-}
-struct AnotherStream {
- AnotherStream &operator<<(unsigned char c) { return *this; }
- AnotherStream &operator<<(signed char c) { return *this; }
-
- AnotherStream &operator>>(unsigned char c) { return *this; }
- AnotherStream &operator>>(signed char c) { return *this; }
-};
-
-void binary_bitwise() {
- int SValue = 42;
- int SResult;
-
- unsigned int UValue = 42;
- unsigned int UResult;
-
- SResult = SValue & 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult = SValue & -1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- SResult = SValue & SValue;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = SValue & 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult = SValue & -1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- UResult&= 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
-
- UResult = UValue & 1u; // Ok
- UResult = UValue & UValue; // Ok
- UResult&= 2u; // Ok
-
- unsigned char UByte1 = 0u;
- unsigned char UByte2 = 16u;
- signed char SByte1 = 0;
- signed char SByte2 = 16;
-
- UByte1 = UByte1 & UByte2; // Ok
- UByte1 = SByte1 & UByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
- UByte1 = SByte1 & SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
- SByte1 = SByte1 & SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
-
- // More complex expressions.
- UResult = UValue & (SByte1 + (SByte1 | SByte2));
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
- // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: use of a signed integer operand with a binary bitwise operator
-
- // The rest is to demonstrate functionality but all operators are matched equally.
- // Therefore functionality is the same for all binary operations.
- UByte1 = UByte1 | UByte2; // Ok
- UByte1 = UByte1 | SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
- UByte1|= SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
- UByte1|= UByte2; // Ok
-
- UByte1 = UByte1 ^ UByte2; // Ok
- UByte1 = UByte1 ^ SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
- UByte1^= SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
- UByte1^= UByte2; // Ok
-
- UByte1 = UByte1 >> UByte2; // Ok
- UByte1 = UByte1 >> SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
- UByte1>>= SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
- UByte1>>= UByte2; // Ok
-
- UByte1 = UByte1 << UByte2; // Ok
- UByte1 = UByte1 << SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a binary bitwise operator
- UByte1<<= SByte2;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
- UByte1<<= UByte2; // Ok
-
- int SignedInt1 = 1 << 12;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator
- int SignedInt2 = 1u << 12;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator
-}
-
-void f1(unsigned char c) {}
-void f2(signed char c) {}
-void f3(int c) {}
-
-void unary_bitwise() {
- unsigned char UByte1 = 0u;
- signed char SByte1 = 0;
-
- UByte1 = ~UByte1; // Ok
- SByte1 = ~UByte1;
- SByte1 = ~SByte1;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a unary bitwise operator
- UByte1 = ~SByte1;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use of a signed integer operand with a unary bitwise operator
-
- unsigned int UInt = 0u;
- int SInt = 0;
-
- f1(~UByte1); // Ok
- f1(~SByte1);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use of a signed integer operand with a unary bitwise operator
- f1(~UInt);
- f1(~SInt);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use of a signed integer operand with a unary bitwise operator
- f2(~UByte1);
- f2(~SByte1);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use of a signed integer operand with a unary bitwise operator
- f2(~UInt);
- f2(~SInt);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use of a signed integer operand with a unary bitwise operator
- f3(~UByte1); // Ok
- f3(~SByte1);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use of a signed integer operand with a unary bitwise operator
-}
-
-/// HICPP uses these examples to demonstrate the rule.
-void standard_examples() {
- int i = 3;
- unsigned int k = 0u;
-
- int r = i << -1; // Emits -Wshift-count-negative from clang
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator
- r = i << 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator
-
- r = -1 >> -1; // Emits -Wshift-count-negative from clang
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator
- r = -1 >> 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator
-
- r = -1 >> i;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator
- r = -1 >> -i;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator
-
- r = ~0;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a unary bitwise operator
- r = ~0u; // Ok
- k = ~k; // Ok
-
- unsigned int u = (-1) & 2u;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator
- u = (-1) | 1u;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator
- u = (-1) ^ 1u;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator
-}
-
-void streams_should_work() {
- StreamClass s;
- s << 1u; // Ok
- s << 1; // Ok
- s >> 1; // Ok
- s >> 1u; // Ok
-
- AnotherStream as;
- unsigned char uc = 1u;
- signed char sc = 1;
- as << uc; // Ok
- as << sc; // Ok
- as >> uc; // Ok
- as >> sc; // Ok
-}
-
-enum OldEnum {
- ValueOne,
- ValueTwo,
-};
-
-enum OldSigned : int {
- IntOne,
- IntTwo,
-};
-
-void classicEnums() {
- OldEnum e1 = ValueOne, e2 = ValueTwo;
- int e3; // Using the enum type, results in an error.
- e3 = ValueOne | ValueTwo; // Ok
- e3 = ValueOne & ValueTwo; // Ok
- e3 = ValueOne ^ ValueTwo; // Ok
- e3 = e1 | e2; // Ok
- e3 = e1 & e2; // Ok
- e3 = e1 ^ e2; // Ok
-
- OldSigned s1 = IntOne, s2 = IntTwo;
- int s3;
- s3 = IntOne | IntTwo; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
- s3|= IntTwo; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
- s3 = IntOne & IntTwo; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
- s3&= IntTwo; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
- s3 = IntOne ^ IntTwo; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
- s3^= IntTwo; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator
- s3 = s1 | s2; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
- s3 = s1 & s2; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
- s3 = s1 ^ s2; // Signed
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: use of a signed integer operand with a binary bitwise operator
-}
-
-enum EnumConstruction {
- one = 1,
- two = 2,
- test1 = 1 << 12,
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator
- test2 = one << two,
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator
- test3 = 1u << 12,
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator
-};
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/a.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/a.h?rev=374540&view=auto
==============================================================================
(empty)
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/b.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/b.h?rev=374540&view=auto
==============================================================================
(empty)
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/s.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/s.h?rev=374540&view=auto
==============================================================================
(empty)
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/stdio.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/stdio.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/stdio.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/Headers/stdio.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1,18 @@
+//===--- stdio.h - Stub header for tests ------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef _STDIO_H_
+#define _STDIO_H_
+
+// A header intended to contain C standard input and output library
+// declarations.
+
+int printf(const char *, ...);
+
+#endif // _STDIO_H_
+
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/compilation-database/template.json
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/compilation-database/template.json?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/compilation-database/template.json (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/compilation-database/template.json Fri Oct 11 05:05:42 2019
@@ -0,0 +1,32 @@
+[
+{
+ "directory": "test_dir/a",
+ "command": "clang++ -o test.o test_dir/a/a.cpp",
+ "file": "test_dir/a/a.cpp"
+},
+{
+ "directory": "test_dir/a",
+ "command": "clang++ -o test.o test_dir/a/b.cpp",
+ "file": "test_dir/a/b.cpp"
+},
+{
+ "directory": "test_dir/",
+ "command": "clang++ -o test.o test_dir/b/b.cpp",
+ "file": "test_dir/b/b.cpp"
+},
+{
+ "directory": "test_dir/b",
+ "command": "clang++ -o test.o ../b/c.cpp",
+ "file": "test_dir/b/c.cpp"
+},
+{
+ "directory": "test_dir/b",
+ "command": "clang++ -I../include -o test.o ../b/d.cpp",
+ "file": "test_dir/b/d.cpp"
+},
+{
+ "directory": "test_dir/",
+ "command": "clang++ -o test.o test_dir/b/not-exist.cpp",
+ "file": "test_dir/b/not-exist.cpp"
+}
+]
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/.clang-tidy Fri Oct 11 05:05:42 2019
@@ -0,0 +1,2 @@
+Checks: 'from-parent'
+HeaderFilterRegex: 'parent'
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/config-files/1/.clang-tidy Fri Oct 11 05:05:42 2019
@@ -0,0 +1,2 @@
+Checks: 'from-child1'
+HeaderFilterRegex: 'child1'
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/empty-database/compile_commands.json
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/empty-database/compile_commands.json?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/empty-database/compile_commands.json (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/empty-database/compile_commands.json Fri Oct 11 05:05:42 2019
@@ -0,0 +1,4 @@
+[{
+ "directory":"",
+ "file":"/tmp/","arguments":[]
+}]
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/a.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/a.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/a.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/a.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+#define a
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/b.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/b.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/b.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/b.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1,2 @@
+#include "a.h"
+#define b
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/c.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/c.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/c.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/c.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1,2 @@
+#include "b.h"
+#define c
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/module.modulemap?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/module.modulemap (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/expand-modular-headers-ppcallbacks/module.modulemap Fri Oct 11 05:05:42 2019
@@ -0,0 +1,3 @@
+module a { header "a.h" export * }
+module b { header "b.h" export * use a }
+module c { header "c.h" export * use b }
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/explain-config/.clang-tidy
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/explain-config/.clang-tidy?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/explain-config/.clang-tidy (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/explain-config/.clang-tidy Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+Checks: '-*,modernize-use-nullptr'
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header1.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header1.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header1.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header1.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+class A1 { A1(int); };
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header2.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header2.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header2.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/header2.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+class A2 { A2(int); };
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/system/system-header.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/system/system-header.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/system/system-header.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/file-filter/system/system-header.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+class A0 { A0(int); };
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header1.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header1.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header1.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header1.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1,3 @@
+class A1 { A1(int); };
+class B1 { B1(int); };
+class C1 { C1(int); };
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header2.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header2.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header2.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header2.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1,3 @@
+class A2 { A2(int); };
+class B2 { B2(int); };
+class C2 { C2(int); };
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header3.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header3.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header3.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/line-filter/header3.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+class A3 { A3(int); };
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/bin/clang
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/bin/clang?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/bin/clang (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/bin/clang Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+This file is a placeholder to keep its parent directory in git.
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/include/c++/v1/mock_vector
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/include/c%2B%2B/v1/mock_vector?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/include/c++/v1/mock_vector (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/mock-libcxx/include/c++/v1/mock_vector Fri Oct 11 05:05:42 2019
@@ -0,0 +1,2 @@
+class vector {};
+typedef vector* vector_ptr;
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/nolint/trigger_warning.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/nolint/trigger_warning.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/nolint/trigger_warning.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/nolint/trigger_warning.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1,5 @@
+void A1(const int &In, int &Out) {
+ if (In > 123) // NOLINT
+ Out = 123;
+}
+
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/overlapping/o.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/overlapping/o.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/overlapping/o.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/overlapping/o.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1,9 @@
+// run: clang-tidy -checks=-*,llvm-include-order -header-filter=.* %s \
+// run: -- -isystem %S/Inputs/Headers -I %S/Inputs/overlapping | \
+// run: not grep "note: this fix will not be applied because it overlaps with another fix"
+
+#include "b.h"
+#include "a.h"
+
+// The comments above are there to match the offset of the #include with the
+// offset of the #includes in the .cpp file.
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/actual_header.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/actual_header.h?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/actual_header.h (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/actual_header.h Fri Oct 11 05:05:42 2019
@@ -0,0 +1 @@
+struct X {};
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/vfsoverlay.yaml
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/vfsoverlay.yaml?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/vfsoverlay.yaml (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/Inputs/vfsoverlay/vfsoverlay.yaml Fri Oct 11 05:05:42 2019
@@ -0,0 +1,12 @@
+{
+ 'version': 0,
+ 'roots': [
+ { 'name': 'OUT_DIR', 'type': 'directory',
+ 'contents': [
+ { 'name': 'not_real.h', 'type': 'file',
+ 'external-contents': 'INPUT_DIR/actual_header.h'
+ }
+ ]
+ }
+ ]
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/alternative-fixes.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/alternative-fixes.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/alternative-fixes.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/alternative-fixes.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy %s "llvm-namespace-comment,clang-diagnostic-*" %t
+void foo(int a) {
+ if (a = 1) {
+ // CHECK-NOTES: [[@LINE-1]]:9: warning: using the result of an assignment as a condition without parentheses [clang-diagnostic-parentheses]
+ // CHECK-NOTES: [[@LINE-2]]:9: note: place parentheses around the assignment to silence this warning
+ // CHECK-NOTES: [[@LINE-3]]:9: note: use '==' to turn this assignment into an equality comparison
+ // CHECK-FIXES: if ((a = 1)) {
+ }
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/basic.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/basic.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/basic.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/basic.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,6 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- | FileCheck %s
+// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,llvm-namespace-comment' 2>&1 | FileCheck %s
+
+namespace i {
+}
+// CHECK: warning: namespace 'i' not terminated with a closing comment [llvm-namespace-comment]
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/check_clang_tidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/check_clang_tidy.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/check_clang_tidy.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/check_clang_tidy.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy -check-suffix=USING-A %s misc-unused-using-decls %t -- -- -DUSING_A
+// RUN: %check_clang_tidy -check-suffix=USING-B %s misc-unused-using-decls %t -- -- -DUSING_B
+// RUN: %check_clang_tidy -check-suffix=USING-C,USING-D %s misc-unused-using-decls %t -- -- -DUSING_C_D
+// RUN: %check_clang_tidy -check-suffixes=USING-C,USING-D %s misc-unused-using-decls %t -- -- -DUSING_C_D
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+
+namespace a {class A {}; class B {}; class C {}; class D {}; class E {};}
+namespace b {
+#if defined(USING_A)
+using a::A;
+#elif defined(USING_B)
+using a::B;
+#elif defined(USING_C_D)
+using a::C;
+using a::D;
+#else
+using a::E;
+#endif
+}
+namespace c {}
+// CHECK-MESSAGES-USING-A: warning: using decl 'A' {{.*}}
+// CHECK-MESSAGES-USING-B: warning: using decl 'B' {{.*}}
+// CHECK-MESSAGES-USING-C: warning: using decl 'C' {{.*}}
+// CHECK-MESSAGES-USING-D: warning: using decl 'D' {{.*}}
+// CHECK-MESSAGES: warning: using decl 'E' {{.*}}
+// CHECK-FIXES-USING-A-NOT: using a::A;$
+// CHECK-FIXES-USING-B-NOT: using a::B;$
+// CHECK-FIXES-USING-C-NOT: using a::C;$
+// CHECK-FIXES-USING-C-NOT: using a::D;$
+// CHECK-FIXES-USING-D-NOT: using a::C;$
+// CHECK-FIXES-USING-D-NOT: using a::D;$
+// CHECK-FIXES-NOT: using a::E;$
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-__clang_analyzer__macro.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-__clang_analyzer__macro.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-__clang_analyzer__macro.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-__clang_analyzer__macro.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,5 @@
+// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
+
+#if !defined(__clang_analyzer__)
+#error __clang_analyzer__ is not defined
+#endif
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-diff.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-diff.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-diff.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-diff.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,26 @@
+// REQUIRES: shell
+// RUN: sed 's/placeholder_for_f/f/' %s > %t.cpp
+// RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -quiet -- -std=c++11 2>&1 | FileCheck -check-prefix=CHECK-QUIET %s
+// RUN: mkdir -p %T/compilation-database-test/
+// RUN: echo '[{"directory": "%T", "command": "clang++ -o test.o -std=c++11 %t.cpp", "file": "%t.cpp"}]' > %T/compilation-database-test/compile_commands.json
+// RUN: not diff -U0 %s %t.cpp | %clang_tidy_diff -checks=-*,modernize-use-override -path %T/compilation-database-test 2>&1 | FileCheck -check-prefix=CHECK %s
+struct A {
+ virtual void f() {}
+ virtual void g() {}
+};
+// CHECK-NOT: warning:
+// CHECK-QUIET-NOT: warning:
+struct B : public A {
+ void placeholder_for_f() {}
+// CHECK-SANITY: [[@LINE-1]]:8: warning: annotate this
+// CHECK: [[@LINE-2]]:8: warning: annotate this
+// CHECK-QUIET: [[@LINE-3]]:8: warning: annotate this
+ void g() {}
+// CHECK-SANITY: [[@LINE-1]]:8: warning: annotate this
+// CHECK-NOT: warning:
+// CHECK-QUIET-NOT: warning:
+};
+// CHECK-SANITY-NOT: Suppressed
+// CHECK-QUIET-NOT: Suppressed
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-one-tu.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-one-tu.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-one-tu.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-one-tu.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,24 @@
+// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' %s -- 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' %s
+
+// CHECK: ===-------------------------------------------------------------------------===
+// CHECK-NEXT: clang-tidy checks profiling
+// CHECK-NEXT: ===-------------------------------------------------------------------------===
+// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock)
+
+// CHECK: {{.*}} --- Name ---
+// CHECK-NEXT: {{.*}} readability-function-size
+// CHECK-NEXT: {{.*}} Total
+
+// CHECK-NOT: ===-------------------------------------------------------------------------===
+// CHECK-NOT: clang-tidy checks profiling
+// CHECK-NOT: ===-------------------------------------------------------------------------===
+// CHECK-NOT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock)
+
+// CHECK-NOT: {{.*}} --- Name ---
+// CHECK-NOT: {{.*}} readability-function-size
+// CHECK-NOT: {{.*}} Total
+
+class A {
+ A() {}
+ ~A() {}
+};
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-two-tu.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-two-tu.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-two-tu.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-enable-check-profile-two-tu.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,33 @@
+// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' %s %s -- 2>&1 | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' %s
+
+// CHECK: ===-------------------------------------------------------------------------===
+// CHECK-NEXT: clang-tidy checks profiling
+// CHECK-NEXT: ===-------------------------------------------------------------------------===
+// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock)
+
+// CHECK: {{.*}} --- Name ---
+// CHECK-NEXT: {{.*}} readability-function-size
+// CHECK-NEXT: {{.*}} Total
+
+// CHECK: ===-------------------------------------------------------------------------===
+// CHECK-NEXT: clang-tidy checks profiling
+// CHECK-NEXT: ===-------------------------------------------------------------------------===
+// CHECK-NEXT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock)
+
+// CHECK: {{.*}} --- Name ---
+// CHECK-NEXT: {{.*}} readability-function-size
+// CHECK-NEXT: {{.*}} Total
+
+// CHECK-NOT: ===-------------------------------------------------------------------------===
+// CHECK-NOT: clang-tidy checks profiling
+// CHECK-NOT: ===-------------------------------------------------------------------------===
+// CHECK-NOT: Total Execution Time: {{.*}} seconds ({{.*}} wall clock)
+
+// CHECK-NOT: {{.*}} --- Name ---
+// CHECK-NOT: {{.*}} readability-function-size
+// CHECK-NOT: {{.*}} Total
+
+class A {
+ A() {}
+ ~A() {}
+};
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-mac-libcxx.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,17 @@
+// Clang on MacOS can find libc++ living beside the installed compiler.
+// This test makes sure clang-tidy emulates this properly.
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+//
+// Install the mock libc++ (simulates the libc++ directory structure).
+// RUN: cp -r %S/Inputs/mock-libcxx %t/
+//
+// Pretend clang is installed beside the mock library that we provided.
+// RUN: echo '[{"directory":"%t","command":"%t/mock-libcxx/bin/clang++ -stdlib=libc++ -std=c++11 -target x86_64-apple-darwin -c test.cpp","file":"test.cpp"}]' | sed -e 's/\\/\//g' > %t/compile_commands.json
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: clang-tidy -header-filter='.*' -system-headers -checks='-*,modernize-use-using' "%t/test.cpp" | FileCheck %s
+// CHECK: mock_vector:{{[0-9]+}}:{{[0-9]+}}: warning: use 'using' instead of 'typedef'
+
+#include <mock_vector>
+typedef vector* vec_ptr;
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-run-with-database.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,29 @@
+// RUN: mkdir -p %T/compilation-database-test/include
+// RUN: mkdir -p %T/compilation-database-test/a
+// RUN: mkdir -p %T/compilation-database-test/b
+// RUN: echo 'int *AA = 0;' > %T/compilation-database-test/a/a.cpp
+// RUN: echo 'int *AB = 0;' > %T/compilation-database-test/a/b.cpp
+// RUN: echo 'int *BB = 0;' > %T/compilation-database-test/b/b.cpp
+// RUN: echo 'int *BC = 0;' > %T/compilation-database-test/b/c.cpp
+// RUN: echo 'int *HP = 0;' > %T/compilation-database-test/include/header.h
+// RUN: echo '#include "header.h"' > %T/compilation-database-test/b/d.cpp
+// RUN: sed 's|test_dir|%/T/compilation-database-test|g' %S/Inputs/compilation-database/template.json > %T/compile_commands.json
+
+// Regression test: shouldn't crash.
+// RUN: not clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/b/not-exist -header-filter=.* 2>&1 | FileCheck %s -check-prefix=CHECK-NOT-EXIST
+// CHECK-NOT-EXIST: Error while processing {{.*[/\\]}}not-exist.
+// CHECK-NOT-EXIST: unable to handle compilation
+// CHECK-NOT-EXIST: Found compiler error
+
+// RUN: clang-tidy --checks=-*,modernize-use-nullptr -p %T %T/compilation-database-test/a/a.cpp %T/compilation-database-test/a/b.cpp %T/compilation-database-test/b/b.cpp %T/compilation-database-test/b/c.cpp %T/compilation-database-test/b/d.cpp -header-filter=.* -fix
+// RUN: FileCheck -input-file=%T/compilation-database-test/a/a.cpp %s -check-prefix=CHECK-FIX1
+// RUN: FileCheck -input-file=%T/compilation-database-test/a/b.cpp %s -check-prefix=CHECK-FIX2
+// RUN: FileCheck -input-file=%T/compilation-database-test/b/b.cpp %s -check-prefix=CHECK-FIX3
+// RUN: FileCheck -input-file=%T/compilation-database-test/b/c.cpp %s -check-prefix=CHECK-FIX4
+// RUN: FileCheck -input-file=%T/compilation-database-test/include/header.h %s -check-prefix=CHECK-FIX5
+
+// CHECK-FIX1: int *AA = nullptr;
+// CHECK-FIX2: int *AB = nullptr;
+// CHECK-FIX3: int *BB = nullptr;
+// CHECK-FIX4: int *BC = nullptr;
+// CHECK-FIX5: int *HP = nullptr;
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clang-tidy-store-check-profile-one-tu.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,37 @@
+// RUN: rm -rf %T/out
+// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T/out %s -- 2>&1 | not FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-CONSOLE %s
+// RUN: cat %T/out/*-clang-tidy-store-check-profile-one-tu.cpp.json | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-FILE %s
+// RUN: rm -rf %T/out
+// RUN: clang-tidy -enable-check-profile -checks='-*,readability-function-size' -store-check-profile=%T/out %s -- 2>&1
+// RUN: cat %T/out/*-clang-tidy-store-check-profile-one-tu.cpp.json | FileCheck --match-full-lines -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK-FILE %s
+
+// CHECK-CONSOLE-NOT: ===-------------------------------------------------------------------------===
+// CHECK-CONSOLE-NOT: {{.*}} --- Name ---
+// CHECK-CONSOLE-NOT: {{.*}} readability-function-size
+// CHECK-CONSOLE-NOT: {{.*}} Total
+// CHECK-CONSOLE-NOT: ===-------------------------------------------------------------------------===
+
+// CHECK-FILE: {
+// CHECK-FILE-NEXT:"file": "{{.*}}clang-tidy-store-check-profile-one-tu.cpp",
+// CHECK-FILE-NEXT:"timestamp": "{{[0-9]+}}-{{[0-9]+}}-{{[0-9]+}} {{[0-9]+}}:{{[0-9]+}}:{{[0-9]+}}.{{[0-9]+}}",
+// CHECK-FILE-NEXT:"profile": {
+// CHECK-FILE-NEXT: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NEXT: "time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NEXT: "time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}
+// CHECK-FILE-NEXT: }
+// CHECK-FILE-NEXT: }
+
+// CHECK-FILE-NOT: {
+// CHECK-FILE-NOT: "file": {{.*}}clang-tidy-store-check-profile-one-tu.cpp{{.*}},
+// CHECK-FILE-NOT: "timestamp": "{{[0-9]+}}-{{[0-9]+}}-{{[0-9]+}} {{[0-9]+}}:{{[0-9]+}}:{{[0-9]+}}.{{[0-9]+}}",
+// CHECK-FILE-NOT: "profile": {
+// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.wall": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.user": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}},
+// CHECK-FILE-NOT: "time.clang-tidy.readability-function-size.sys": {{.*}}{{[0-9]}}.{{[0-9]+}}e{{[-+]}}{{[0-9]}}{{[0-9]}}
+// CHECK-FILE-NOT: }
+// CHECK-FILE-NOT: }
+
+class A {
+ A() {}
+ ~A() {}
+};
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/clean-up-code.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/clean-up-code.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/clean-up-code.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/clean-up-code.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,14 @@
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=none --
+// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -format-style=llvm --
+namespace a { class A {}; }
+namespace b {
+using a::A;
+}
+namespace c {}
+// CHECK-MESSAGES: :[[@LINE-3]]:10: warning: using decl 'A' is unused [misc-unused-using-decls]
+// CHECK-FIXES: {{^namespace a { class A {}; }$}}
+// CHECK-FIXES-NOT: namespace
+// CHECK-FIXES: {{^namespace c {}$}}
+// FIXME: cleanupAroundReplacements leaves whitespace. Otherwise we could just
+// check the next line.
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/config-files.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/config-files.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/config-files.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/config-files.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,12 @@
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-BASE
+// CHECK-BASE: Checks: {{.*}}from-parent
+// CHECK-BASE: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/1/- -- | FileCheck %s -check-prefix=CHECK-CHILD1
+// CHECK-CHILD1: Checks: {{.*}}from-child1
+// CHECK-CHILD1: HeaderFilterRegex: child1
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
+// CHECK-CHILD2: Checks: {{.*}}from-parent
+// CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
+// CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
+// CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/custom-diagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/custom-diagnostics.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/custom-diagnostics.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/custom-diagnostics.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,27 @@
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' %s -- | count 0
+//
+// Enable warnings using -config:
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
+// RUN: -config='{ExtraArgs: ["-Wshadow","-Wno-unused-variable"], ExtraArgsBefore: ["-Wno-shadow","-Wfloat-conversion","-Wunused-variable"]}' %s -- \
+// RUN: | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+//
+// ... -extra-arg:
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
+// RUN: -extra-arg=-Wshadow -extra-arg=-Wno-unused-variable \
+// RUN: -extra-arg-before=-Wno-shadow -extra-arg-before=-Wfloat-conversion \
+// RUN: -extra-arg-before=-Wunused-variable %s -- \
+// RUN: | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+//
+// ... a combination of -config and -extra-arg(-before):
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-shadow,clang-diagnostic-float-conversion' \
+// RUN: -config='{ExtraArgs: ["-Wno-unused-variable"], ExtraArgsBefore: ["-Wno-shadow","-Wfloat-conversion"]}' \
+// RUN: -extra-arg=-Wshadow -extra-arg-before=-Wunused-variable %s -- \
+// RUN: | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+
+void f(float x) {
+ int a;
+ { int a; }
+ // CHECK: :[[@LINE-1]]:9: warning: declaration shadows a local variable [clang-diagnostic-shadow]
+ int b = x;
+ // CHECK: :[[@LINE-1]]:11: warning: implicit conversion turns floating-point number into integer: 'float' to 'int' [clang-diagnostic-float-conversion]
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/deduplication.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/deduplication.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/deduplication.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/deduplication.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,10 @@
+// RUN: %check_clang_tidy %s google-explicit-constructor %t
+
+template<typename T>
+struct A { A(T); };
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: single-argument constructors must be marked explicit
+
+void f() {
+ A<int> a(0);
+ A<double> b(0);
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/diagnostic.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/diagnostic.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/diagnostic.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,52 @@
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -DCOMPILATION_ERROR | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
+//
+// Now repeat the tests and ensure no other errors appear on stderr:
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %s -- -DCOMPILATION_ERROR 2>&1 | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
+//
+// Now create a directory with a compilation database file and ensure we don't
+// use it after failing to parse commands from the command line:
+//
+// RUN: mkdir -p %T/diagnostics/
+// RUN: echo '[{"directory": "%/T/diagnostics/","command": "clang++ -fan-option-from-compilation-database -c %/T/diagnostics/input.cpp", "file": "%/T/diagnostics/input.cpp"}]' > %T/diagnostics/compile_commands.json
+// RUN: cat %s > %T/diagnostics/input.cpp
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/nonexistent.cpp -- 2>&1 | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %T/diagnostics/input.cpp -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %T/diagnostics/input.cpp -- -DMACRO_FROM_COMMAND_LINE 2>&1 | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %T/diagnostics/input.cpp 2>&1 | FileCheck -check-prefix=CHECK5 -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy -checks='-*,modernize-use-override' %T/diagnostics/input.cpp -- -DCOMPILATION_ERROR 2>&1 | FileCheck -check-prefix=CHECK6 -implicit-check-not='{{warning:|error:}}' %s
+
+// CHECK1: error: no input files [clang-diagnostic-error]
+// CHECK1: error: no such file or directory: '{{.*}}nonexistent.cpp' [clang-diagnostic-error]
+// CHECK1: error: unable to handle compilation{{.*}} [clang-diagnostic-error]
+// CHECK2: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]
+// CHECK3: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]
+// CHECK5: error: unknown argument: '-fan-option-from-compilation-database' [clang-diagnostic-error]
+
+// CHECK2: :[[@LINE+3]]:9: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conversion]
+// CHECK3: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' changes value
+// CHECK5: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' changes value
+int a = 1.5;
+
+// CHECK2: :[[@LINE+3]]:11: warning: single-argument constructors must be marked explicit
+// CHECK3: :[[@LINE+2]]:11: warning: single-argument constructors must be marked explicit
+// CHECK5: :[[@LINE+1]]:11: warning: single-argument constructors must be marked explicit
+class A { A(int) {} };
+
+#define MACRO_FROM_COMMAND_LINE
+// CHECK4: :[[@LINE-1]]:9: warning: 'MACRO_FROM_COMMAND_LINE' macro redefined
+
+#ifdef COMPILATION_ERROR
+void f(int a) {
+ &(a + 1);
+ // CHECK6: :[[@LINE-1]]:3: error: cannot take the address of an rvalue of type 'int' [clang-diagnostic-error]
+}
+#endif
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/duplicate-reports.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/duplicate-reports.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/duplicate-reports.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/duplicate-reports.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,15 @@
+// RUN: %check_clang_tidy %s cert-err09-cpp,cert-err61-cpp %t -- -- -fexceptions
+
+void alwaysThrows() {
+ int ex = 42;
+ // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead [cert-err09-cpp]
+ // CHECK-MESSAGES: warning: throw expression should throw anonymous temporary values instead [cert-err61-cpp]
+ throw ex;
+}
+
+void doTheJob() {
+ try {
+ alwaysThrows();
+ } catch (int&) {
+ }
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/empty-database.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/empty-database.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/empty-database.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/empty-database.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,5 @@
+// UNSUPPORTED: system-windows
+
+// RUN: not clang-tidy -p %S/Inputs/empty-database %s 2>&1 | FileCheck %s
+
+// CHECK: LLVM ERROR: Cannot chdir into ""!
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/enable-alpha-checks.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/enable-alpha-checks.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/enable-alpha-checks.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/enable-alpha-checks.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,8 @@
+// REQUIRES: static-analyzer
+
+// Check if '-allow-enabling-analyzer-alpha-checkers' is visible for users.
+// RUN: clang-tidy -help | not grep 'allow-enabling-analyzer-alpha-checkers'
+
+// Check if '-allow-enabling-analyzer-alpha-checkers' enables alpha checks.
+// RUN: clang-tidy -checks=* -list-checks | not grep 'clang-analyzer-alpha'
+// RUN: clang-tidy -checks=* -list-checks -allow-enabling-analyzer-alpha-checkers | grep 'clang-analyzer-alpha'
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/expand-modular-headers-ppcallbacks.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,57 @@
+// Sanity-check. Run without modules:
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp %S/Inputs/expand-modular-headers-ppcallbacks/* %t/
+// RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t/without-modules -- \
+// RUN: -config="CheckOptions: [{ \
+// RUN: key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
+// RUN: -header-filter=.* \
+// RUN: -- -I %t/
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp %S/Inputs/expand-modular-headers-ppcallbacks/* %t/
+// RUN: %check_clang_tidy -std=c++17 %s readability-identifier-naming %t/without-modules -- \
+// RUN: -config="CheckOptions: [{ \
+// RUN: key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
+// RUN: -header-filter=.* \
+// RUN: -- -I %t/
+//
+// Run clang-tidy on a file with modular includes:
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp %S/Inputs/expand-modular-headers-ppcallbacks/* %t/
+// RUN: %check_clang_tidy -std=c++11 %s readability-identifier-naming %t/with-modules -- \
+// RUN: -config="CheckOptions: [{ \
+// RUN: key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
+// RUN: -header-filter=.* \
+// RUN: -- -I %t/ \
+// RUN: -fmodules -fimplicit-modules -fno-implicit-module-maps \
+// RUN: -fmodule-map-file=%t/module.modulemap \
+// RUN: -fmodules-cache-path=%t/module-cache/
+//
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: cp %S/Inputs/expand-modular-headers-ppcallbacks/* %t/
+// RUN: %check_clang_tidy -std=c++17 %s readability-identifier-naming %t/with-modules -- \
+// RUN: -config="CheckOptions: [{ \
+// RUN: key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }]" \
+// RUN: -header-filter=.* \
+// RUN: -- -I %t/ \
+// RUN: -fmodules -fimplicit-modules -fno-implicit-module-maps \
+// RUN: -fmodule-map-file=%t/module.modulemap \
+// RUN: -fmodules-cache-path=%t/module-cache/
+// FIXME: Make the test work in all language modes.
+#include "c.h"
+
+// CHECK-MESSAGES: a.h:1:9: warning: invalid case style for macro definition 'a' [readability-identifier-naming]
+// CHECK-MESSAGES: a.h:1:9: note: FIX-IT applied suggested code changes
+// CHECK-MESSAGES: b.h:2:9: warning: invalid case style for macro definition 'b'
+// CHECK-MESSAGES: b.h:2:9: note: FIX-IT applied suggested code changes
+// CHECK-MESSAGES: c.h:2:9: warning: invalid case style for macro definition 'c'
+// CHECK-MESSAGES: c.h:2:9: note: FIX-IT applied suggested code changes
+
+#define m
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for macro definition 'm'
+// CHECK-MESSAGES: :[[@LINE-2]]:9: note: FIX-IT applied suggested code changes
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/explain-checks.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/explain-checks.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/explain-checks.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/explain-checks.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,12 @@
+// RUN: clang-tidy -checks=-*,modernize-use-nullptr -explain-config | FileCheck --check-prefix=CHECK-MESSAGE1 %s
+// RUN: clang-tidy -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE2 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-use-nullptr'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE3 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,-modernize-use-nullptr'}" %S/Inputs/explain-config/a.cc -explain-config -- | FileCheck --check-prefix=CHECK-MESSAGE4 %s
+// RUN: clang-tidy -checks=modernize-use-nullptr -config="{Checks: '-*,modernize-*'}" -explain-config | FileCheck --check-prefix=CHECK-MESSAGE5 %s
+// RUN: clang-tidy -explain-config %S/Inputs/explain-config/a.cc -- | grep "'modernize-use-nullptr' is enabled in the .*[/\\]Inputs[/\\]explain-config[/\\].clang-tidy."
+
+// CHECK-MESSAGE1: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE2: 'modernize-use-nullptr' is enabled in the command-line option '-config'.
+// CHECK-MESSAGE3: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE4: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
+// CHECK-MESSAGE5: 'modernize-use-nullptr' is enabled in the command-line option '-checks'.
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-diagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-diagnostics.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-diagnostics.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-diagnostics.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,45 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t-input.cpp
+// RUN: clang-tidy %t-input.cpp -checks='-*,google-explicit-constructor,clang-diagnostic-missing-prototypes' -export-fixes=%t.yaml -- -Wmissing-prototypes > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s -implicit-check-not='{{warning|error|note}}:'
+// RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
+#define X(n) void n ## n() {}
+X(f)
+
+// CHECK-MESSAGES: -input.cpp:2:1: warning: no previous prototype for function 'ff' [clang-diagnostic-missing-prototypes]
+// CHECK-MESSAGES: -input.cpp:1:19: note: expanded from macro 'X'
+// CHECK-MESSAGES: {{^}}note: expanded from here{{$}}
+// CHECK-MESSAGES: -input.cpp:2:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
+// CHECK-MESSAGES: -input.cpp:1:14: note: expanded from macro 'X'
+
+// CHECK-YAML: ---
+// CHECK-YAML-NEXT: MainSourceFile: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: Diagnostics:
+// CHECK-YAML-NEXT: - DiagnosticName: clang-diagnostic-missing-prototypes
+// CHECK-YAML-NEXT: DiagnosticMessage:
+// CHECK-YAML-NEXT: Message: 'no previous prototype for function
+// ''ff'''
+// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: FileOffset: 30
+// CHECK-YAML-NEXT: Replacements: []
+// CHECK-YAML-NEXT: Notes:
+// CHECK-YAML-NEXT: - Message: 'expanded from macro ''X'''
+// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: FileOffset: 18
+// CHECK-YAML-NEXT: Replacements: []
+// CHECK-YAML-NEXT: - Message: expanded from here
+// CHECK-YAML-NEXT: FilePath: ''
+// CHECK-YAML-NEXT: FileOffset: 0
+// CHECK-YAML-NEXT: Replacements: []
+// CHECK-YAML-NEXT: - Message: 'declare ''static'' if the function is not intended to be used outside of this translation unit'
+// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: FileOffset: 30
+// CHECK-YAML-NEXT: Replacements:
+// CHECK-YAML-NEXT: - FilePath: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: Offset: 30
+// CHECK-YAML-NEXT: Length: 0
+// CHECK-YAML-NEXT: ReplacementText: 'static '
+// CHECK-YAML-NEXT: - Message: 'expanded from macro ''X'''
+// CHECK-YAML-NEXT: FilePath: '{{.*}}-input.cpp'
+// CHECK-YAML-NEXT: FileOffset: 13
+// CHECK-YAML-NEXT: Replacements: []
+// CHECK-YAML-NEXT: ...
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-relpath.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-relpath.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-relpath.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/export-relpath.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,19 @@
+// RUN: rm -rf %T/clang-tidy/export-relpath
+// RUN: mkdir -p %T/clang-tidy/export-relpath/subdir
+// RUN: cp %s %T/clang-tidy/export-relpath/subdir/source.cpp
+// RUN: echo '[{ "directory": "%/T/clang-tidy/export-relpath/subdir", "command": "clang++ source.cpp", "file": "%/T/clang-tidy/export-relpath/subdir/source.cpp"}]' > %T/clang-tidy/export-relpath/subdir/compile_commands.json
+//
+// Check that running clang-tidy in './subdir' and storing results
+// in './fixes.yaml' works as expected.
+//
+// RUN: cd %T/clang-tidy/export-relpath
+// RUN: clang-tidy -p subdir subdir/source.cpp -checks='-*,google-explicit-constructor,llvm-namespace-comment' -export-fixes=./fixes.yaml
+// RUN: FileCheck -input-file=%T/clang-tidy/export-relpath/fixes.yaml -check-prefix=CHECK-YAML %s
+
+namespace i {
+void f(); // So that the namespace isn't empty.
+}
+// CHECK-YAML: ReplacementText: ' // namespace i'
+
+class A { A(int i); };
+// CHECK-YAML: ReplacementText: 'explicit '
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/extra-args.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/extra-args.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/extra-args.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/extra-args.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,7 @@
+// RUN: clang-tidy -checks='-*,modernize-use-override' \
+// RUN: -config='{ExtraArgs: ["-DTEST4"], ExtraArgsBefore: ["-DTEST1"]}' \
+// RUN: -extra-arg=-DTEST3 -extra-arg-before=-DTEST2 %s -- -v 2>&1 \
+// RUN: | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+
+// CHECK: {{^}}clang Invocation:{{$}}
+// CHECK-NEXT: {{"-D" "TEST1" .*"-D" "TEST2" .*"-D" "TEST3" .*"-D" "TEST4"}}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter-symlinks.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter-symlinks.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter-symlinks.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter-symlinks.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,19 @@
+// REQUIRES: shell
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/dir1/dir2
+// RUN: echo 'class A { A(int); };' > %t/dir1/header.h
+// RUN: ln -s %t/dir1/header.h %t/dir1/header_alias.h
+//
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='dir1/dir2/\.\./header_alias\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='dir1/dir2/\.\./header_alias\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header_alias\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header_alias\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER_ALIAS %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header\.h' %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header\.h' -quiet %s -- -I %t 2>&1 | FileCheck --check-prefix=CHECK_HEADER %s
+
+// Check that `-header-filter` operates on the same file paths as paths in
+// diagnostics printed by ClangTidy.
+#include "dir1/dir2/../header_alias.h"
+// CHECK_HEADER_ALIAS: dir1/dir2/../header_alias.h:1:11: warning: single-argument constructors
+// CHECK_HEADER-NOT: warning:
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/file-filter.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,73 @@
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK2-QUIET %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header2\.h' %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK3 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='header2\.h' -quiet %s -- -I %S/Inputs/file-filter -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK3-QUIET %s
+// FIXME: "-I %S/Inputs/file-filter/system/.." must be redundant.
+// On Win32, file-filter/system\system-header1.h precedes
+// file-filter\header*.h due to code order between '/' and '\\'.
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4 %s
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -header-filter='.*' -system-headers -quiet %s -- -I %S/Inputs/file-filter/system/.. -isystem %S/Inputs/file-filter/system 2>&1 | FileCheck --check-prefix=CHECK4-QUIET %s
+
+#include "header1.h"
+// CHECK-NOT: warning:
+// CHECK-QUIET-NOT: warning:
+// CHECK2: header1.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK2-QUIET: header1.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK3-NOT: warning:
+// CHECK3-QUIET-NOT: warning:
+// CHECK4: header1.h:1:12: warning: single-argument constructors
+// CHECK4-QUIET: header1.h:1:12: warning: single-argument constructors
+
+#include "header2.h"
+// CHECK-NOT: warning:
+// CHECK-QUIET-NOT: warning:
+// CHECK2: header2.h:1:12: warning: single-argument constructors
+// CHECK2-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK3: header2.h:1:12: warning: single-argument constructors
+// CHECK3-QUIET: header2.h:1:12: warning: single-argument constructors
+// CHECK4: header2.h:1:12: warning: single-argument constructors
+// CHECK4-QUIET: header2.h:1:12: warning: single-argument constructors
+
+#include <system-header.h>
+// CHECK-NOT: warning:
+// CHECK-QUIET-NOT: warning:
+// CHECK2-NOT: warning:
+// CHECK2-QUIET-NOT: warning:
+// CHECK3-NOT: warning:
+// CHECK3-QUIET-NOT: warning:
+// CHECK4: system-header.h:1:12: warning: single-argument constructors
+// CHECK4-QUIET: system-header.h:1:12: warning: single-argument constructors
+
+class A { A(int); };
+// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors
+// CHECK-QUIET: :[[@LINE-2]]:11: warning: single-argument constructors
+// CHECK2: :[[@LINE-3]]:11: warning: single-argument constructors
+// CHECK2-QUIET: :[[@LINE-4]]:11: warning: single-argument constructors
+// CHECK3: :[[@LINE-5]]:11: warning: single-argument constructors
+// CHECK3-QUIET: :[[@LINE-6]]:11: warning: single-argument constructors
+// CHECK4: :[[@LINE-7]]:11: warning: single-argument constructors
+// CHECK4-QUIET: :[[@LINE-8]]:11: warning: single-argument constructors
+
+// CHECK-NOT: warning:
+// CHECK-QUIET-NOT: warning:
+// CHECK2-NOT: warning:
+// CHECK2-QUIET-NOT: warning:
+// CHECK3-NOT: warning:
+// CHECK3-QUIET-NOT: warning:
+// CHECK4-NOT: warning:
+// CHECK4-QUIET-NOT: warning:
+
+// CHECK: Suppressed 3 warnings (3 in non-user code)
+// CHECK: Use -header-filter=.* to display errors from all non-system headers.
+// CHECK-QUIET-NOT: Suppressed
+// CHECK2: Suppressed 1 warnings (1 in non-user code)
+// CHECK2: Use -header-filter=.* {{.*}}
+// CHECK2-QUIET-NOT: Suppressed
+// CHECK3: Suppressed 2 warnings (2 in non-user code)
+// CHECK3: Use -header-filter=.* {{.*}}
+// CHECK3-QUIET-NOT: Suppressed
+// CHECK4-NOT: Suppressed {{.*}} warnings
+// CHECK4-NOT: Use -header-filter=.* {{.*}}
+// CHECK4-QUIET-NOT: Suppressed
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix-errors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix-errors.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix-errors.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix-errors.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,15 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: not clang-tidy %t.cpp -checks='-*,google-explicit-constructor' -fix -- > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.cpp -check-prefix=CHECK-FIX %s
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,google-explicit-constructor' -fix-errors -- > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.cpp -check-prefix=CHECK-FIX2 %s
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES2 %s
+
+class A { A(int i); }
+// CHECK-FIX: class A { A(int i); }{{$}}
+// CHECK-MESSAGES: Fixes have NOT been applied.
+// CHECK-FIX2: class A { explicit A(int i); };
+// CHECK-MESSAGES2: note: FIX-IT applied suggested code changes
+// CHECK-MESSAGES2: clang-tidy applied 2 of 2 suggested fixes.
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/fix.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,18 @@
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,google-explicit-constructor,llvm-namespace-comment' -fix -export-fixes=%t.yaml -- > %t.msg 2>&1
+// RUN: FileCheck -input-file=%t.cpp %s
+// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s
+// RUN: FileCheck -input-file=%t.yaml -check-prefix=CHECK-YAML %s
+
+namespace i {
+void f(); // So that the namespace isn't empty.
+}
+// CHECK: } // namespace i
+// CHECK-MESSAGES: note: FIX-IT applied suggested code changes
+// CHECK-YAML: ReplacementText: ' // namespace i'
+
+class A { A(int i); };
+// CHECK: class A { explicit A(int i); };
+// CHECK-MESSAGES: note: FIX-IT applied suggested code changes
+// CHECK-MESSAGES: clang-tidy applied 2 of 2 suggested fixes.
+// CHECK-YAML: ReplacementText: 'explicit '
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/line-filter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/line-filter.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/line-filter.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/line-filter.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,27 @@
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='header[12]\.h$' %s -- -I %S/Inputs/line-filter 2>&1 | FileCheck %s
+
+#include "header1.h"
+// CHECK-NOT: header1.h:{{.*}} warning
+// CHECK: header1.h:1:12: warning: single-argument constructors must be marked explicit
+// CHECK: header1.h:2:12: warning: single-argument constructors {{.*}}
+// CHECK-NOT: header1.h:{{.*}} warning
+
+#include "header2.h"
+// CHECK: header2.h:1:12: warning: single-argument constructors {{.*}}
+// CHECK: header2.h:2:12: warning: single-argument constructors {{.*}}
+// CHECK: header2.h:3:12: warning: single-argument constructors {{.*}}
+// CHECK-NOT: header2.h:{{.*}} warning
+
+#include "header3.h"
+// CHECK-NOT: header3.h:{{.*}} warning
+
+class A { A(int); };
+// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors {{.*}}
+class B { B(int); };
+// CHECK-NOT: :[[@LINE-1]]:{{.*}} warning
+class C { C(int); };
+// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors {{.*}}
+
+// CHECK-NOT: warning:
+
+// CHECK: Suppressed 3 warnings (1 in non-user code, 2 due to line filter)
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/list-checks.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/list-checks.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/list-checks.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/list-checks.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,4 @@
+// RUN: mkdir -p %T/clang-tidy/list-checks/
+// RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
+// RUN: cd %T/clang-tidy/list-checks
+// RUN: clang-tidy -list-checks | grep "^ *google-"
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/macros.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/macros.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/macros.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,7 @@
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' %s -- | FileCheck %s
+
+#define Q(name) class name { name(int i); }
+
+Q(A);
+// CHECK: :[[@LINE-1]]:3: warning: single-argument constructors must be marked explicit
+// CHECK: :3:30: note: expanded from macro 'Q'
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint-plugin.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint-plugin.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint-plugin.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,50 @@
+// REQUIRES: static-analyzer
+// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult' -Wunused-variable -I%S/Inputs/nolint 2>&1 | FileCheck %s
+
+#include "trigger_warning.h"
+void I(int& Out) {
+ int In;
+ A1(In, Out);
+}
+// CHECK-NOT: trigger_warning.h:{{.*}} warning
+// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
+
+class A { A(int i); };
+// CHECK-DAG: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class B { B(int i); }; // NOLINT
+
+class C { C(int i); }; // NOLINT(for-some-other-check)
+// CHECK-DAG: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
+
+class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
+
+void f() {
+ int i;
+// CHECK-DAG: :[[@LINE-1]]:7: warning: unused variable 'i' [-Wunused-variable]
+// 31:7: warning: unused variable 'i' [-Wunused-variable]
+// int j; // NOLINT
+// int k; // NOLINT(clang-diagnostic-unused-variable)
+}
+
+#define MACRO(X) class X { X(int i); };
+MACRO(D)
+// CHECK-DAG: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
+MACRO(E) // NOLINT
+
+#define MACRO_NOARG class F { F(int i); };
+MACRO_NOARG // NOLINT
+
+#define MACRO_NOLINT class G { G(int i); }; // NOLINT
+MACRO_NOLINT
+
+#define DOUBLE_MACRO MACRO(H) // NOLINT
+DOUBLE_MACRO
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolint.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,51 @@
+// REQUIRES: static-analyzer
+// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
+
+#include "trigger_warning.h"
+void I(int& Out) {
+ int In;
+ A1(In, Out);
+}
+// CHECK-MESSAGES-NOT: trigger_warning.h:{{.*}} warning
+// CHECK-MESSAGES-NOT: :[[@LINE-4]]:{{.*}} note
+
+class A { A(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class B { B(int i); }; // NOLINT
+
+class C { C(int i); }; // NOLINT(for-some-other-check)
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+class C1 { C1(int i); }; // NOLINT(*)
+
+class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
+
+class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
+
+class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
+
+class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
+
+void f() {
+ int i;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: unused variable 'i' [clang-diagnostic-unused-variable]
+ int j; // NOLINT
+ int k; // NOLINT(clang-diagnostic-unused-variable)
+}
+
+#define MACRO(X) class X { X(int i); };
+MACRO(D)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
+MACRO(E) // NOLINT
+
+#define MACRO_NOARG class F { F(int i); };
+MACRO_NOARG // NOLINT
+
+#define MACRO_NOLINT class G { G(int i); }; // NOLINT
+MACRO_NOLINT
+
+#define DOUBLE_MACRO MACRO(H) // NOLINT
+DOUBLE_MACRO
+
+// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline-plugin.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,48 @@
+// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,google-explicit-constructor' 2>&1 | FileCheck %s
+
+class A { A(int i); };
+// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE
+class B { B(int i); };
+
+// NOLINTNEXTLINE(for-some-other-check)
+class C { C(int i); };
+// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-check, google-explicit-constructor)
+class C4 { C4(int i); };
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };
+
+
+// NOLINTNEXTLINE
+
+class D { D(int i); };
+// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE
+//
+class E { E(int i); };
+// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+#define MACRO(X) class X { X(int i); };
+MACRO(F)
+// CHECK: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
+// NOLINTNEXTLINE
+MACRO(G)
+
+#define MACRO_NOARG class H { H(int i); };
+// NOLINTNEXTLINE
+MACRO_NOARG
+
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/nolintnextline.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,49 @@
+class A { A(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE
+class B { B(int i); };
+
+// NOLINTNEXTLINE(for-some-other-check)
+class C { C(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE(*)
+class C1 { C1(int i); };
+
+// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
+class C2 { C2(int i); };
+
+// NOLINTNEXTLINE(google-explicit-constructor)
+class C3 { C3(int i); };
+
+// NOLINTNEXTLINE(some-check, google-explicit-constructor)
+class C4 { C4(int i); };
+
+// NOLINTNEXTLINE without-brackets-skip-all, another-check
+class C5 { C5(int i); };
+
+
+// NOLINTNEXTLINE
+
+class D { D(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+// NOLINTNEXTLINE
+//
+class E { E(int i); };
+// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
+
+#define MACRO(X) class X { X(int i); };
+MACRO(F)
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
+// NOLINTNEXTLINE
+MACRO(G)
+
+#define MACRO_NOARG class H { H(int i); };
+// NOLINTNEXTLINE
+MACRO_NOARG
+
+// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
+
+// RUN: %check_clang_tidy %s google-explicit-constructor %t --
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/nonstandard-file-extension.test
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/nonstandard-file-extension.test?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/nonstandard-file-extension.test (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/nonstandard-file-extension.test Fri Oct 11 05:05:42 2019
@@ -0,0 +1,6 @@
+// RUN: %check_clang_tidy -assume-filename=const-cast.cpp %s cppcoreguidelines-pro-type-const-cast %t
+
+const int *i;
+int *j;
+void f() { j = const_cast<int *>(i); }
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: do not use const_cast [cppcoreguidelines-pro-type-const-cast]
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-arc-and-properties.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-arc-and-properties.m?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-arc-and-properties.m (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-arc-and-properties.m Fri Oct 11 05:05:42 2019
@@ -0,0 +1,21 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t
+
+// This test checks if Objective-C 2.0 (@properties) and
+// Automatic Reference Counting (ARC) are enabled for .m files
+// checked via check_clang_tidy.py.
+
+#if !__has_feature(objc_arc)
+#error Objective-C ARC not enabled as expected
+#endif
+
+ at interface Foo
+ at property (nonatomic, assign) int shouldDoStuff;
+- (void)nop;
+ at end
+
+void fail(Foo *f)
+{
+ if(f.shouldDoStuff); [f nop];
+ // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
+ // CHECK-FIXES: if(f.shouldDoStuff) [f nop];
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-no-arc-or-properties.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-no-arc-or-properties.m?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-no-arc-or-properties.m (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/objc-no-arc-or-properties.m Fri Oct 11 05:05:42 2019
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy -std=c99 %s bugprone-suspicious-semicolon %t -- -- -fno-objc-arc -fobjc-abi-version=1
+
+// This test ensures check_clang_tidy.py allows disabling Objective-C ARC and
+// Objective-C 2.0 via passing arguments after -- on the command line.
+//
+// (We could include a test which doesn't pass any arguments after --
+// to check if ARC and ObjC 2.0 are disabled by default, but that test
+// could change behavior based on the default Objective-C runtime for
+// the platform, which would make this test flaky.)
+
+#if __has_feature(objc_arc)
+#error Objective-C ARC unexpectedly enabled even with -fno-objc-arc
+#endif
+
+#ifdef __OBJC2__
+#error Objective-C 2.0 unexpectedly enabled even with -fobjc-abi-version=1
+#endif
+
+ at interface Foo
+- (int)shouldDoStuff;
+- (void)nop;
+ at end
+
+void fail(Foo *f)
+{
+ if([f shouldDoStuff]); [f nop];
+ // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
+ // CHECK-FIXES: if([f shouldDoStuff]) [f nop];
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/overlapping.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/overlapping.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/overlapping.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/overlapping.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,10 @@
+// RUN: clang-tidy -checks=-*,llvm-include-order -header-filter=.* %s \
+// RUN: -- -isystem %S/Inputs/Headers -I %S/Inputs/overlapping | \
+// RUN: not grep "note: this fix will not be applied because it overlaps with another fix"
+
+#include <s.h>
+#include "o.h"
+
+// Test that clang-tidy takes into account in which file we are doing the
+// replacements to determine if they overlap or not. In the file "o.h" there is
+// a similar error at the same file offset, but they do not overlap.
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/pr37091.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/pr37091.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/pr37091.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/pr37091.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,10 @@
+// REQUIRES: shell
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+
+// This is a reproducer for PR37091.
+//
+// Verify that no temporary files are left behind by the clang-tidy invocation.
+
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t clang-tidy %s -- --target=mips64
+// RUN: rmdir %t
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/read_file_config.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/read_file_config.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/read_file_config.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/read_file_config.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,13 @@
+// REQUIRES: static-analyzer
+// RUN: mkdir -p %T/read-file-config/
+// RUN: cp %s %T/read-file-config/test.cpp
+// RUN: echo 'Checks: "-*,modernize-use-nullptr"' > %T/read-file-config/.clang-tidy
+// RUN: echo '[{"command": "cc -c -o test.o test.cpp", "directory": "%/T/read-file-config", "file": "%/T/read-file-config/test.cpp"}]' > %T/read-file-config/compile_commands.json
+// RUN: clang-tidy %T/read-file-config/test.cpp | not grep "warning: .*\[clang-analyzer-deadcode.DeadStores\]$"
+// RUN: clang-tidy -checks="-*,clang-analyzer-*" %T/read-file-config/test.cpp | grep "warning: .*\[clang-analyzer-deadcode.DeadStores\]$"
+
+void f() {
+ int x;
+ x = 1;
+ x = 2;
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/run-clang-tidy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/run-clang-tidy.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/run-clang-tidy.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/run-clang-tidy.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,18 @@
+// RUN: %run_clang_tidy --help
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: echo "[{\"directory\":\".\",\"command\":\"clang++ -c %/t/test.cpp\",\"file\":\"%/t/test.cpp\"}]" | sed -e 's/\\/\\\\/g' > %t/compile_commands.json
+// RUN: echo "Checks: '-*,modernize-use-auto'" > %t/.clang-tidy
+// RUN: echo "WarningsAsErrors: '*'" >> %t/.clang-tidy
+// RUN: echo "CheckOptions:" >> %t/.clang-tidy
+// RUN: echo " - key: modernize-use-auto.MinTypeNameLength" >> %t/.clang-tidy
+// RUN: echo " value: '0'" >> %t/.clang-tidy
+// RUN: cp "%s" "%t/test.cpp"
+// RUN: cd "%t"
+// RUN: not %run_clang_tidy "%t/test.cpp"
+
+int main()
+{
+ int* x = new int();
+ delete x;
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/select-checks.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/select-checks.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/select-checks.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/select-checks.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,11 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-*' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' %s
+// RUN: not clang-tidy %s -checks='-*,an-unknown-check' -- 2>&1 | FileCheck -implicit-check-not='{{warning:|error:}}' -check-prefix=CHECK2 %s
+
+// CHECK2: Error: no checks enabled.
+
+namespace i {
+}
+// CHECK: :[[@LINE-1]]:1: warning: namespace 'i' not terminated with a closing comment [llvm-namespace-comment]
+
+// Expect no warnings from the google-explicit-constructor check:
+class A { A(int i); };
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/serialize-diagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/serialize-diagnostics.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/serialize-diagnostics.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/serialize-diagnostics.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,3 @@
+// RUN: not clang-tidy -checks=-*,llvm-namespace-comment %s -- -serialize-diagnostics %t | FileCheck %s
+// CHECK: :[[@LINE+1]]:12: error: expected ';' after struct [clang-diagnostic-error]
+struct A {}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer-config.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer-config.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer-config.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer-config.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,20 @@
+// REQUIRES: static-analyzer
+// RUN: clang-tidy %s -checks='-*,clang-analyzer-unix.Malloc' -config='{CheckOptions: [{ key: "clang-analyzer-unix.DynamicMemoryModeling:Optimistic", value: true}]}' -- | FileCheck %s
+typedef __typeof(sizeof(int)) size_t;
+void *malloc(size_t);
+void free(void *);
+void __attribute((ownership_returns(malloc))) *my_malloc(size_t);
+void __attribute((ownership_takes(malloc, 1))) my_free(void *);
+
+void f1() {
+ void *p = malloc(12);
+ return;
+ // CHECK: warning: Potential leak of memory pointed to by 'p' [clang-analyzer-unix.Malloc]
+}
+
+void af2() {
+ void *p = my_malloc(12);
+ my_free(p);
+ free(p);
+ // CHECK: warning: Attempt to free released memory [clang-analyzer-unix.Malloc]
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/static-analyzer.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,18 @@
+// REQUIRES: static-analyzer
+// RUN: clang-tidy %s -checks='-*,clang-analyzer-*' -- | FileCheck %s
+extern void *malloc(unsigned long);
+extern void free(void *);
+
+void f() {
+ int *p = new int(42);
+ delete p;
+ delete p;
+ // CHECK: warning: Attempt to free released memory [clang-analyzer-cplusplus.NewDelete]
+}
+
+void g() {
+ void *q = malloc(132);
+ free(q);
+ free(q);
+ // CHECK: warning: Attempt to free released memory [clang-analyzer-unix.Malloc]
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/temporaries.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/temporaries.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/temporaries.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/temporaries.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,25 @@
+// REQUIRES: static-analyzer
+// RUN: clang-tidy -checks='-*,clang-analyzer-core.NullDereference' %s -- | FileCheck %s
+
+struct NoReturnDtor {
+ ~NoReturnDtor() __attribute__((noreturn));
+};
+
+extern bool check(const NoReturnDtor &);
+
+// CHECK-NOT: warning
+void testNullPointerDereferencePositive() {
+ int *value = 0;
+ // CHECK: [[@LINE+1]]:10: warning: Dereference of null pointer (loaded from variable 'value') [clang-analyzer-core.NullDereference]
+ *value = 1;
+}
+
+// CHECK-NOT: warning
+void testNullPointerDereference() {
+ int *value = 0;
+ if (check(NoReturnDtor())) {
+ // This unreachable code causes a warning if analysis of temporary
+ // destructors is not enabled.
+ *value = 1;
+ }
+}
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/validate-check-names.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/validate-check-names.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/validate-check-names.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/validate-check-names.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,2 @@
+// Check names may only contain alphanumeric characters, '-', '_', and '.'.
+// RUN: clang-tidy -checks=* -list-checks | grep '^ ' | cut -b5- | not grep -v '^[a-zA-Z0-9_.\-]\+$'
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/vfsoverlay.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/vfsoverlay.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/vfsoverlay.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/vfsoverlay.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,8 @@
+// RUN: sed -e "s:INPUT_DIR:%S/Inputs/vfsoverlay:g" -e "s:OUT_DIR:%t:g" %S/Inputs/vfsoverlay/vfsoverlay.yaml > %t.yaml
+// RUN: clang-tidy %s -checks='-*,modernize-use-nullptr' -vfsoverlay %t.yaml -- -I %t | FileCheck %s
+// REQUIRES: shell
+
+#include "not_real.h"
+
+X *ptr = 0;
+// CHECK: warning: use nullptr [modernize-use-nullptr]
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-diagnostics.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,18 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: -- -Wunused-variable 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-WARN -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: -warnings-as-errors='clang-diagnostic*' -- -Wunused-variable 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: -warnings-as-errors='clang-diagnostic*' -quiet -- -Wunused-variable 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
+
+void f() { int i; }
+// CHECK-WARN: warning: unused variable 'i' [clang-diagnostic-unused-variable]
+// CHECK-WERR: error: unused variable 'i' [clang-diagnostic-unused-variable,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: unused variable 'i' [clang-diagnostic-unused-variable,-warnings-as-errors]
+
+// CHECK-WARN-NOT: treated as
+// CHECK-WERR: 1 warning treated as error
+// CHECK-WERR-QUIET-NOT: treated as
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-plural.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-plural.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-plural.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors-plural.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,24 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' -- 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-WARN -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: -warnings-as-errors='llvm-namespace-comment' -- 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment,clang-diagnostic*' \
+// RUN: -warnings-as-errors='llvm-namespace-comment' -quiet -- 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
+
+namespace j {
+}
+// CHECK-WARN: warning: namespace 'j' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: namespace 'j' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+
+namespace k {
+}
+// CHECK-WARN: warning: namespace 'k' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: namespace 'k' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+
+// CHECK-WARN-NOT: treated as
+// CHECK-WERR: 2 warnings treated as errors
+// CHECK-WERR-QUIET-NOT: treated as
Added: clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors.cpp?rev=374540&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors.cpp (added)
+++ clang-tools-extra/trunk/test/clang-tidy/infrastructure/warnings-as-errors.cpp Fri Oct 11 05:05:42 2019
@@ -0,0 +1,13 @@
+// RUN: clang-tidy %s -checks='-*,llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WARN -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -warnings-as-errors='llvm-namespace-comment' -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR -implicit-check-not='{{warning|error}}:'
+// RUN: not clang-tidy %s -checks='-*,llvm-namespace-comment' -warnings-as-errors='llvm-namespace-comment' -quiet -- 2>&1 | FileCheck %s --check-prefix=CHECK-WERR-QUIET -implicit-check-not='{{warning|error}}:'
+
+namespace i {
+}
+// CHECK-WARN: warning: namespace 'i' not terminated with a closing comment [llvm-namespace-comment]
+// CHECK-WERR: error: namespace 'i' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+// CHECK-WERR-QUIET: error: namespace 'i' not terminated with a closing comment [llvm-namespace-comment,-warnings-as-errors]
+
+// CHECK-WARN-NOT: treated as
+// CHECK-WERR: 1 warning treated as error
+// CHECK-WERR-QUIET-NOT: treated as
Removed: clang-tools-extra/trunk/test/clang-tidy/line-filter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/line-filter.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/line-filter.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/line-filter.cpp (removed)
@@ -1,27 +0,0 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' -line-filter='[{"name":"line-filter.cpp","lines":[[18,18],[22,22]]},{"name":"header1.h","lines":[[1,2]]},{"name":"header2.h"},{"name":"header3.h"}]' -header-filter='header[12]\.h$' %s -- -I %S/Inputs/line-filter 2>&1 | FileCheck %s
-
-#include "header1.h"
-// CHECK-NOT: header1.h:{{.*}} warning
-// CHECK: header1.h:1:12: warning: single-argument constructors must be marked explicit
-// CHECK: header1.h:2:12: warning: single-argument constructors {{.*}}
-// CHECK-NOT: header1.h:{{.*}} warning
-
-#include "header2.h"
-// CHECK: header2.h:1:12: warning: single-argument constructors {{.*}}
-// CHECK: header2.h:2:12: warning: single-argument constructors {{.*}}
-// CHECK: header2.h:3:12: warning: single-argument constructors {{.*}}
-// CHECK-NOT: header2.h:{{.*}} warning
-
-#include "header3.h"
-// CHECK-NOT: header3.h:{{.*}} warning
-
-class A { A(int); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors {{.*}}
-class B { B(int); };
-// CHECK-NOT: :[[@LINE-1]]:{{.*}} warning
-class C { C(int); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors {{.*}}
-
-// CHECK-NOT: warning:
-
-// CHECK: Suppressed 3 warnings (1 in non-user code, 2 due to line filter)
Removed: clang-tools-extra/trunk/test/clang-tidy/linuxkernel-must-check-errs.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/linuxkernel-must-check-errs.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/linuxkernel-must-check-errs.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/linuxkernel-must-check-errs.c (removed)
@@ -1,43 +0,0 @@
-// RUN: %check_clang_tidy %s linuxkernel-must-check-errs %t
-
-#define __must_check __attribute__((warn_unused_result))
-
-// Prototypes of the error functions.
-void * __must_check ERR_PTR(long error);
-long __must_check PTR_ERR(const void *ptr);
-int __must_check IS_ERR(const void *ptr);
-int __must_check IS_ERR_OR_NULL(const void *ptr);
-void * __must_check ERR_CAST(const void *ptr);
-int __must_check PTR_ERR_OR_ZERO(const void *ptr);
-
-void f() {
- ERR_PTR(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'ERR_PTR' is unused
- PTR_ERR((void *)0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'PTR_ERR' is unused
- IS_ERR((void *)0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'IS_ERR' is unused
- ERR_CAST((void *)0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'ERR_CAST' is unused
-out:
- PTR_ERR_OR_ZERO((void *)0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'PTR_ERR_OR_ZERO' is unused
-}
-
-void *f1() {
- return ERR_PTR(0);
-}
-
-long f2() {
- if (IS_ERR((void *)0)) {
- return PTR_ERR((void *)0);
- }
- return -1;
-}
-
-void f3() {
- f1();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'f1' is unused but represents an error value
- f2();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: result from function 'f2' is unused but represents an error value
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/list-checks.cpp (removed)
@@ -1,4 +0,0 @@
-// RUN: mkdir -p %T/clang-tidy/list-checks/
-// RUN: echo '{Checks: "-*,google-*"}' > %T/clang-tidy/.clang-tidy
-// RUN: cd %T/clang-tidy/list-checks
-// RUN: clang-tidy -list-checks | grep "^ *google-"
Removed: clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-include-order.cpp (removed)
@@ -1,42 +0,0 @@
-// RUN: %check_clang_tidy %s llvm-include-order %t -- -- -isystem %S/Inputs/Headers
-
-// CHECK-MESSAGES: [[@LINE+2]]:1: warning: #includes are not sorted properly
-#include "j.h"
-#include "gtest/foo.h"
-#include "i.h"
-#include <s.h>
-#include "llvm/a.h"
-#include "clang/b.h"
-#include "clang-c/c.h" // hi
-#include "llvm-c/d.h" // -c
-
-// CHECK-FIXES: #include "j.h"
-// CHECK-FIXES-NEXT: #include "i.h"
-// CHECK-FIXES-NEXT: #include "clang-c/c.h" // hi
-// CHECK-FIXES-NEXT: #include "clang/b.h"
-// CHECK-FIXES-NEXT: #include "llvm-c/d.h" // -c
-// CHECK-FIXES-NEXT: #include "llvm/a.h"
-// CHECK-FIXES-NEXT: #include "gtest/foo.h"
-// CHECK-FIXES-NEXT: #include <s.h>
-
-#include "b.h"
-#ifdef FOO
-#include "a.h"
-#endif
-
-// CHECK-FIXES: #include "b.h"
-// CHECK-FIXES-NEXT: #ifdef FOO
-// CHECK-FIXES-NEXT: #include "a.h"
-// CHECK-FIXES-NEXT: #endif
-
-// CHECK-MESSAGES: [[@LINE+1]]:1: warning: #includes are not sorted properly
-#include "b.h"
-#include "a.h"
-
-// CHECK-FIXES: #include "a.h"
-// CHECK-FIXES-NEXT: #include "b.h"
-
-// CHECK-MESSAGES-NOT: [[@LINE+1]]:1: warning: #includes are not sorted properly
-#include "cross-file-c.h"
-// This line number should correspond to the position of the #include in cross-file-c.h
-#include "cross-file-a.h"
Removed: clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-isa-or-dyn-cast-in-conditionals.cpp (removed)
@@ -1,132 +0,0 @@
-// RUN: %check_clang_tidy %s llvm-prefer-isa-or-dyn-cast-in-conditionals %t
-
-struct X;
-struct Y;
-struct Z {
- int foo();
- X *bar();
- X *cast(Y*);
- bool baz(Y*);
-};
-
-template <class X, class Y>
-bool isa(Y *);
-template <class X, class Y>
-X *cast(Y *);
-template <class X, class Y>
-X *dyn_cast(Y *);
-template <class X, class Y>
-X *dyn_cast_or_null(Y *);
-
-bool foo(Y *y, Z *z) {
- if (auto x = cast<X>(y))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: cast<> in conditional will assert rather than return a null pointer [llvm-prefer-isa-or-dyn-cast-in-conditionals]
- // CHECK-FIXES: if (auto x = dyn_cast<X>(y))
-
- while (auto x = cast<X>(y))
- break;
- // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: cast<> in conditional
- // CHECK-FIXES: while (auto x = dyn_cast<X>(y))
-
- if (cast<X>(y))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: cast<> in conditional
- // CHECK-FIXES: if (isa<X>(y))
-
- while (cast<X>(y))
- break;
- // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: cast<> in conditional
- // CHECK-FIXES: while (isa<X>(y))
-
- do {
- break;
- } while (cast<X>(y));
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: cast<> in conditional
- // CHECK-FIXES: while (isa<X>(y));
-
- if (dyn_cast<X>(y))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: return value from dyn_cast<> not used [llvm-prefer-isa-or-dyn-cast-in-conditionals]
- // CHECK-FIXES: if (isa<X>(y))
-
- while (dyn_cast<X>(y))
- break;
- // CHECK-MESSAGES: :[[@LINE-2]]:10: warning: return value from dyn_cast<> not used
- // CHECK-FIXES: while (isa<X>(y))
-
- do {
- break;
- } while (dyn_cast<X>(y));
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: return value from dyn_cast<> not used
- // CHECK-FIXES: while (isa<X>(y));
-
- if (y && isa<X>(y))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred over an explicit test for null followed by calling isa<> [llvm-prefer-isa-or-dyn-cast-in-conditionals]
- // CHECK-FIXES: if (isa_and_nonnull<X>(y))
-
- if (z->bar() && isa<Y>(z->bar()))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
- // CHECK-FIXES: if (isa_and_nonnull<Y>(z->bar()))
-
- if (z->bar() && cast<Y>(z->bar()))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
- // CHECK-FIXES: if (isa_and_nonnull<Y>(z->bar()))
-
- if (z->bar() && dyn_cast<Y>(z->bar()))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
- // CHECK-FIXES: if (isa_and_nonnull<Y>(z->bar()))
-
- if (z->bar() && dyn_cast_or_null<Y>(z->bar()))
- return true;
- // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
- // CHECK-FIXES: if (isa_and_nonnull<Y>(z->bar()))
-
- bool b = z->bar() && cast<Y>(z->bar());
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: isa_and_nonnull<> is preferred
- // CHECK-FIXES: bool b = isa_and_nonnull<Y>(z->bar());
-
- // These don't trigger a warning.
- if (auto x = cast<Z>(y)->foo())
- return true;
- if (auto x = z->cast(y))
- return true;
- while (auto x = cast<Z>(y)->foo())
- break;
- if (cast<Z>(y)->foo())
- return true;
- if (z->cast(y))
- return true;
- while (cast<Z>(y)->foo())
- break;
- if (y && cast<X>(z->bar()))
- return true;
- if (z && cast<Z>(y)->foo())
- return true;
- bool b2 = y && cast<X>(z);
- if(z->cast(y))
- return true;
- if (z->baz(cast<Y>(z)))
- return true;
-
-#define CAST(T, Obj) cast<T>(Obj)
-#define AUTO_VAR_CAST(X, Y, Z) auto X = cast<Y>(Z)
-#define ISA(T, Obj) isa<T>(Obj)
-#define ISA_OR_NULL(T, Obj) Obj &&isa<T>(Obj)
-
- // Macros don't trigger warning.
- if (auto x = CAST(X, y))
- return true;
- if (AUTO_VAR_CAST(x, X, z))
- return true;
- if (z->bar() && ISA(Y, z->bar()))
- return true;
- if (ISA_OR_NULL(Y, z->bar()))
- return true;
-
- return false;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned.cpp (removed)
@@ -1,143 +0,0 @@
-// RUN: %check_clang_tidy %s llvm-prefer-register-over-unsigned %t
-
-namespace llvm {
-class Register {
-public:
- operator unsigned();
-
- unsigned Reg;
-};
-
-// This class shouldn't trigger it despite the similarity.
-class RegisterLike {
-public:
- operator unsigned();
-
- unsigned Reg;
-};
-} // end namespace llvm
-
-llvm::Register getReg();
-llvm::RegisterLike getRegLike();
-
-void apply_1() {
- unsigned Reg1 = getReg();
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'Reg1' declared as 'unsigned int'; use 'llvm::Register' instead [llvm-prefer-register-over-unsigned]
- // CHECK-FIXES: apply_1()
- // CHECK-FIXES-NEXT: llvm::Register Reg1 = getReg();
-}
-
-void apply_2() {
- using namespace llvm;
- unsigned Reg2 = getReg();
- // FIXME: Function-scoped UsingDirectiveDecl's don't appear to be in the
- // DeclContext for the function so we can't elide the llvm:: in this
- // case. Fortunately, it doesn't actually occur in the LLVM code base.
- // CHECK-MESSAGES: :[[@LINE-4]]:12: warning: variable 'Reg2' declared as 'unsigned int'; use 'llvm::Register' instead [llvm-prefer-register-over-unsigned]
- // CHECK-FIXES: apply_2()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: llvm::Register Reg2 = getReg();
-}
-
-namespace llvm {
-void apply_3() {
- unsigned Reg3 = getReg();
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'Reg3' declared as 'unsigned int'; use 'Register' instead [llvm-prefer-register-over-unsigned]
- // CHECK-FIXES: apply_3()
- // CHECK-FIXES-NEXT: Register Reg3 = getReg();
-}
-} // end namespace llvm
-
-void done_1() {
- llvm::Register Reg1 = getReg();
- // CHECK-FIXES: done_1()
- // CHECK-FIXES-NEXT: llvm::Register Reg1 = getReg();
-}
-
-void done_2() {
- using namespace llvm;
- Register Reg2 = getReg();
- // CHECK-FIXES: done_2()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: Register Reg2 = getReg();
-}
-
-namespace llvm {
-void done_3() {
- Register Reg3 = getReg();
- // CHECK-FIXES: done_3()
- // CHECK-FIXES-NEXT: Register Reg3 = getReg();
-}
-} // end namespace llvm
-
-void do_nothing_1() {
- unsigned Reg1 = getRegLike();
- // CHECK-FIXES: do_nothing_1()
- // CHECK-FIXES-NEXT: unsigned Reg1 = getRegLike();
-}
-
-void do_nothing_2() {
- using namespace llvm;
- unsigned Reg2 = getRegLike();
- // CHECK-FIXES: do_nothing_2()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: unsigned Reg2 = getRegLike();
-}
-
-namespace llvm {
-void do_nothing_3() {
- unsigned Reg3 = getRegLike();
- // CHECK-FIXES: do_nothing_3()
- // CHECK-FIXES-NEXT: unsigned Reg3 = getRegLike();
-}
-} // end namespace llvm
-
-void fn1(llvm::Register R);
-void do_nothing_4() {
- fn1(getReg());
- // CHECK-FIXES: do_nothing_4()
- // CHECK-FIXES-NEXT: fn1(getReg());
-}
-
-void fn2(unsigned R);
-void do_nothing_5() {
- fn2(getReg());
- // CHECK-FIXES: do_nothing_5()
- // CHECK-FIXES-NEXT: fn2(getReg());
-}
-
-void do_nothing_6() {
- using namespace llvm;
- Register Reg6{getReg()};
- // CHECK-FIXES: do_nothing_6()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: Register Reg6{getReg()};
-}
-
-void do_nothing_7() {
- using namespace llvm;
- Register Reg7;
- Reg7.Reg = getReg();
- // CHECK-FIXES: do_nothing_7()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: Register Reg7;
- // CHECK-FIXES-NEXT: Reg7.Reg = getReg();
-}
-
-void do_nothing_8() {
- using namespace llvm;
- RegisterLike Reg8{getReg()};
- // CHECK-FIXES: do_nothing_8()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: RegisterLike Reg8{getReg()};
-}
-
-void do_nothing_9() {
- using namespace llvm;
- RegisterLike Reg9;
- Reg9.Reg = getReg();
- // CHECK-FIXES: do_nothing_9()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: RegisterLike Reg9;
- // CHECK-FIXES-NEXT: Reg9.Reg = getReg();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned2.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned2.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned2.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned2.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: %check_clang_tidy %s llvm-prefer-register-over-unsigned %t
-
-namespace llvm {
-class Register {
-public:
- operator unsigned();
-};
-} // end namespace llvm
-
-llvm::Register getReg();
-
-using namespace llvm;
-
-void apply_1() {
- unsigned Reg = getReg();
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: variable 'Reg' declared as 'unsigned int'; use 'Register' instead [llvm-prefer-register-over-unsigned]
- // CHECK-FIXES: apply_1()
- // CHECK-FIXES-NEXT: Register Reg = getReg();
-}
-
-void done_1() {
- llvm::Register Reg = getReg();
- // CHECK-FIXES: done_1()
- // CHECK-FIXES-NEXT: llvm::Register Reg = getReg();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned3.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned3.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned3.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-prefer-register-over-unsigned3.cpp (removed)
@@ -1,33 +0,0 @@
-// RUN: %check_clang_tidy %s llvm-prefer-register-over-unsigned %t
-
-namespace llvm { };
-
-// This class shouldn't trigger it despite the similarity as it's not inside the llvm namespace
-class Register {
-public:
- operator unsigned();
-};
-
-Register getReg();
-
-void do_nothing_1() {
- unsigned Reg1 = getReg();
- // CHECK-FIXES: do_nothing_1()
- // CHECK-FIXES-NEXT: unsigned Reg1 = getReg();
-}
-
-void do_nothing_2() {
- using namespace llvm;
- unsigned Reg2 = getReg();
- // CHECK-FIXES: do_nothing_2()
- // CHECK-FIXES-NEXT: using namespace llvm;
- // CHECK-FIXES-NEXT: unsigned Reg2 = getReg();
-}
-
-namespace llvm {
-void do_nothing_3() {
- unsigned Reg3 = getReg();
- // CHECK-FIXES: do_nothing_3()
- // CHECK-FIXES-NEXT: unsigned Reg3 = getReg();
-}
-} // end namespace llvm
Removed: 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=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp (removed)
@@ -1,64 +0,0 @@
-// RUN: %check_clang_tidy %s llvm-twine-local %t
-
-namespace llvm {
-class Twine {
-public:
- Twine(const char *);
- Twine(int);
- Twine();
- Twine &operator+(const Twine &);
-};
-}
-
-using namespace llvm;
-
-void foo(const Twine &x);
-
-static Twine Moo = Twine("bark") + "bah";
-// 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: :[[@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: :[[@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";
-
- const Twine t2 = Twine();
-// 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 t2 = (Twine()).str();
- foo(Twine() + "b");
-
- const Twine t3 = Twine(42);
-// 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 t3 = (Twine(42)).str();
-
- const Twine t4 = Twine(42) + "b";
-// 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 t4 = (Twine(42) + "b").str();
-
- const Twine t5 = Twine() + "b";
-// 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 t5 = (Twine() + "b").str();
-
- const Twine t6 = true ? Twine() : Twine(42);
-// 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 t6 = (true ? Twine() : Twine(42)).str();
-
- const Twine t7 = false ? Twine() : Twine("b");
-// 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 t7 = (false ? Twine() : Twine("b")).str();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/macros.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/macros.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/macros.cpp (removed)
@@ -1,7 +0,0 @@
-// RUN: clang-tidy -checks='-*,google-explicit-constructor' %s -- | FileCheck %s
-
-#define Q(name) class name { name(int i); }
-
-Q(A);
-// CHECK: :[[@LINE-1]]:3: warning: single-argument constructors must be marked explicit
-// CHECK: :3:30: note: expanded from macro 'Q'
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers-1z.hpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers-1z.hpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers-1z.hpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers-1z.hpp (removed)
@@ -1,10 +0,0 @@
-// RUN: %check_clang_tidy %s misc-definitions-in-headers %t -- -- -std=c++1z
-
-class CE {
- constexpr static int i = 5; // OK: inline variable definition.
-};
-
-inline int i = 5; // OK: inline variable definition.
-
-int b = 1;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'b' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-definitions-in-headers.hpp (removed)
@@ -1,194 +0,0 @@
-// RUN: %check_clang_tidy %s misc-definitions-in-headers %t
-
-int f() {
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]
-// CHECK-MESSAGES: :[[@LINE-2]]:5: note: make as 'inline'
-// CHECK-FIXES: inline int f() {
- return 1;
-}
-
-class CA {
- void f1() {} // OK: inline class member function definition.
- void f2();
- template<typename T>
- T f3() {
- T a = 1;
- return a;
- }
- template<typename T>
- struct CAA {
- struct CAB {
- void f4();
- };
- };
-};
-
-void CA::f2() { }
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: function 'f2' defined in a header file;
-// CHECK-FIXES: inline void CA::f2() {
-
-template <>
-int CA::f3() {
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: full function template specialization 'f3<int>' defined in a header file;
-// CHECK-FIXES: inline int CA::f3() {
- int a = 1;
- return a;
-}
-
-template <typename T>
-void CA::CAA<T>::CAB::f4() {
-// OK: member function definition of a nested template class in a class.
-}
-
-template <typename T>
-struct CB {
- void f1();
- struct CCA {
- void f2(T a);
- };
- struct CCB; // OK: forward declaration.
- static int a; // OK: class static data member declaration.
-};
-
-template <typename T>
-void CB<T>::f1() { // OK: Member function definition of a class template.
-}
-
-template <typename T>
-void CB<T>::CCA::f2(T a) {
-// OK: member function definition of a nested class in a class template.
-}
-
-template <typename T>
-struct CB<T>::CCB {
- void f3();
-};
-
-template <typename T>
-void CB<T>::CCB::f3() {
-// OK: member function definition of a nested class in a class template.
-}
-
-template <typename T>
-int CB<T>::a = 2; // OK: static data member definition of a class template.
-
-template class CB<int>; // OK: explicitly instantiated static data member of a class template.
-inline int callCB() {
- CB<double> cb; // OK: implicitly instantiated static data member of a class template.
- return cb.a;
-}
-
-template <typename T>
-T tf() { // OK: template function definition.
- T a;
- return a;
-}
-
-
-namespace NA {
- int f() { return 1; }
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f' defined in a header file;
-// CHECK-FIXES: inline int f() { return 1; }
-}
-
-template <typename T>
-T f3() {
- T a = 1;
- return a;
-}
-
-template <>
-int f3() {
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: full function template specialization 'f3<int>' defined in a header file;
-// CHECK-FIXES: inline int f3() {
- int a = 1;
- return a;
-}
-
-int f5(); // OK: function declaration.
-inline int f6() { return 1; } // OK: inline function definition.
-namespace {
- int f7() { return 1; }
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: function 'f7' defined in a header file;
-}
-
-int f8() = delete; // OK: the function being marked delete is not callable.
-
-template <typename T>
-int f9(T t) { return 1; }
-
-inline void callF9() { f9(1); } // OK: implicitly instantiated function.
-template int f9(double); // OK: explicitly instantiated function.
-
-int a = 1;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: variable 'a' defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
-CA a1;
-// CHECK-MESSAGES: :[[@LINE-1]]:4: warning: variable 'a1' defined in a header file;
-
-namespace NB {
- int b = 1;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'b' defined in a header file;
- const int c = 1; // OK: internal linkage variable definition.
-}
-
-class CC {
- static int d; // OK: class static data member declaration.
-};
-
-int CC::d = 1;
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'd' defined in a header file;
-
-const char* ca = "foo";
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'ca' defined in a header file;
-
-namespace {
- int e = 2;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'e' defined in a header file;
-}
-
-const char* const g = "foo"; // OK: internal linkage variable definition.
-static int h = 1; // OK: internal linkage variable definition.
-const int i = 1; // OK: internal linkage variable definition.
-extern int j; // OK: internal linkage variable definition.
-
-template <typename T, typename U>
-struct CD {
- int f();
-};
-
-template <typename T>
-struct CD<T, int> {
- int f();
-};
-
-template <>
-struct CD<int, int> {
- int f();
-};
-
-int CD<int, int>::f() {
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: function 'f' defined in a header file;
-// CHECK-FIXES: inline int CD<int, int>::f() {
- return 0;
-}
-
-template <typename T>
-int CD<T, int>::f() { // OK: partial template specialization.
- return 0;
-}
-
-constexpr int k = 1; // OK: constexpr variable has internal linkage.
-
-constexpr int f10() { return 0; } // OK: constexpr function definition.
-
-const int f11() { return 0; }
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: function 'f11' defined in a header file;
-// CHECK-FIXES: inline const int f11() { return 0; }
-
-template <typename T>
-const T f12();
-
-template <>
-const int f12() { return 0; }
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: full function template specialization 'f12<int>' defined in a header file;
-// CHECK-FIXES: inline const int f12() { return 0; }
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const-cxx17.cpp (removed)
@@ -1,15 +0,0 @@
-// RUN: %check_clang_tidy -expect-clang-tidy-error %s misc-misplaced-const %t -- -- -std=c++17
-
-// This test previously would cause a failed assertion because the structured
-// binding declaration had no valid type associated with it. This ensures the
-// expected clang diagnostic is generated instead.
-// CHECK-MESSAGES: :[[@LINE+1]]:6: error: decomposition declaration '[x]' requires an initializer [clang-diagnostic-error]
-auto [x];
-
-struct S { int a; };
-S f();
-
-int main() {
- auto [x] = f();
-}
-
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.c (removed)
@@ -1,45 +0,0 @@
-// RUN: %check_clang_tidy %s misc-misplaced-const %t
-
-typedef int plain_i;
-typedef int *ip;
-typedef const int *cip;
-
-typedef void (*func_ptr)(void);
-
-void func(void) {
- // ok
- const int *i0 = 0;
- const plain_i *i1 = 0;
- const cip i2 = 0; // const applies to both pointer and pointee.
-
- // Not ok
- const ip i3 = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
-
- ip const i4 = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i4' declared with a const-qualified
-
- const volatile ip i5 = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i5' declared with a const-qualified typedef type; results in the type being 'int *const volatile' instead of 'const int *volatile'
-}
-
-void func2(const plain_i *i1,
- const cip i2,
- const ip i3,
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 'i3' declared with a const-qualified
- const int *i4) {
-}
-
-struct S {
- const int *i0;
- const plain_i *i1;
- const cip i2;
- const ip i3;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'i3' declared with a const-qualified
-};
-
-// Function pointers should not be diagnosed because a function
-// pointer type can never be const.
-void func3(const func_ptr fp) {
- const func_ptr fp2 = fp;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-misplaced-const.cpp (removed)
@@ -1,44 +0,0 @@
-// RUN: %check_clang_tidy %s misc-misplaced-const %t
-
-typedef int plain_i;
-typedef int *ip;
-typedef const int *cip;
-
-void func() {
- if (const int *i = 0)
- ;
- if (const plain_i *i = 0)
- ;
- if (const cip i = 0)
- ;
-
- // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: 'i' declared with a const-qualified typedef type; results in the type being 'int *const' instead of 'const int *'
- if (const ip i = 0)
- ;
-}
-
-template <typename Ty>
-struct S {
- const Ty *i;
- const Ty &i2;
-};
-
-template struct S<int>;
-template struct S<ip>; // ok
-template struct S<cip>;
-
-template <typename Ty>
-struct U {
- const Ty *i;
- const Ty &i2;
-};
-
-template struct U<int *>; // ok
-
-struct T {
- typedef void (T::*PMF)();
-
- void f() {
- const PMF val = &T::f; // ok
- }
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads-sized-dealloc.cpp (removed)
@@ -1,20 +0,0 @@
-// RUN: %check_clang_tidy %s misc-new-delete-overloads %t -- -- -fsized-deallocation
-
-typedef decltype(sizeof(int)) size_t;
-
-struct S {
- // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope [misc-new-delete-overloads]
- void operator delete(void *ptr, size_t) noexcept; // not a placement delete
-};
-
-struct T {
- // Because we have enabled sized deallocations explicitly, this new/delete
- // pair matches.
- void *operator new(size_t size) noexcept;
- void operator delete(void *ptr, size_t) noexcept; // ok because sized deallocation is enabled
-};
-
-// While we're here, check that global operator delete with no operator new
-// is also matched.
-// CHECK-MESSAGES: :[[@LINE+1]]:6: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope
-void operator delete(void *ptr) noexcept;
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-new-delete-overloads.cpp (removed)
@@ -1,81 +0,0 @@
-// RUN: %check_clang_tidy %s misc-new-delete-overloads %t
-
-typedef decltype(sizeof(int)) size_t;
-
-struct S {
- // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope [misc-new-delete-overloads]
- void *operator new(size_t size) noexcept;
- // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new[]' has no matching declaration of 'operator delete[]' at the same scope
- void *operator new[](size_t size) noexcept;
-};
-
-// CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope
-void *operator new(size_t size) noexcept(false);
-
-struct T {
- // Sized deallocations are not enabled by default, and so this new/delete pair
- // does not match. However, we expect only one warning, for the new, because
- // the operator delete is a placement delete and we do not warn on mismatching
- // placement operations.
- // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope
- void *operator new(size_t size) noexcept;
- void operator delete(void *ptr, size_t) noexcept; // ok only if sized deallocation is enabled
-};
-
-struct U {
- void *operator new(size_t size) noexcept;
- void operator delete(void *ptr) noexcept;
-
- void *operator new[](size_t) noexcept;
- void operator delete[](void *) noexcept;
-};
-
-struct Z {
- // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete' has no matching declaration of 'operator new' at the same scope
- void operator delete(void *ptr) noexcept;
- // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: declaration of 'operator delete[]' has no matching declaration of 'operator new[]' at the same scope
- void operator delete[](void *ptr) noexcept;
-};
-
-struct A {
- void *operator new(size_t size, Z) noexcept; // ok, placement new
-};
-
-struct B {
- void operator delete(void *ptr, A) noexcept; // ok, placement delete
-};
-
-// It is okay to have a class with an inaccessible free store operator.
-struct C {
- void *operator new(size_t, A) noexcept; // ok, placement new
-private:
- void operator delete(void *) noexcept;
-};
-
-// It is also okay to have a class with a delete free store operator.
-struct D {
- void *operator new(size_t, A) noexcept; // ok, placement new
- void operator delete(void *) noexcept = delete;
-};
-
-struct E : U {
- void *operator new(size_t) noexcept; // okay, we inherit operator delete from U
-};
-
-struct F : S {
- // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope
- void *operator new(size_t) noexcept;
-};
-
-class G {
- void operator delete(void *) noexcept;
-};
-
-struct H : G {
- // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' has no matching declaration of 'operator delete' at the same scope
- void *operator new(size_t) noexcept; // base class operator is inaccessible
-};
-
-template <typename Base> struct Derived : Base {
- void operator delete(void *);
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.c (removed)
@@ -1,43 +0,0 @@
-// RUN: %check_clang_tidy %s misc-non-copyable-objects %t
-
-typedef struct FILE {} FILE;
-typedef struct pthread_cond_t {} pthread_cond_t;
-typedef int pthread_mutex_t;
-
-// CHECK-MESSAGES: :[[@LINE+1]]:13: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? [misc-non-copyable-objects]
-void g(FILE f);
-// CHECK-MESSAGES: :[[@LINE+1]]:24: warning: 'm' declared as type 'pthread_mutex_t', which is unsafe to copy; did you mean 'pthread_mutex_t *'?
-void h(pthread_mutex_t m);
-// CHECK-MESSAGES: :[[@LINE+1]]:23: warning: 'c' declared as type 'pthread_cond_t', which is unsafe to copy; did you mean 'pthread_cond_t *'?
-void i(pthread_cond_t c);
-
-struct S {
- pthread_cond_t c; // ok
- // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- FILE f;
-};
-
-void func(FILE *f) {
- // CHECK-MESSAGES: :[[@LINE+1]]:8: warning: 'f1' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- FILE f1; // match
- // CHECK-MESSAGES: :[[@LINE+2]]:8: warning: 'f2' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: expression has opaque data structure type 'FILE'; type should only be used as a pointer and not dereferenced
- FILE f2 = *f;
- // CHECK-MESSAGES: :[[@LINE+1]]:15: warning: 'f3' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- struct FILE f3;
- // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: expression has opaque data structure type 'FILE'; type should only be used as a pointer and not dereferenced
- (void)sizeof(*f);
- (void)sizeof(FILE);
- // CHECK-MESSAGES: :[[@LINE+1]]:5: warning: expression has opaque data structure type 'FILE'; type should only be used as a pointer and not dereferenced
- g(*f);
-
- pthread_mutex_t m; // ok
- h(m); // ok
-
- pthread_cond_t c; // ok
- i(c); // ok
-
- pthread_mutex_t *m1 = &m; // ok
- // CHECK-MESSAGES: :[[@LINE+1]]:5: warning: expression has opaque data structure type 'pthread_mutex_t'; type should only be used as a pointer and not dereferenced
- h(*m1);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-non-copyable-objects.cpp (removed)
@@ -1,26 +0,0 @@
-// RUN: %check_clang_tidy %s misc-non-copyable-objects %t
-
-namespace std {
-typedef struct FILE {} FILE;
-}
-using namespace std;
-
-// CHECK-MESSAGES: :[[@LINE+1]]:18: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'? [misc-non-copyable-objects]
-void g(std::FILE f);
-
-struct S {
- // CHECK-MESSAGES: :[[@LINE+1]]:10: warning: 'f' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- ::FILE f;
-};
-
-void func(FILE *f) {
- // CHECK-MESSAGES: :[[@LINE+1]]:13: warning: 'f1' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- std::FILE f1; // match
- // CHECK-MESSAGES: :[[@LINE+2]]:10: warning: 'f2' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- // CHECK-MESSAGES: :[[@LINE+1]]:15: warning: expression has opaque data structure type 'FILE'; type should only be used as a pointer and not dereferenced
- ::FILE f2 = *f; // match, match
- // CHECK-MESSAGES: :[[@LINE+1]]:15: warning: 'f3' declared as type 'FILE', which is unsafe to copy; did you mean 'FILE *'?
- struct FILE f3; // match
- // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: expression has opaque data structure type 'FILE'; type should only be used as a pointer and not dereferenced
- (void)sizeof(*f); // match
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-non-private-member-variables-in-classes.cpp (removed)
@@ -1,397 +0,0 @@
-// RUN: %check_clang_tidy -check-suffixes=PUBLIC,NONPRIVATE,PROTECTED %s misc-non-private-member-variables-in-classes %t
-// RUN: %check_clang_tidy -check-suffixes=PUBLIC,NONPRIVATE,PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
-// RUN: %check_clang_tidy -check-suffixes=PUBLIC,PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 0}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
-// RUN: %check_clang_tidy -check-suffixes=PUBLIC,PROTECTED %s cppcoreguidelines-non-private-member-variables-in-classes %t -- --
-// RUN: %check_clang_tidy -check-suffixes=PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 0}]}' --
-// RUN: %check_clang_tidy -check-suffixes=PROTECTED %s misc-non-private-member-variables-in-classes %t -- -config='{CheckOptions: [{key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables, value: 1}, {key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic, value: 1}]}' --
-
-//----------------------------------------------------------------------------//
-
-// Only data, do not warn
-
-struct S0 {
- int S0_v0;
-
-public:
- int S0_v1;
-
-protected:
- int S0_v2;
-
-private:
- int S0_v3;
-};
-
-class S1 {
- int S1_v0;
-
-public:
- int S1_v1;
-
-protected:
- int S1_v2;
-
-private:
- int S1_v3;
-};
-
-// Only data and implicit or static methods, do not warn
-
-class C {
-public:
- C() {}
- ~C() {}
-};
-
-struct S1Implicit {
- C S1Implicit_v0;
-};
-
-struct S1ImplicitAndStatic {
- C S1Implicit_v0;
- static void s() {}
-};
-
-//----------------------------------------------------------------------------//
-
-// All functions are static, do not warn.
-
-struct S2 {
- static void S2_m0();
- int S2_v0;
-
-public:
- static void S2_m1();
- int S2_v1;
-
-protected:
- static void S2_m3();
- int S2_v2;
-
-private:
- static void S2_m4();
- int S2_v3;
-};
-
-class S3 {
- static void S3_m0();
- int S3_v0;
-
-public:
- static void S3_m1();
- int S3_v1;
-
-protected:
- static void S3_m3();
- int S3_v2;
-
-private:
- static void S3_m4();
- int S3_v3;
-};
-
-//============================================================================//
-
-// union != struct/class. do not diagnose.
-
-union U0 {
- void U0_m0();
- int U0_v0;
-
-public:
- void U0_m1();
- int U0_v1;
-
-protected:
- void U0_m2();
- int U0_v2;
-
-private:
- void U0_m3();
- int U0_v3;
-};
-
-//============================================================================//
-
-// Has non-static method with default visibility.
-
-struct S4 {
- void S4_m0();
-
- int S4_v0;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S4_v0' has public visibility
-public:
- int S4_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S4_v1' has public visibility
-protected:
- int S4_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S4_v2' has protected visibility
-private:
- int S4_v3;
-};
-
-class S5 {
- void S5_m0();
-
- int S5_v0;
-
-public:
- int S5_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S5_v1' has public visibility
-protected:
- int S5_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S5_v2' has protected visibility
-private:
- int S5_v3;
-};
-
-//----------------------------------------------------------------------------//
-
-// Has non-static method with public visibility.
-
-struct S6 {
- int S6_v0;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S6_v0' has public visibility
-public:
- void S6_m0();
- int S6_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S6_v1' has public visibility
-protected:
- int S6_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S6_v2' has protected visibility
-private:
- int S6_v3;
-};
-
-class S7 {
- int S7_v0;
-
-public:
- void S7_m0();
- int S7_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S7_v1' has public visibility
-protected:
- int S7_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S7_v2' has protected visibility
-private:
- int S7_v3;
-};
-
-//----------------------------------------------------------------------------//
-
-// Has non-static method with protected visibility.
-
-struct S8 {
- int S8_v0;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S8_v0' has public visibility
-public:
- int S8_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S8_v1' has public visibility
-protected:
- void S8_m0();
- int S8_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S8_v2' has protected visibility
-private:
- int S8_v3;
-};
-
-class S9 {
- int S9_v0;
-
-public:
- int S9_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S9_v1' has public visibility
-protected:
- void S9_m0();
- int S9_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S9_v2' has protected visibility
-private:
- int S9_v3;
-};
-
-//----------------------------------------------------------------------------//
-
-// Has non-static method with private visibility.
-
-struct S10 {
- int S10_v0;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S10_v0' has public visibility
-public:
- int S10_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S10_v1' has public visibility
-protected:
- int S10_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S10_v2' has protected visibility
-private:
- void S10_m0();
- int S10_v3;
-};
-
-class S11 {
- int S11_v0;
-
-public:
- int S11_v1;
- // CHECK-MESSAGES-PUBLIC: :[[@LINE-1]]:7: warning: member variable 'S11_v1' has public visibility
-protected:
- int S11_v2;
- // CHECK-MESSAGES-PROTECTED: :[[@LINE-1]]:7: warning: member variable 'S11_v2' has protected visibility
-private:
- void S11_m0();
- int S11_v3;
-};
-
-//============================================================================//
-
-// Static variables are ignored.
-// Has non-static methods and static variables.
-
-struct S12 {
- void S12_m0();
- static int S12_v0;
-
-public:
- void S12_m1();
- static int S12_v1;
-
-protected:
- void S12_m2();
- static int S12_v2;
-
-private:
- void S12_m3();
- static int S12_v3;
-};
-
-class S13 {
- void S13_m0();
- static int S13_v0;
-
-public:
- void S13_m1();
- static int S13_v1;
-
-protected:
- void S13_m2();
- static int S13_v2;
-
-private:
- void S13_m3();
- static int S13_v3;
-};
-
-struct S14 {
- void S14_m0();
- int S14_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S14_v0' has public visibility
-
-public:
- void S14_m1();
- int S14_v1;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S14_v1' has public visibility
-
-protected:
- void S14_m2();
-
-private:
- void S14_m3();
-};
-
-class S15 {
- void S15_m0();
-
-public:
- void S15_m1();
- int S15_v1;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S15_v1' has public visibility
-
-protected:
- void S15_m2();
-
-private:
- void S15_m3();
-};
-
-//----------------------------------------------------------------------------//
-
-template <typename T>
-struct S97 {
- void method();
- T S97_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:5: warning: member variable 'S97_v0' has public visibility
-};
-
-template struct S97<char *>;
-
-template <>
-struct S97<double> {
- void method();
- double S97d_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:10: warning: member variable 'S97d_v0' has public visibility
-};
-
-//----------------------------------------------------------------------------//
-
-#define FIELD(x) int x;
-
-// Do diagnose fields originating from macros.
-struct S98 {
- void method();
- FIELD(S98_v0);
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:9: warning: member variable 'S98_v0' has public visibility
-};
-
-//----------------------------------------------------------------------------//
-
-// Don't look in descendant classes.
-class S99 {
- void method();
-
- struct S99_0 {
- int S99_S0_v0;
- };
-
-public:
- struct S99_1 {
- int S99_S0_v0;
- };
-
-protected:
- struct S99_2 {
- int S99_S0_v0;
- };
-
-private:
- struct S99_3 {
- int S99_S0_v0;
- };
-};
-
-//----------------------------------------------------------------------------//
-
-// Only diagnose once, don't let the inheritance fool you.
-struct S100 {
- int S100_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S100_v0' has public visibility
- void m0();
-};
-struct S101_default_inheritance : S100 {
- int S101_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S101_v0' has public visibility
- void m1();
-};
-struct S102_public_inheritance : public S100 {
- int S102_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S102_v0' has public visibility
- void m1();
-};
-struct S103_protected_inheritance : protected S100 {
- int S103_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S103_v0' has public visibility
- void m1();
-};
-struct S104_private_inheritance : private S100 {
- int S104_v0;
- // CHECK-MESSAGES-NONPRIVATE: :[[@LINE-1]]:7: warning: member variable 'S104_v0' has public visibility
- void m1();
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-redundant-expression.cpp (removed)
@@ -1,753 +0,0 @@
-// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -fno-delayed-template-parsing
-
-typedef __INT64_TYPE__ I64;
-
-struct Point {
- int x;
- int y;
- int a[5];
-} P;
-
-extern Point P1;
-extern Point P2;
-
-extern int foo(int x);
-extern int bar(int x);
-extern int bat(int x, int y);
-
-int TestSimpleEquivalent(int X, int Y) {
- if (X - X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent [misc-redundant-expression]
- if (X / X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
- if (X % X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
-
- if (X & X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
- if (X | X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
- if (X ^ X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
-
- if (X < X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
- if (X <= X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
- if (X > X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
- if (X >= X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
-
- if (X && X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
- if (X || X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
-
- if (X != (((X)))) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of operator are equivalent
-
- if (X + 1 == X + 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
- if (X + 1 != X + 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
- if (X + 1 <= X + 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
- if (X + 1 >= X + 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
-
- if ((X != 1 || Y != 1) && (X != 1 || Y != 1)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both sides of operator are equivalent
- if (P.a[X - P.x] != P.a[X - P.x]) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: both sides of operator are equivalent
-
- if ((int)X < (int)X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both sides of operator are equivalent
- if (int(X) < int(X)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both sides of operator are equivalent
-
- if ( + "dummy" == + "dummy") return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both sides of operator are equivalent
- if (L"abc" == L"abc") return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both sides of operator are equivalent
-
- if (foo(0) - 2 < foo(0) - 2) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: both sides of operator are equivalent
- if (foo(bar(0)) < (foo(bar((0))))) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both sides of operator are equivalent
-
- if (P1.x < P2.x && P1.x < P2.x) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: both sides of operator are equivalent
- if (P2.a[P1.x + 2] < P2.x && P2.a[(P1.x) + (2)] < (P2.x)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: both sides of operator are equivalent
-
- return 0;
-}
-
-template <int DX>
-int TestSimpleEquivalentDependent() {
- if (DX > 0 && DX > 0) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both sides of operator are equivalent
-
- return 0;
-}
-
-int Valid(int X, int Y) {
- if (X != Y) return 1;
- if (X == Y + 0) return 1;
- if (P.x == P.y) return 1;
- if (P.a[P.x] < P.a[P.y]) return 1;
- if (P.a[0] < P.a[1]) return 1;
-
- if (P.a[0] < P.a[0ULL]) return 1;
- if (0 < 0ULL) return 1;
- if ((int)0 < (int)0ULL) return 1;
-
- if (++X != ++X) return 1;
- if (P.a[X]++ != P.a[X]++) return 1;
- if (P.a[X++] != P.a[X++]) return 1;
-
- if ("abc" == "ABC") return 1;
- if (foo(bar(0)) < (foo(bat(0, 1)))) return 1;
- return 0;
-}
-
-#define COND_OP_MACRO 9
-#define COND_OP_OTHER_MACRO 9
-int TestConditional(int x, int y) {
- int k = 0;
- k += (y < 0) ? x : x;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 'true' and 'false' expressions are equivalent
- k += (y < 0) ? x + 1 : x + 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'true' and 'false' expressions are equivalent
- k += (y < 0) ? COND_OP_MACRO : COND_OP_MACRO;
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: 'true' and 'false' expressions are equivalent
-
- // Do not match for conditional operators with a macro and a const.
- k += (y < 0) ? COND_OP_MACRO : 9;
- // Do not match for conditional operators with expressions from different macros.
- k += (y < 0) ? COND_OP_MACRO : COND_OP_OTHER_MACRO;
- return k;
-}
-#undef COND_OP_MACRO
-#undef COND_OP_OTHER_MACRO
-
-// Overloaded operators that compare two instances of a struct.
-struct MyStruct {
- int x;
- bool operator==(const MyStruct& rhs) const {return this->x == rhs.x; } // not modifing
- bool operator>=(const MyStruct& rhs) const { return this->x >= rhs.x; } // not modifing
- bool operator<=(MyStruct& rhs) const { return this->x <= rhs.x; }
- bool operator&&(const MyStruct& rhs){ this->x++; return this->x && rhs.x; }
-} Q;
-
-bool operator!=(const MyStruct& lhs, const MyStruct& rhs) { return lhs.x == rhs.x; } // not modifing
-bool operator<(const MyStruct& lhs, const MyStruct& rhs) { return lhs.x < rhs.x; } // not modifing
-bool operator>(const MyStruct& lhs, MyStruct& rhs) { rhs.x--; return lhs.x > rhs.x; }
-bool operator||(MyStruct& lhs, const MyStruct& rhs) { lhs.x++; return lhs.x || rhs.x; }
-
-bool TestOverloadedOperator(MyStruct& S) {
- if (S == Q) return false;
-
- if (S <= S) return false;
- if (S && S) return false;
- if (S > S) return false;
- if (S || S) return false;
-
- if (S == S) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of overloaded operator are equivalent
- if (S < S) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of overloaded operator are equivalent
- if (S != S) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of overloaded operator are equivalent
- if (S >= S) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: both sides of overloaded operator are equivalent
-
- return true;
-}
-
-#define LT(x, y) (void)((x) < (y))
-#define COND(x, y, z) ((x)?(y):(z))
-#define EQUALS(x, y) (x) == (y)
-
-int TestMacro(int X, int Y) {
- LT(0, 0);
- LT(1, 0);
- LT(X, X);
- LT(X+1, X + 1);
- COND(X < Y, X, X);
- EQUALS(Q, Q);
- return 0;
-}
-
-int TestFalsePositive(int* A, int X, float F) {
- // Produced by bison.
- X = A[(2) - (2)];
- X = A['a' - 'a'];
-
- // Testing NaN.
- if (F != F && F == F) return 1;
- return 0;
-}
-
-int TestBannedMacros() {
-#define EAGAIN 3
-#define NOT_EAGAIN 3
- if (EAGAIN == 0 | EAGAIN == 0) return 0;
- if (NOT_EAGAIN == 0 | NOT_EAGAIN == 0) return 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: both sides of operator are equivalent
- return 0;
-}
-
-struct MyClass {
-static const int Value = 42;
-};
-template <typename T, typename U>
-void TemplateCheck() {
- static_assert(T::Value == U::Value, "should be identical");
- static_assert(T::Value == T::Value, "should be identical");
- // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: both sides of operator are equivalent
-}
-void TestTemplate() { TemplateCheck<MyClass, MyClass>(); }
-
-int TestArithmetic(int X, int Y) {
- if (X + 1 == X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
- if (X + 1 != X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
- if (X - 1 == X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
- if (X - 1 != X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- if (X + 1LL == X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
- if (X + 1ULL == X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
-
- if (X == X + 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
- if (X != X + 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
- if (X == X - 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
- if (X != X - 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
-
- if (X != X - 1U) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
- if (X != X - 1LL) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always true
-
- if ((X+X) != (X+X) - 1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- if (X + 1 == X + 2) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
- if (X + 1 != X + 2) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- if (X - 1 == X - 2) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
- if (X - 1 != X - 2) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- if (X + 1 == X - -1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
- if (X + 1 != X - -1) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
- if (X + 1 == X - -2) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
- if (X + 1 != X - -2) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- if (X + 1 == X - (~0)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
- if (X + 1 == X - (~0U)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- if (X + 1 == X - (~0ULL)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- // Should not match.
- if (X + 0.5 == X) return 1;
- if (X + 1 == Y) return 1;
- if (X + 1 == Y + 1) return 1;
- if (X + 1 == Y + 2) return 1;
-
- return 0;
-}
-
-int TestBitwise(int X, int Y) {
-
- if ((X & 0xFF) == 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
- if ((X & 0xFF) != 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
- if ((X | 0xFF) == 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
- if ((X | 0xFF) != 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
-
- if ((X | 0xFFULL) != 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: logical expression is always true
- if ((X | 0xFF) != 0xF00ULL) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
-
- if ((0xFF & X) == 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
- if ((0xFF & X) != 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
- if ((0xFF & X) == 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
- if ((0xFF & X) != 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always true
-
- if ((0xFFLL & X) == 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: logical expression is always false
- if ((0xFF & X) == 0xF00ULL) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
-
- return 0;
-}
-
-// Overloaded operators that compare an instance of a struct and an integer
-// constant.
-struct S {
- S() { x = 1; }
- int x;
- // Overloaded comparison operators without any possible side effect.
- bool operator==(const int &i) const { return x == i; } // not modifying
- bool operator!=(int i) const { return x != i; } // not modifying
- bool operator>(const int &i) const { return x > i; } // not modifying
- bool operator<(int i) const { return x < i; } // not modifying
-};
-
-bool operator<=(const S &s, int i) { return s.x <= i; } // not modifying
-bool operator>=(const S &s, const int &i) { return s.x >= i; } // not modifying
-
-struct S2 {
- S2() { x = 1; }
- int x;
- // Overloaded comparison operators that are able to modify their params.
- bool operator==(const int &i) {
- this->x++;
- return x == i;
- }
- bool operator!=(int i) { return x != i; }
- bool operator>(const int &i) { return x > i; }
- bool operator<(int i) {
- this->x--;
- return x < i;
- }
-};
-
-bool operator>=(S2 &s, const int &i) { return s.x >= i; }
-bool operator<=(S2 &s, int i) {
- s.x++;
- return s.x <= i;
-}
-
-int TestLogical(int X, int Y){
-#define CONFIG 0
- if (CONFIG && X) return 1;
-#undef CONFIG
-#define CONFIG 1
- if (CONFIG || X) return 1;
-#undef CONFIG
-
- if (X == 10 && X != 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
- if (X == 10 && (X != 10)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
- if (X == 10 && !(X == 10)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
- if (!(X != 10) && !(X == 10)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
-
- if (X == 10ULL && X != 10ULL) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
- if (!(X != 10U) && !(X == 10)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: logical expression is always false
- if (!(X != 10LL) && !(X == 10)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: logical expression is always false
- if (!(X != 10ULL) && !(X == 10)) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: logical expression is always false
-
- if (X == 0 && X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always false
- if (X != 0 && !X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always false
- if (X && !X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: logical expression is always false
-
- if (X && !!X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: equivalent expression on both sides of logical operator
- if (X != 0 && X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: equivalent expression on both sides of logical operator
- if (X != 0 && !!X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: equivalent expression on both sides of logical operator
- if (X == 0 && !X) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: equivalent expression on both sides of logical operator
-
- // Should not match.
- if (X == 10 && Y == 10) return 1;
- if (X != 10 && X != 12) return 1;
- if (X == 10 || X == 12) return 1;
- if (!X && !Y) return 1;
- if (!X && Y) return 1;
- if (!X && Y == 0) return 1;
- if (X == 10 && Y != 10) return 1;
-
- // Test for overloaded operators with constant params.
- S s1;
- if (s1 == 1 && s1 == 1) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: equivalent expression on both sides of logical operator
- if (s1 == 1 || s1 != 1) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
- if (s1 > 1 && s1 < 1) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always false
- if (s1 >= 1 || s1 <= 1) return true;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
-
- // Test for overloaded operators that may modify their params.
- S2 s2;
- if (s2 == 1 || s2 != 1) return true;
- if (s2 == 1 || s2 == 1) return true;
- if (s2 > 1 && s2 < 1) return true;
- if (s2 >= 1 || s2 <= 1) return true;
-}
-
-int TestRelational(int X, int Y) {
- if (X == 10 && X > 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
- if (X == 10 && X < 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
- if (X < 10 && X > 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always false
- if (X <= 10 && X > 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always false
- if (X < 10 && X >= 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always false
- if (X < 10 && X == 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always false
-
- if (X > 5 && X <= 5) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always false
- if (X > -5 && X <= -5) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always false
-
- if (X < 10 || X >= 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
- if (X <= 10 || X > 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
- if (X <= 10 || X >= 11) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
- if (X != 7 || X != 14) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
- if (X == 7 || X != 5) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X != 7 || X == 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
-
- if (X < 7 && X < 6) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X < 7 && X < 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
- if (X < 7 && X < 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: expression is redundant
-
- if (X < 7 && X <= 5) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X < 7 && X <= 6) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: equivalent expression on both sides of logical operator
- if (X < 7 && X <= 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: expression is redundant
- if (X < 7 && X <= 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: expression is redundant
-
- if (X <= 7 && X < 6) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X <= 7 && X < 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X <= 7 && X < 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: equivalent expression on both sides of logical operator
-
- if (X >= 7 && X > 6) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: equivalent expression on both sides of logical operator
- if (X >= 7 && X > 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X >= 7 && X > 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
-
- if (X <= 7 && X <= 5) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X <= 7 && X <= 6) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X <= 7 && X <= 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: both sides of operator are equivalent
- if (X <= 7 && X <= 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: expression is redundant
-
- if (X == 11 && X > 10) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: expression is redundant
- if (X == 11 && X < 12) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: expression is redundant
- if (X > 10 && X == 11) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X < 12 && X == 11) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
-
- if (X != 11 && X == 42) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X != 11 && X > 11) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X != 11 && X < 11) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X != 11 && X < 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X != 11 && X > 14) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
-
- if (X < 7 || X < 6) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: expression is redundant
- if (X < 7 || X < 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
- if (X < 7 || X < 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
-
- if (X > 7 || X > 6) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X > 7 || X > 7) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: both sides of operator are equivalent
- if (X > 7 || X > 8) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: expression is redundant
-
- // Should not match.
- if (X < 10 || X > 12) return 1;
- if (X > 10 && X < 12) return 1;
- if (X < 10 || X >= 12) return 1;
- if (X > 10 && X <= 12) return 1;
- if (X <= 10 || X > 12) return 1;
- if (X >= 10 && X < 12) return 1;
- if (X <= 10 || X >= 12) return 1;
- if (X >= 10 && X <= 12) return 1;
- if (X >= 10 && X <= 11) return 1;
- if (X >= 10 && X < 11) return 1;
- if (X > 10 && X <= 11) return 1;
- if (X > 10 && X != 11) return 1;
- if (X >= 10 && X <= 10) return 1;
- if (X <= 10 && X >= 10) return 1;
- if (X < 0 || X > 0) return 1;
-}
-
-int TestRelationalMacros(int X){
-#define SOME_MACRO 3
-#define SOME_MACRO_SAME_VALUE 3
-#define SOME_OTHER_MACRO 9
- // Do not match for redundant relational macro expressions that can be
- // considered intentional, and for some particular values, non redundant.
-
- // Test cases for expressions with the same macro on both sides.
- if (X < SOME_MACRO && X > SOME_MACRO) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: logical expression is always false
- if (X < SOME_MACRO && X == SOME_MACRO) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: logical expression is always false
- if (X < SOME_MACRO || X >= SOME_MACRO) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: logical expression is always true
- if (X <= SOME_MACRO || X > SOME_MACRO) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: logical expression is always true
- if (X != SOME_MACRO && X > SOME_MACRO) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
- if (X != SOME_MACRO && X < SOME_MACRO) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
-
- // Test cases for two different macros.
- if (X < SOME_MACRO && X > SOME_OTHER_MACRO) return 1;
- if (X != SOME_MACRO && X >= SOME_OTHER_MACRO) return 1;
- if (X != SOME_MACRO && X != SOME_OTHER_MACRO) return 1;
- if (X == SOME_MACRO || X == SOME_MACRO_SAME_VALUE) return 1;
- if (X == SOME_MACRO || X <= SOME_MACRO_SAME_VALUE) return 1;
- if (X == SOME_MACRO || X > SOME_MACRO_SAME_VALUE) return 1;
- if (X < SOME_MACRO && X <= SOME_OTHER_MACRO) return 1;
- if (X == SOME_MACRO && X > SOME_OTHER_MACRO) return 1;
- if (X == SOME_MACRO && X != SOME_OTHER_MACRO) return 1;
- if (X == SOME_MACRO && X != SOME_MACRO_SAME_VALUE) return 1;
- if (X == SOME_MACRO_SAME_VALUE && X == SOME_MACRO ) return 1;
-
- // Test cases for a macro and a const.
- if (X < SOME_MACRO && X > 9) return 1;
- if (X != SOME_MACRO && X >= 9) return 1;
- if (X != SOME_MACRO && X != 9) return 1;
- if (X == SOME_MACRO || X == 3) return 1;
- if (X == SOME_MACRO || X <= 3) return 1;
- if (X < SOME_MACRO && X <= 9) return 1;
- if (X == SOME_MACRO && X != 9) return 1;
- if (X == SOME_MACRO && X == 9) return 1;
-
-#undef SOME_OTHER_MACRO
-#undef SOME_MACRO_SAME_VALUE
-#undef SOME_MACRO
- return 0;
-}
-
-int TestValidExpression(int X) {
- if (X - 1 == 1 - X) return 1;
- if (2 * X == X) return 1;
- if ((X << 1) == X) return 1;
-
- return 0;
-}
-
-enum Color { Red, Yellow, Green };
-int TestRelationalWithEnum(enum Color C) {
- if (C == Red && C == Yellow) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
- if (C == Red && C != Red) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always false
- if (C != Red || C != Yellow) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: logical expression is always true
-
- // Should not match.
- if (C == Red || C == Yellow) return 1;
- if (C != Red && C != Yellow) return 1;
-
- return 0;
-}
-
-template<class T>
-int TestRelationalTemplated(int X) {
- // This test causes a corner case with |isIntegerConstantExpr| where the type
- // is dependent. There is an assert failing when evaluating
- // sizeof(<incomplet-type>).
- if (sizeof(T) == 4 || sizeof(T) == 8) return 1;
-
- if (X + 0 == -X) return 1;
- if (X + 0 < X) return 1;
-
- return 0;
-}
-
-int TestWithSignedUnsigned(int X) {
- if (X + 1 == X + 1ULL) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: logical expression is always true
-
- if ((X & 0xFFU) == 0xF00) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: logical expression is always false
-
- if ((X & 0xFF) == 0xF00U) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: logical expression is always false
-
- if ((X & 0xFFU) == 0xF00U) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: logical expression is always false
-
- return 0;
-}
-
-int TestWithLong(int X, I64 Y) {
- if (X + 0ULL == -X) return 1;
- if (Y + 0 == -Y) return 1;
- if (Y <= 10 && X >= 10LL) return 1;
- if (Y <= 10 && X >= 10ULL) return 1;
- if (X <= 10 || X > 12LL) return 1;
- if (X <= 10 || X > 12ULL) return 1;
- if (Y <= 10 || Y > 12) return 1;
-
- return 0;
-}
-
-int TestWithMinMaxInt(int X) {
- if (X <= X + 0xFFFFFFFFU) return 1;
- if (X <= X + 0x7FFFFFFF) return 1;
- if (X <= X + 0x80000000) return 1;
-
- if (X <= 0xFFFFFFFFU && X > 0) return 1;
- if (X <= 0xFFFFFFFFU && X > 0U) return 1;
-
- if (X + 0x80000000 == X - 0x80000000) return 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: logical expression is always true
-
- if (X > 0x7FFFFFFF || X < ((-0x7FFFFFFF)-1)) return 1;
- if (X <= 0x7FFFFFFF && X >= ((-0x7FFFFFFF)-1)) return 1;
-
- return 0;
-}
-
-#define FLAG1 1
-#define FLAG2 2
-#define FLAG3 4
-#define FLAGS (FLAG1 | FLAG2 | FLAG3)
-#define NOTFLAGS !(FLAG1 | FLAG2 | FLAG3)
-int TestOperatorConfusion(int X, int Y, long Z)
-{
- // Ineffective & expressions.
- Y = (Y << 8) & 0xff;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and operation
- Y = (Y << 12) & 0xfff;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
- Y = (Y << 12) & 0xff;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
- Y = (Y << 8) & 0x77;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and
- Y = (Y << 5) & 0x11;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and
-
- // Tests for unmatched types
- Z = (Z << 8) & 0xff;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and operation
- Y = (Y << 12) & 0xfffL;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
- Z = (Y << 12) & 0xffLL;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
- Y = (Z << 8L) & 0x77L;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: ineffective bitwise and
-
- Y = (Y << 8) & 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: ineffective bitwise and
-
- Y = (Y << 8) & -1;
-
- // Effective expressions. Do not check.
- Y = (Y << 4) & 0x15;
- Y = (Y << 3) & 0x250;
- Y = (Y << 9) & 0xF33;
-
- int K = !(1 | 2 | 4);
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: ineffective logical negation operator used; did you mean '~'?
- // CHECK-FIXES: {{^}} int K = ~(1 | 2 | 4);{{$}}
- K = !(FLAG1 & FLAG2 & FLAG3);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: ineffective logical negation operator
- // CHECK-FIXES: {{^}} K = ~(FLAG1 & FLAG2 & FLAG3);{{$}}
- K = !(3 | 4);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: ineffective logical negation operator
- // CHECK-FIXES: {{^}} K = ~(3 | 4);{{$}}
- int NotFlags = !FLAGS;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: ineffective logical negation operator
- // CHECK-FIXES: {{^}} int NotFlags = ~FLAGS;{{$}}
- NotFlags = NOTFLAGS;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: ineffective logical negation operator
- return !(1 | 2 | 4);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: ineffective logical negation operator
- // CHECK-FIXES: {{^}} return ~(1 | 2 | 4);{{$}}
-}
-
-template <int Shift, int Mask>
-int TestOperatorConfusionDependent(int Y) {
- int r1 = (Y << Shift) & 0xff;
- int r2 = (Y << 8) & Mask;
-}
-#undef FLAG1
-#undef FLAG2
-#undef FLAG3
-
-namespace no_crash {
-struct Foo {};
-bool operator<(const Foo&, const Foo&);
-template <class T>
-struct Bar {
- static const Foo &GetFoo();
- static bool Test(const T & maybe_foo, const Foo& foo) {
- return foo < GetFoo() && foo < maybe_foo;
- }
-};
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.c (removed)
@@ -1,27 +0,0 @@
-// RUN: %check_clang_tidy %s misc-static-assert %t -- -- -std=c11
-// RUN: clang-tidy %s -checks=-*,misc-static-assert -- -std=c99 | count 0
-
-void abort() {}
-#ifdef NDEBUG
-#define assert(x) 1
-#else
-#define assert(x) \
- if (!(x)) \
- abort()
-#endif
-
-void f(void) {
- int x = 1;
- assert(x == 0);
- // CHECK-FIXES: {{^ }}assert(x == 0);
-
- #define static_assert(x, msg) _Static_assert(x, msg)
- assert(11 == 5 + 6);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(11 == 5 + 6, "");
- #undef static_assert
-
- assert(10 == 5 + 5);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(10 == 5 + 5, "");
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-static-assert.cpp (removed)
@@ -1,143 +0,0 @@
-// RUN: %check_clang_tidy %s misc-static-assert %t
-
-void abort() {}
-#ifdef NDEBUG
-#define assert(x) 1
-#else
-#define assert(x) \
- if (!(x)) \
- abort()
-#endif
-
-void print(...);
-
-#define ZERO_MACRO 0
-
-#define False false
-#define FALSE 0
-
-#define my_macro() assert(0 == 1)
-// CHECK-FIXES: #define my_macro() assert(0 == 1)
-
-constexpr bool myfunc(int a, int b) { return a * b == 0; }
-
-typedef __SIZE_TYPE__ size_t;
-extern "C" size_t strlen(const char *s);
-
-class A {
-public:
- bool method() { return true; }
-};
-
-class B {
-public:
- constexpr bool method() { return true; }
-};
-
-template <class T> void doSomething(T t) {
- assert(myfunc(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be replaced by static_assert() [misc-static-assert]
- // CHECK-FIXES: {{^ }}static_assert(myfunc(1, 2), "");
-
- assert(t.method());
- // CHECK-FIXES: {{^ }}assert(t.method());
-
- assert(sizeof(T) == 123);
-}
-
-int main() {
- my_macro();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}my_macro();
-
- assert(myfunc(1, 2) && (3 == 4));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(myfunc(1, 2) && (3 == 4), "");
-
- int x = 1;
- assert(x == 0);
- // CHECK-FIXES: {{^ }}assert(x == 0);
-
- A a;
- B b;
-
- doSomething<A>(a);
- doSomething<B>(b);
-
- assert(false);
- // CHECK-FIXES: {{^ }}assert(false);
-
- assert(False);
- // CHECK-FIXES: {{^ }}assert(False);
- assert(FALSE);
- // CHECK-FIXES: {{^ }}assert(FALSE);
-
- assert(ZERO_MACRO);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(ZERO_MACRO, "");
-
- assert(!"Don't report me!");
- // CHECK-FIXES: {{^ }}assert(!"Don't report me!");
-
- assert(0 && "Don't report me!");
- // CHECK-FIXES: {{^ }}assert(0 && "Don't report me!");
-
- assert(false && "Don't report me!");
- // CHECK-FIXES: {{^ }}assert(false && "Don't report me!");
-
-#define NULL ((void*)0)
- assert(NULL && "Don't report me!");
- // CHECK-FIXES: {{^ }}assert(NULL && "Don't report me!");
-
- assert(NULL == "Don't report me!");
- // CHECK-FIXES: {{^ }}assert(NULL == "Don't report me!");
-
- assert("Don't report me!" == NULL);
- // CHECK-FIXES: {{^ }}assert("Don't report me!" == NULL);
-
- assert(0 == "Don't report me!");
- // CHECK-FIXES: {{^ }}assert(0 == "Don't report me!");
-
-#define NULL ((unsigned int)0)
- assert(NULL && "Report me!");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(NULL , "Report me!");
-
-#define NULL __null
- assert(__null == "Don't report me!");
- // CHECK-FIXES: {{^ }}assert(__null == "Don't report me!");
- assert(NULL == "Don't report me!");
- // CHECK-FIXES: {{^ }}assert(NULL == "Don't report me!");
-#undef NULL
-
- assert(ZERO_MACRO && "Report me!");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(ZERO_MACRO , "Report me!");
-
- assert(0);
-
-#define false false
- assert(false);
-
-#define false 0
- assert(false);
-#undef false
-
- assert(10==5 && "Report me!");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(10==5 , "Report me!");
-
- assert(strlen("12345") == 5);
- // CHECK-FIXES: {{^ }}assert(strlen("12345") == 5);
-
-#define assert(e) (__builtin_expect(!(e), 0) ? print (#e, __FILE__, __LINE__) : (void)0)
- assert(false);
- // CHECK-FIXES: {{^ }}assert(false);
-
- assert(10 == 5 + 5);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: found assert() that could be
- // CHECK-FIXES: {{^ }}static_assert(10 == 5 + 5, "");
-#undef assert
-
- return 0;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-throw-by-value-catch-by-reference.cpp (removed)
@@ -1,156 +0,0 @@
-// RUN: %check_clang_tidy %s misc-throw-by-value-catch-by-reference %t -- -- -fcxx-exceptions
-
-
-class logic_error {
-public:
- logic_error(const char *message) {}
-};
-
-typedef logic_error *logic_ptr;
-typedef logic_ptr logic_double_typedef;
-
-int lastException;
-
-template <class T> struct remove_reference { typedef T type; };
-template <class T> struct remove_reference<T &> { typedef T type; };
-template <class T> struct remove_reference<T &&> { typedef T type; };
-
-template <typename T> typename remove_reference<T>::type &&move(T &&arg) {
- return static_cast<typename remove_reference<T>::type &&>(arg);
-}
-
-logic_error CreateException() { return logic_error("created"); }
-
-void testThrowFunc() {
- throw new logic_error("by pointer");
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: throw expression throws a pointer; it should throw a non-pointer value instead [misc-throw-by-value-catch-by-reference]
- logic_ptr tmp = new logic_error("by pointer");
- throw tmp;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: throw expression should throw anonymous temporary values instead [misc-throw-by-value-catch-by-reference]
- // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: throw expression throws a pointer; it should throw a non-pointer value instead [misc-throw-by-value-catch-by-reference]
- throw logic_error("by value");
- auto *literal = "test";
- throw logic_error(literal);
- throw "test string literal";
- throw L"throw wide string literal";
- const char *characters = 0;
- throw characters;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: throw expression should throw anonymous temporary values instead [misc-throw-by-value-catch-by-reference]
- // CHECK-MESSAGES: :[[@LINE-2]]:9: warning: throw expression throws a pointer; it should throw a non-pointer value instead [misc-throw-by-value-catch-by-reference]
- logic_error lvalue("lvalue");
- throw lvalue;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: throw expression should throw anonymous temporary values instead [misc-throw-by-value-catch-by-reference]
-
- throw move(lvalue);
- int &ex = lastException;
- throw ex;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: throw expression should throw anonymous temporary values instead [misc-throw-by-value-catch-by-reference]
- throw CreateException();
-}
-
-void throwReferenceFunc(logic_error &ref) { throw ref; }
-
-void catchByPointer() {
- try {
- testThrowFunc();
- } catch (logic_error *e) {
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]
- }
-}
-
-void catchByValue() {
- try {
- testThrowFunc();
- } catch (logic_error e) {
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches by value; should catch by reference instead [misc-throw-by-value-catch-by-reference]
- }
-}
-
-void catchByReference() {
- try {
- testThrowFunc();
- } catch (logic_error &e) {
- }
-}
-
-void catchByConstReference() {
- try {
- testThrowFunc();
- } catch (const logic_error &e) {
- }
-}
-
-void catchTypedef() {
- try {
- testThrowFunc();
- } catch (logic_ptr) {
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]
- }
-}
-
-void catchAll() {
- try {
- testThrowFunc();
- } catch (...) {
- }
-}
-
-void catchLiteral() {
- try {
- testThrowFunc();
- } catch (const char *) {
- } catch (const wchar_t *) {
- // disabled for now until it is clear
- // how to enable them in the test
- //} catch (const char16_t*) {
- //} catch (const char32_t*) {
- }
-}
-
-// catching fundamentals should not warn
-void catchFundamental() {
- try {
- testThrowFunc();
- } catch (int) {
- } catch (double) {
- } catch (unsigned long) {
- }
-}
-
-struct TrivialType {
- double x;
- double y;
-};
-
-void catchTrivial() {
- try {
- testThrowFunc();
- } catch (TrivialType) {
- }
-}
-
-typedef logic_error &fine;
-void additionalTests() {
- try {
- } catch (int i) { // ok
- throw i; // ok
- } catch (fine e) { // ok
- throw e; // ok
- } catch (logic_error *e) {
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]
- throw e; // ok, despite throwing a pointer
- } catch (...) { // ok
- throw; // ok
- }
-}
-
-struct S {};
-
-S &returnByReference();
-S returnByValue();
-
-void f() {
- throw returnByReference(); // Should diagnose
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: throw expression should throw anonymous temporary values instead [misc-throw-by-value-catch-by-reference]
- throw returnByValue(); // Should not diagnose
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator-cxx17.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s misc-unconventional-assign-operator %t -- -- -fno-delayed-template-parsing
-
-struct BadModifier {
- BadModifier& operator=(const BadModifier&) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'const'
-};
-
-struct PR35468 {
- template<typename T> auto &operator=(const T &) {
- return *this;
- }
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unconventional-assign-operator.cpp (removed)
@@ -1,111 +0,0 @@
-// RUN: %check_clang_tidy %s misc-unconventional-assign-operator %t -- -- -isystem %S/Inputs/Headers -fno-delayed-template-parsing
-
-namespace std {
-template <typename T>
-struct remove_reference { typedef T type; };
-template <typename T>
-struct remove_reference<T &> { typedef T type; };
-template <typename T>
-struct remove_reference<T &&> { typedef T type; };
-template <typename T>
-typename remove_reference<T>::type &&move(T &&t);
-}
-
-
-struct Good {
- Good& operator=(const Good&);
- Good& operator=(Good&&);
-
- // Assign from other types is fine too.
- Good& operator=(int);
-};
-
-struct AlsoGood {
- // By value is also fine.
- AlsoGood& operator=(AlsoGood);
-};
-
-struct BadReturnType {
- void operator=(const BadReturnType&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'BadReturnType&' [misc-unconventional-assign-operator]
- const BadReturnType& operator=(BadReturnType&&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
- void operator=(int);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-};
-
-struct BadReturnType2 {
- BadReturnType2&& operator=(const BadReturnType2&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
- int operator=(BadReturnType2&&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
-};
-
-struct BadArgument {
- BadArgument& operator=(BadArgument&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadArgument const&', 'BadArgument&&' or 'BadArgument'
- BadArgument& operator=(const BadArgument&&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should take 'BadAr
-};
-
-struct BadModifier {
- BadModifier& operator=(const BadModifier&) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'const'
-};
-
-struct Deleted {
- // We don't check the return value of deleted operators.
- void operator=(const Deleted&) = delete;
- void operator=(Deleted&&) = delete;
-};
-
-class Private {
- // We don't check the return value of private operators.
- // Pre-C++11 way of disabling assignment.
- void operator=(const Private &);
-};
-
-struct Virtual {
- virtual Virtual& operator=(const Virtual &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should not be marked 'virtual'
-};
-
-class BadReturnStatement {
- int n;
-
-public:
- BadReturnStatement& operator=(BadReturnStatement&& rhs) {
- n = std::move(rhs.n);
- return rhs;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: operator=() should always return '*this'
- }
-
- // Do not check if return type is different from '&BadReturnStatement'
- int operator=(int i) {
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: operator=() should return 'Bad
- n = i;
- return n;
- }
-};
-
-namespace pr31531 {
-enum E { e };
-// This declaration makes the 'return *this' below have an unresolved operator
-// in the class template, but not in an instantiation.
-E operator*(E, E);
-
-template <typename>
-struct UnresolvedOperator {
- UnresolvedOperator &operator=(const UnresolvedOperator &) { return *this; }
-};
-
-UnresolvedOperator<int> UnresolvedOperatorInt;
-
-template <typename>
-struct Template {
- Template &operator=(const Template &) { return this; }
- // CHECK-MESSAGES: :[[@LINE-1]]:43: warning: operator=() should always return '*this'
-};
-
-Template<int> TemplateInt;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-uniqueptr-reset-release.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-uniqueptr-reset-release.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-uniqueptr-reset-release.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-uniqueptr-reset-release.cpp (removed)
@@ -1,69 +0,0 @@
-// RUN: %check_clang_tidy %s misc-uniqueptr-reset-release %t
-
-namespace std {
-
-template <typename T>
-struct default_delete {};
-
-template <typename T, class Deleter = std::default_delete<T>>
-struct unique_ptr {
- unique_ptr();
- explicit unique_ptr(T *);
- template <typename U, typename E>
- unique_ptr(unique_ptr<U, E> &&);
- void reset(T *);
- T *release();
-};
-} // namespace std
-
-struct Foo {};
-struct Bar : Foo {};
-
-std::unique_ptr<Foo> Create();
-std::unique_ptr<Foo> &Look();
-std::unique_ptr<Foo> *Get();
-
-using FooFunc = void (*)(Foo *);
-using BarFunc = void (*)(Bar *);
-
-void f() {
- std::unique_ptr<Foo> a, b;
- std::unique_ptr<Bar> c;
- std::unique_ptr<Foo> *x = &a;
- std::unique_ptr<Foo> *y = &b;
-
- a.reset(b.release());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr1 = std::move(ptr2) over ptr1.reset(ptr2.release()) [misc-uniqueptr-reset-release]
- // CHECK-FIXES: a = std::move(b);
- a.reset(c.release());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr1 = std::move(ptr2)
- // CHECK-FIXES: a = std::move(c);
- a.reset(Create().release());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: prefer ptr = ReturnUnique() over ptr.reset(ReturnUnique().release()) [misc-uniqueptr-reset-release]
- // CHECK-FIXES: a = Create();
- x->reset(y->release());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: prefer ptr1 = std::move(ptr2)
- // CHECK-FIXES: *x = std::move(*y);
- Look().reset(Look().release());
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr1 = std::move(ptr2)
- // CHECK-FIXES: Look() = std::move(Look());
- Get()->reset(Get()->release());
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr1 = std::move(ptr2)
- // CHECK-FIXES: *Get() = std::move(*Get());
-
- std::unique_ptr<Bar, FooFunc> func_a, func_b;
- func_a.reset(func_b.release());
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: prefer ptr1 = std::move(ptr2)
- // CHECK-FIXES: func_a = std::move(func_b);
-}
-
-void negatives() {
- std::unique_ptr<Foo> src;
- struct OtherDeleter {};
- std::unique_ptr<Foo, OtherDeleter> dest;
- dest.reset(src.release());
-
- std::unique_ptr<Bar, FooFunc> func_a;
- std::unique_ptr<Bar, BarFunc> func_b;
- func_a.reset(func_b.release());
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-alias-decls.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: %check_clang_tidy %s misc-unused-alias-decls %t
-
-namespace my_namespace {
-class C {};
-}
-
-namespace unused_alias = ::my_namespace; // eol-comments aren't removed (yet)
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: namespace alias decl 'unused_alias' is unused
-// CHECK-FIXES: {{^}}// eol-comments aren't removed (yet)
-
-namespace used_alias = ::my_namespace;
-void f() { used_alias::C c; }
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters-strict.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters-strict.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters-strict.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters-strict.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: %check_clang_tidy %s misc-unused-parameters %t -- \
-// RUN: -config="{CheckOptions: [{key: StrictMode, value: 1}]}" --
-
-// Warn on empty function bodies in StrictMode.
-namespace strict_mode {
-void f(int foo) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'foo' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void f(int /*foo*/) {}{{$}}
-class E {
- int i;
-
-public:
- E(int j) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'j' is unused
-// CHECK-FIXES: {{^}} E(int /*j*/) {}{{$}}
-};
-class F {
- int i;
-
-public:
- F(int j) : i() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'j' is unused
-// CHECK-FIXES: {{^}} F(int /*j*/) : i() {}{{$}}
-};
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.c (removed)
@@ -1,17 +0,0 @@
-// RUN: %check_clang_tidy %s misc-unused-parameters %t -- -- -xc
-
-// Basic removal
-// =============
-void a(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void a(int i) {;}{{$}}
-
-static void b(); // In C, forward declarations can leave out parameters.
-static void b(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: parameter 'i' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}static void b() {;}{{$}}
-
-// Unchanged cases
-// ===============
-void h(i, c, d) int i; char *c, *d; {} // Don't mess with K&R style
-
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-parameters.cpp (removed)
@@ -1,278 +0,0 @@
-// RUN: echo "static void staticFunctionHeader(int i) {;}" > %T/header.h
-// RUN: echo "static void staticFunctionHeader(int /*i*/) {;}" > %T/header-fixed.h
-// RUN: %check_clang_tidy -std=c++11 %s misc-unused-parameters %t -- -header-filter='.*' -- -fno-delayed-template-parsing
-// RUN: diff %T/header.h %T/header-fixed.h
-// FIXME: Make the test work in all language modes.
-
-#include "header.h"
-// CHECK-MESSAGES: header.h:1:38: warning
-
-// Basic removal
-// =============
-void a(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void a(int /*i*/) {;}{{$}}
-
-void b(int i = 1) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void b(int /*i*/ = 1) {;}{{$}}
-
-void c(int *i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'i' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void c(int * /*i*/) {;}{{$}}
-
-void d(int i[]) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void d(int /*i*/[]) {;}{{$}}
-
-void e(int i[1]) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: parameter 'i' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void e(int /*i*/[1]) {;}{{$}}
-
-void f(void (*fn)()) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: parameter 'fn' is unused [misc-unused-parameters]
-// CHECK-FIXES: {{^}}void f(void (* /*fn*/)()) {;}{{$}}
-
-// Unchanged cases
-// ===============
-void f(int i); // Don't remove stuff in declarations
-void g(int i = 1);
-void h(int i[]);
-void s(int i[1]);
-void u(void (*fn)());
-void w(int i) { (void)i; } // Don't remove used parameters
-
-bool useLambda(int (*fn)(int));
-static bool static_var = useLambda([] (int a) { return a; });
-
-// Remove parameters of local functions
-// ====================================
-static void staticFunctionA(int i);
-// CHECK-FIXES: {{^}}static void staticFunctionA();
-static void staticFunctionA(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning
-// CHECK-FIXES: {{^}}static void staticFunctionA()
-
-static void staticFunctionB(int i, int j) { (void)i; }
-// CHECK-MESSAGES: :[[@LINE-1]]:40: warning
-// CHECK-FIXES: {{^}}static void staticFunctionB(int i)
-
-static void staticFunctionC(int i, int j) { (void)j; }
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning
-// CHECK-FIXES: {{^}}static void staticFunctionC(int j)
-
-static void staticFunctionD(int i, int j, int k) { (void)i; (void)k; }
-// CHECK-MESSAGES: :[[@LINE-1]]:40: warning
-// CHECK-FIXES: {{^}}static void staticFunctionD(int i, int k)
-
-static void staticFunctionE(int i = 4) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning
-// CHECK-FIXES: {{^}}static void staticFunctionE()
-
-static void staticFunctionF(int i = 4);
-// CHECK-FIXES: {{^}}static void staticFunctionF();
-static void staticFunctionF(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning
-// CHECK-FIXES: {{^}}static void staticFunctionF()
-
-static void staticFunctionG(int i[]);
-// CHECK-FIXES: {{^}}static void staticFunctionG();
-static void staticFunctionG(int i[]) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning
-// CHECK-FIXES: {{^}}static void staticFunctionG()
-
-static void staticFunctionH(void (*fn)());
-// CHECK-FIXES: {{^}}static void staticFunctionH();
-static void staticFunctionH(void (*fn)()) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:36: warning
-// CHECK-FIXES: {{^}}static void staticFunctionH()
-
-static void someCallSites() {
- staticFunctionA(1);
-// CHECK-FIXES: staticFunctionA();
- staticFunctionB(1, 2);
-// CHECK-FIXES: staticFunctionB(1);
- staticFunctionC(1, 2);
-// CHECK-FIXES: staticFunctionC(2);
- staticFunctionD(1, 2, 3);
-// CHECK-FIXES: staticFunctionD(1, 3);
- staticFunctionE(1);
-// CHECK-FIXES: staticFunctionE();
- staticFunctionF(1);
-// CHECK-FIXES: staticFunctionF();
- staticFunctionF();
-// CHECK-FIXES: staticFunctionF();
- int t[] = {1};
- staticFunctionG(t);
-// CHECK-FIXES: staticFunctionG();
- void func();
- staticFunctionH(&func);
-// CHECK-FIXES: staticFunctionH();
-}
-
-/*
- * FIXME: This fails because the removals overlap and ClangTidy doesn't apply
- * them.
- * static void bothVarsUnused(int a, int b) {;}
- */
-
-// Regression test for long variable names and expressions
-// =======================================================
-static int variableWithLongName1(int LongName1, int LongName2) {
-// CHECK-MESSAGES: :[[@LINE-1]]:53: warning: parameter 'LongName2' is unused
-// CHECK-FIXES: {{^}}static int variableWithLongName1(int LongName1) {
- return LongName1;
-}
-static int variableWithLongName2(int LongName1, int LongName2) {
-// CHECK-MESSAGES: :[[@LINE-1]]:38: warning: parameter 'LongName1' is unused
-// CHECK-FIXES: {{^}}static int variableWithLongName2(int LongName2) {
- return LongName2;
-}
-static void someLongNameCallSites() {
- int LongName1 = 7, LongName2 = 17;
- variableWithLongName1(LongName1, LongName2);
-// CHECK-FIXES: variableWithLongName1(LongName1);
- variableWithLongName2(LongName1, LongName2);
-// CHECK-FIXES: variableWithLongName2(LongName2);
-}
-
-class SomeClass {
- static void f(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning
-// CHECK-FIXES: static void f(int /*i*/) {;}
- static void g(int i = 1) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning
-// CHECK-FIXES: static void g(int /*i*/ = 1) {;}
- static void h(int i[]) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning
-// CHECK-FIXES: static void h(int /*i*/[]) {;}
- static void s(void (*fn)()) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning
-// CHECK-FIXES: static void s(void (* /*fn*/)()) {;}
-};
-
-namespace {
-class C {
-public:
- void f(int i);
-// CHECK-FIXES: void f();
- void g(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
-// CHECK-FIXES: void g() {;}
- void h(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
-// CHECK-FIXES: void h(int /*i*/) {;}
- void s(int i = 1) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
-// CHECK-FIXES: void s(int /*i*/ = 1) {;}
- void u(int i[]) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
-// CHECK-FIXES: void u(int /*i*/[]) {;}
- void w(void (*fn)()) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning
-// CHECK-FIXES: void w(void (* /*fn*/)()) {;}
-};
-
-void C::f(int i) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning
-// CHECK-FIXES: void C::f() {;}
-
-template <typename T>
-void useFunction(T t);
-
-void someMoreCallSites() {
- C c;
- c.f(1);
-// CHECK-FIXES: c.f();
- c.g(1);
-// CHECK-FIXES: c.g();
-
- useFunction(&C::h);
- useFunction(&C::s);
- useFunction(&C::u);
- useFunction(&C::w);
-}
-
-class Base {
- virtual void f(int i);
-};
-
-class Derived : public Base {
- void f(int i) override {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning
-// CHECK-FIXES: void f(int /*i*/) override {;}
-};
-
-} // end namespace
-
-template <typename T> void someFunctionTemplate(T b, T e) { (void)b; (void)e; }
-
-template <typename T> void someFunctionTemplateOneUnusedParam(T b, T e) { (void)e; }
-// CHECK-MESSAGES: :[[@LINE-1]]:65: warning
-// CHECK-FIXES: {{^}}template <typename T> void someFunctionTemplateOneUnusedParam(T /*b*/, T e) { (void)e; }
-
-template <typename T> void someFunctionTemplateAllUnusedParams(T b, T e) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:66: warning
-// CHECK-MESSAGES: :[[@LINE-2]]:71: warning
-// CHECK-FIXES: {{^}}template <typename T> void someFunctionTemplateAllUnusedParams(T /*b*/, T /*e*/) {;}
-
-static void dontGetConfusedByParametersInFunctionTypes() { void (*F)(int i); }
-
-template <typename T> class Function {};
-static Function<void(int, int i)> dontGetConfusedByFunctionReturnTypes() {
- return Function<void(int, int)>();
-}
-
-namespace PR38055 {
-namespace {
-struct a {
- void b(int c) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: parameter 'c' is unused
-// CHECK-FIXES: {{^}} void b() {;}{{$}}
-};
-template <class>
-class d {
- a e;
- void f() { e.b(); }
-};
-} // namespace
-} // namespace PR38055
-
-namespace strict_mode_off {
-// Do not warn on empty function bodies.
-void f1(int foo1) {}
-void f2(int foo2) {
- // "empty" in the AST sense, not in textual sense.
-}
-void f3(int foo3) {;}
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: parameter 'foo3' is unused
-// CHECK-FIXES: {{^}}void f3(int /*foo3*/) {;}{{$}}
-
-class E {
- int i;
-
-public:
- E(int j) {}
-};
-class F {
- int i;
-
-public:
- // Constructor initializer counts as a non-empty body.
- F(int j) : i() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'j' is unused
-// CHECK-FIXES: {{^}} F(int /*j*/) : i() {}{{$}}
-};
-
-class A {
-public:
- A();
- A(int);
-};
-class B : public A {
-public:
- B(int i) : A() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: parameter 'i' is unused
-// CHECK-FIXES: {{^}} B(int /*i*/) : A() {}{{$}}
-};
-} // namespace strict_mode_off
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls-errors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls-errors.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls-errors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls-errors.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: %check_clang_tidy -expect-clang-tidy-error %s misc-unused-using-decls %t
-
-namespace n {
-class C;
-}
-
-using n::C;
-
-void f() {
- for (C *p : unknown()) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:15: error: use of undeclared identifier 'unknown' [clang-diagnostic-error]
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp (removed)
@@ -1,213 +0,0 @@
-// RUN: %check_clang_tidy %s misc-unused-using-decls %t -- -- -fno-delayed-template-parsing -isystem %S/Inputs/
-
-
-// ----- Definitions -----
-template <typename T> class vector {};
-namespace n {
-class A;
-class B;
-class C;
-class D;
-class D { public: static int i; };
-template <typename T> class E {};
-template <typename T> class F {};
-class G { public: static void func() {} };
-class H { public: static int i; };
-class I {
- public:
- static int ii;
-};
-template <typename T> class J {};
-class G;
-class H;
-
-template <typename T> class K {};
-template <template <typename> class S>
-class L {};
-
-template <typename T> class M {};
-class N {};
-
-template <int T> class P {};
-const int Constant = 0;
-
-template <typename T> class Q {};
-
-class Base {
- public:
- void f();
-};
-
-D UsedInstance;
-D UnusedInstance;
-
-int UsedFunc() { return 1; }
-int UnusedFunc() { return 1; }
-template <typename T> int UsedTemplateFunc() { return 1; }
-template <typename T> int UnusedTemplateFunc() { return 1; }
-template <typename T> int UsedInTemplateFunc() { return 1; }
-void OverloadFunc(int);
-void OverloadFunc(double);
-int FuncUsedByUsingDeclInMacro() { return 1; }
-
-class ostream {
-public:
- ostream &operator<<(ostream &(*PF)(ostream &));
-};
-extern ostream cout;
-ostream &endl(ostream &os);
-
-enum Color1 { Green };
-
-enum Color2 { Red };
-
-enum Color3 { Yellow };
-
-enum Color4 { Blue };
-
-} // namespace n
-
-#include "unused-using-decls.h"
-namespace ns {
-template <typename T>
-class AA {
- T t;
-};
-template <typename T>
-T ff() { T t; return t; }
-} // namespace ns
-
-// ----- Using declarations -----
-// eol-comments aren't removed (yet)
-using n::A; // A
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'A' is unused
-// CHECK-MESSAGES: :[[@LINE-2]]:10: note: remove the using
-// CHECK-FIXES: {{^}}// A
-using n::B;
-using n::C;
-using n::D;
-using n::E; // E
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'E' is unused
-// CHECK-FIXES: {{^}}// E
-using n::F;
-using n::G;
-using n::H;
-using n::I;
-int I::ii = 1;
-class Derived : public n::Base {
- public:
- using Base::f;
-};
-using n::UsedInstance;
-using n::UsedFunc;
-using n::UsedTemplateFunc;
-using n::UnusedInstance; // UnusedInstance
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedInstance' is unused
-// CHECK-FIXES: {{^}}// UnusedInstance
-using n::UnusedFunc; // UnusedFunc
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'UnusedFunc' is unused
-// CHECK-FIXES: {{^}}// UnusedFunc
-using n::cout;
-using n::endl;
-
-using n::UsedInTemplateFunc;
-using n::J;
-template <typename T> void Callee() {
- J<T> j;
- UsedInTemplateFunc<T>();
-}
-
-using n::OverloadFunc; // OverloadFunc
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'OverloadFunc' is unused
-// CHECK-FIXES: {{^}}// OverloadFunc
-
-#define DEFINE_INT(name) \
- namespace INT { \
- static const int _##name = 1; \
- } \
- using INT::_##name
-DEFINE_INT(test);
-#undef DEFIND_INT
-
-#define USING_FUNC \
- using n::FuncUsedByUsingDeclInMacro;
-USING_FUNC
-#undef USING_FUNC
-
-namespace N1 {
-// n::G is used in namespace N2.
-// Currently, the check doesn't support multiple scopes. All the relevant
-// using-decls will be marked as used once we see an usage even the usage is in
-// other scope.
-using n::G;
-}
-
-namespace N2 {
-using n::G;
-void f(G g);
-}
-
-void IgnoreFunctionScope() {
-// Using-decls defined in function scope will be ignored.
-using n::H;
-}
-
-using n::Color1;
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Color1' is unused
-using n::Green;
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Green' is unused
-using n::Color2;
-using n::Color3;
-using n::Blue;
-
-using ns::AA;
-using ns::ff;
-
-using n::K;
-
-using n::N;
-
-// FIXME: Currently non-type template arguments are not supported.
-using n::Constant;
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
-
-using n::Q;
-
-// ----- Usages -----
-void f(B b);
-void g() {
- vector<C> data;
- D::i = 1;
- F<int> f;
- void (*func)() = &G::func;
- int *i = &H::i;
- UsedInstance.i;
- UsedFunc();
- UsedTemplateFunc<int>();
- cout << endl;
- Color2 color2;
- int t1 = Color3::Yellow;
- int t2 = Blue;
-
- MyClass a;
- int t3 = 0;
- a.func1<AA>(&t3);
- a.func2<int, ff>(t3);
-
- n::L<K> l;
-}
-
-template<class T>
-void h(n::M<T>* t) {}
-// n::N is used the explicit template instantiation.
-template void h(n::M<N>* t);
-
-// Test on Non-type template arguments.
-template <int T>
-void i(n::P<T>* t) {}
-template void i(n::P<Constant>* t);
-
-template <typename T, template <typename> class U> class Bar {};
-// We used to report Q unsued, because we only checked the first template
-// argument.
-Bar<int, Q> *bar;
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-bind.cpp (removed)
@@ -1,123 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-avoid-bind %t
-
-namespace std {
-inline namespace impl {
-template <class Fp, class... Arguments>
-class bind_rt {};
-
-template <class Fp, class... Arguments>
-bind_rt<Fp, Arguments...> bind(Fp &&, Arguments &&...);
-}
-}
-
-int add(int x, int y) { return x + y; }
-
-void f() {
- auto clj = std::bind(add, 2, 2);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [modernize-avoid-bind]
- // CHECK-FIXES: auto clj = [] { return add(2, 2); };
-}
-
-void g() {
- int x = 2;
- int y = 2;
- auto clj = std::bind(add, x, y);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
- // CHECK-FIXES: auto clj = [=] { return add(x, y); };
-}
-
-struct placeholder {};
-placeholder _1;
-placeholder _2;
-
-void h() {
- int x = 2;
- auto clj = std::bind(add, x, _1);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
- // CHECK-FIXES: auto clj = [=](auto && arg1) { return add(x, arg1); };
-}
-
-struct A;
-struct B;
-bool ABTest(const A &, const B &);
-
-void i() {
- auto BATest = std::bind(ABTest, _2, _1);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer a lambda to std::bind
- // CHECK-FIXES: auto BATest = [](auto && arg1, auto && arg2) { return ABTest(arg2, arg1); };
-}
-
-void j() {
- auto clj = std::bind(add, 2, 2, 2);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
- // No fix is applied for argument mismatches.
- // CHECK-FIXES: auto clj = std::bind(add, 2, 2, 2);
-}
-
-void k() {
- auto clj = std::bind(add, _1, _1);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
- // No fix is applied for reused placeholders.
- // CHECK-FIXES: auto clj = std::bind(add, _1, _1);
-}
-
-void m() {
- auto clj = std::bind(add, 1, add(2, 5));
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
- // No fix is applied for nested calls.
- // CHECK-FIXES: auto clj = std::bind(add, 1, add(2, 5));
-}
-
-namespace C {
- int add(int x, int y){ return x + y; }
-}
-
-void n() {
- auto clj = std::bind(C::add, 1, 1);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
- // CHECK-FIXES: auto clj = [] { return C::add(1, 1); };
-}
-
-// Let's fake a minimal std::function-like facility.
-namespace std {
-template <typename _Tp>
-_Tp declval();
-
-template <typename _Functor, typename... _ArgTypes>
-struct __res {
- template <typename... _Args>
- static decltype(declval<_Functor>()(_Args()...)) _S_test(int);
-
- template <typename...>
- static void _S_test(...);
-
- using type = decltype(_S_test<_ArgTypes...>(0));
-};
-
-template <typename>
-struct function;
-
-template <typename... _ArgTypes>
-struct function<void(_ArgTypes...)> {
- template <typename _Functor,
- typename = typename __res<_Functor, _ArgTypes...>::type>
- function(_Functor) {}
-};
-} // namespace std
-
-struct Thing {};
-void UseThing(Thing *);
-
-struct Callback {
- Callback();
- Callback(std::function<void()>);
- void Reset(std::function<void()>);
-};
-
-void test(Thing *t) {
- Callback cb;
- if (t)
- cb.Reset(std::bind(UseThing, t));
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind
- // CHECK-FIXES: cb.Reset([=] { return UseThing(t); });
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-main.cpp (removed)
@@ -1,18 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-avoid-c-arrays %t
-
-int not_main(int argc, char *argv[]) {
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead
- int f4[] = {1, 2};
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-}
-
-int main(int argc, char *argv[]) {
- int f5[] = {1, 2};
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-
- auto not_main = [](int argc, char *argv[]) {
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use std::array<> instead
- int f6[] = {1, 2};
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
- };
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-three-arg-main.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-three-arg-main.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-three-arg-main.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays-ignores-three-arg-main.cpp (removed)
@@ -1,20 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-avoid-c-arrays %t
-
-int not_main(int argc, char *argv[], char *argw[]) {
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not declare C-style arrays, use std::array<> instead
- // CHECK-MESSAGES: :[[@LINE-2]]:38: warning: do not declare C-style arrays, use std::array<> instead
- int f4[] = {1, 2};
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-}
-
-int main(int argc, char *argv[], char *argw[]) {
- int f5[] = {1, 2};
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-
- auto not_main = [](int argc, char *argv[], char *argw[]) {
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: do not declare C-style arrays, use std::array<> instead
- // CHECK-MESSAGES: :[[@LINE-2]]:46: warning: do not declare C-style arrays, use std::array<> instead
- int f6[] = {1, 2};
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: do not declare C-style arrays, use std::array<> instead
- };
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-avoid-c-arrays.cpp (removed)
@@ -1,88 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-avoid-c-arrays %t
-
-int a[] = {1, 2};
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
-
-int b[1];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
-
-void foo() {
- int c[b[0]];
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C VLA arrays, use std::vector<> instead
-
- using d = decltype(c);
- d e;
- // Semi-FIXME: we do not diagnose these last two lines separately,
- // because we point at typeLoc.getBeginLoc(), which is the decl before that
- // (int c[b[0]];), which is already diagnosed.
-}
-
-template <typename T, int Size>
-class array {
- T d[Size];
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-
- int e[1];
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-};
-
-array<int[4], 2> d;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: do not declare C-style arrays, use std::array<> instead
-
-using k = int[4];
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not declare C-style arrays, use std::array<> instead
-
-array<k, 2> dk;
-
-template <typename T>
-class unique_ptr {
- T *d;
-
- int e[1];
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-};
-
-unique_ptr<int[]> d2;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use std::array<> instead
-
-using k2 = int[];
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: do not declare C-style arrays, use std::array<> instead
-
-unique_ptr<k2> dk2;
-
-// Some header
-extern "C" {
-
-int f[] = {1, 2};
-
-int j[1];
-
-inline void bar() {
- {
- int j[j[0]];
- }
-}
-
-extern "C++" {
-int f3[] = {1, 2};
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
-
-int j3[1];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: do not declare C-style arrays, use std::array<> instead
-
-struct Foo {
- int f3[3] = {1, 2};
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-
- int j3[1];
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: do not declare C-style arrays, use std::array<> instead
-};
-}
-
-struct Bar {
-
- int f[3] = {1, 2};
-
- int j[1];
-};
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-concat-nested-namespaces.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-concat-nested-namespaces.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-concat-nested-namespaces.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-concat-nested-namespaces.cpp (removed)
@@ -1,161 +0,0 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-concat-nested-namespaces %t
-
-namespace n1 {}
-
-namespace n2 {
-namespace n3 {
-void t();
-}
-namespace n4 {
-void t();
-}
-} // namespace n2
-
-namespace n5 {
-inline namespace n6 {
-void t();
-}
-} // namespace n5
-
-namespace n7 {
-void t();
-
-namespace n8 {
-void t();
-}
-} // namespace n7
-
-namespace n9 {
-namespace n10 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n9::n10
-void t();
-} // namespace n10
-} // namespace n9
-// CHECK-FIXES: }
-
-namespace n11 {
-namespace n12 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n11::n12
-namespace n13 {
-void t();
-}
-namespace n14 {
-void t();
-}
-} // namespace n12
-} // namespace n11
-// CHECK-FIXES: }
-
-namespace n15 {
-namespace n16 {
-void t();
-}
-
-inline namespace n17 {
-void t();
-}
-
-namespace n18 {
-namespace n19 {
-namespace n20 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n18::n19::n20
-void t();
-} // namespace n20
-} // namespace n19
-} // namespace n18
-// CHECK-FIXES: }
-
-namespace n21 {
-void t();
-}
-} // namespace n15
-
-namespace n22 {
-namespace {
-void t();
-}
-} // namespace n22
-
-namespace n23 {
-namespace {
-namespace n24 {
-namespace n25 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n24::n25
-void t();
-} // namespace n25
-} // namespace n24
-// CHECK-FIXES: }
-} // namespace
-} // namespace n23
-
-namespace n26::n27 {
-namespace n28 {
-namespace n29::n30 {
-// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n26::n27::n28::n29::n30
-void t() {}
-} // namespace n29::n30
-} // namespace n28
-} // namespace n26::n27
-// CHECK-FIXES: }
-
-namespace n31 {
-namespace n32 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-} // namespace n31
-// CHECK-FIXES-EMPTY
-
-namespace n33 {
-namespace n34 {
-namespace n35 {}
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-} // namespace n34
-// CHECK-FIXES-EMPTY
-namespace n36 {
-void t();
-}
-} // namespace n33
-
-namespace n37::n38 {
-void t();
-}
-
-#define IEXIST
-namespace n39 {
-namespace n40 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n39::n40
-#ifdef IEXIST
-void t() {}
-#endif
-} // namespace n40
-} // namespace n39
-// CHECK-FIXES: }
-
-namespace n41 {
-namespace n42 {
-// CHECK-MESSAGES: :[[@LINE-2]]:1: warning: nested namespaces can be concatenated [modernize-concat-nested-namespaces]
-// CHECK-FIXES: namespace n41::n42
-#ifdef IDONTEXIST
-void t() {}
-#endif
-} // namespace n42
-} // namespace n41
-// CHECK-FIXES: }
-
-int main() {
- n26::n27::n28::n29::n30::t();
-#ifdef IEXIST
- n39::n40::t();
-#endif
-
-#ifdef IDONTEXIST
- n41::n42::t();
-#endif
-
- return 0;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx03.cpp (removed)
@@ -1,148 +0,0 @@
-// RUN: %check_clang_tidy -std=c++98 %s modernize-deprecated-headers %t -- -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers
-
-#include <assert.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
-// CHECK-FIXES: {{^}}#include <cassert>{{$}}
-#include <complex.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'complex' instead
-// CHECK-FIXES: {{^}}#include <complex>{{$}}
-#include <ctype.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead
-// CHECK-FIXES: {{^}}#include <cctype>{{$}}
-#include <errno.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead
-// CHECK-FIXES: {{^}}#include <cerrno>{{$}}
-#include <float.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead
-// CHECK-FIXES: {{^}}#include <cfloat>{{$}}
-#include <limits.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead
-// CHECK-FIXES: {{^}}#include <climits>{{$}}
-#include <locale.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead
-// CHECK-FIXES: {{^}}#include <clocale>{{$}}
-#include <math.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead
-// CHECK-FIXES: {{^}}#include <cmath>{{$}}
-#include <setjmp.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead
-// CHECK-FIXES: {{^}}#include <csetjmp>{{$}}
-#include <signal.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead
-// CHECK-FIXES: {{^}}#include <csignal>{{$}}
-#include <stdarg.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead
-// CHECK-FIXES: {{^}}#include <cstdarg>{{$}}
-#include <stddef.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead
-// CHECK-FIXES: {{^}}#include <cstddef>{{$}}
-#include <stdio.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead
-// CHECK-FIXES: {{^}}#include <cstdio>{{$}}
-#include <stdlib.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead
-// CHECK-FIXES: {{^}}#include <cstdlib>{{$}}
-#include <string.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead
-// CHECK-FIXES: {{^}}#include <cstring>{{$}}
-#include <time.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead
-// CHECK-FIXES: {{^}}#include <ctime>{{$}}
-#include <wchar.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead
-// CHECK-FIXES: {{^}}#include <cwchar>{{$}}
-#include <wctype.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead
-// CHECK-FIXES: {{^}}#include <cwctype>{{$}}
-
-// Headers that have no effect in C++; remove them
-#include <stdalign.h> // <stdalign.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// <stdalign.h>{{$}}
-#include <stdbool.h> // <stdbool.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// <stdbool.h>{{$}}
-#include <iso646.h> // <iso646.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'iso646.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// <iso646.h>{{$}}
-
-// Headers deprecated since C++11: expect no diagnostics.
-#include <fenv.h>
-#include <inttypes.h>
-#include <stdint.h>
-#include <tgmath.h>
-#include <uchar.h>
-
-
-#include "assert.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead
-// CHECK-FIXES: {{^}}#include <cassert>{{$}}
-#include "complex.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'complex' instead
-// CHECK-FIXES: {{^}}#include <complex>{{$}}
-#include "ctype.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead
-// CHECK-FIXES: {{^}}#include <cctype>{{$}}
-#include "errno.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead
-// CHECK-FIXES: {{^}}#include <cerrno>{{$}}
-#include "float.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead
-// CHECK-FIXES: {{^}}#include <cfloat>{{$}}
-#include "limits.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead
-// CHECK-FIXES: {{^}}#include <climits>{{$}}
-#include "locale.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead
-// CHECK-FIXES: {{^}}#include <clocale>{{$}}
-#include "math.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead
-// CHECK-FIXES: {{^}}#include <cmath>{{$}}
-#include "setjmp.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead
-// CHECK-FIXES: {{^}}#include <csetjmp>{{$}}
-#include "signal.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead
-// CHECK-FIXES: {{^}}#include <csignal>{{$}}
-#include "stdarg.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead
-// CHECK-FIXES: {{^}}#include <cstdarg>{{$}}
-#include "stddef.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead
-// CHECK-FIXES: {{^}}#include <cstddef>{{$}}
-#include "stdio.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead
-// CHECK-FIXES: {{^}}#include <cstdio>{{$}}
-#include "stdlib.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead
-// CHECK-FIXES: {{^}}#include <cstdlib>{{$}}
-#include "string.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead
-// CHECK-FIXES: {{^}}#include <cstring>{{$}}
-#include "time.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead
-// CHECK-FIXES: {{^}}#include <ctime>{{$}}
-#include "wchar.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead
-// CHECK-FIXES: {{^}}#include <cwchar>{{$}}
-#include "wctype.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead
-// CHECK-FIXES: {{^}}#include <cwctype>
-
-// Headers that have no effect in C++; remove them
-#include "stdalign.h" // "stdalign.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// "stdalign.h"{{$}}
-#include "stdbool.h" // "stdbool.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// "stdbool.h"{{$}}
-#include "iso646.h" // "iso646.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'iso646.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// "iso646.h"{{$}}
-
-// Headers deprecated since C++11; expect no diagnostics
-#include "fenv.h"
-#include "inttypes.h"
-#include "stdint.h"
-#include "tgmath.h"
-#include "uchar.h"
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-headers-cxx11.cpp (removed)
@@ -1,163 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11-or-later %s modernize-deprecated-headers %t -- -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers
-
-#include <assert.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead [modernize-deprecated-headers]
-// CHECK-FIXES: {{^}}#include <cassert>{{$}}
-#include <complex.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'complex' instead
-// CHECK-FIXES: {{^}}#include <complex>{{$}}
-#include <ctype.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead
-// CHECK-FIXES: {{^}}#include <cctype>{{$}}
-#include <errno.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead
-// CHECK-FIXES: {{^}}#include <cerrno>{{$}}
-#include <fenv.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'fenv.h'; consider using 'cfenv' instead
-// CHECK-FIXES: {{^}}#include <cfenv>{{$}}
-#include <float.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead
-// CHECK-FIXES: {{^}}#include <cfloat>{{$}}
-#include <inttypes.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead
-// CHECK-FIXES: {{^}}#include <cinttypes>{{$}}
-#include <limits.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead
-// CHECK-FIXES: {{^}}#include <climits>{{$}}
-#include <locale.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead
-// CHECK-FIXES: {{^}}#include <clocale>{{$}}
-#include <math.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead
-// CHECK-FIXES: {{^}}#include <cmath>{{$}}
-#include <setjmp.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead
-// CHECK-FIXES: {{^}}#include <csetjmp>{{$}}
-#include <signal.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead
-// CHECK-FIXES: {{^}}#include <csignal>{{$}}
-#include <stdarg.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead
-// CHECK-FIXES: {{^}}#include <cstdarg>{{$}}
-#include <stddef.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead
-// CHECK-FIXES: {{^}}#include <cstddef>{{$}}
-#include <stdint.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead
-// CHECK-FIXES: {{^}}#include <cstdint>{{$}}
-#include <stdio.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead
-// CHECK-FIXES: {{^}}#include <cstdio>{{$}}
-#include <stdlib.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead
-// CHECK-FIXES: {{^}}#include <cstdlib>{{$}}
-#include <string.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead
-// CHECK-FIXES: {{^}}#include <cstring>{{$}}
-#include <tgmath.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'tgmath.h'; consider using 'ctgmath' instead
-// CHECK-FIXES: {{^}}#include <ctgmath>{{$}}
-#include <time.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead
-// CHECK-FIXES: {{^}}#include <ctime>{{$}}
-#include <uchar.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'uchar.h'; consider using 'cuchar' instead
-// CHECK-FIXES: {{^}}#include <cuchar>{{$}}
-#include <wchar.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead
-// CHECK-FIXES: {{^}}#include <cwchar>{{$}}
-#include <wctype.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead
-// CHECK-FIXES: {{^}}#include <cwctype>
-
-// Headers that have no effect in C++; remove them
-#include <stdalign.h> // <stdalign.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// <stdalign.h>{{$}}
-#include <stdbool.h> // <stdbool.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// <stdbool.h>{{$}}
-#include <iso646.h> // <iso646.h>
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'iso646.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// <iso646.h>{{$}}
-
-#include "assert.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'assert.h'; consider using 'cassert' instead
-// CHECK-FIXES: {{^}}#include <cassert>{{$}}
-#include "complex.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'complex.h'; consider using 'complex' instead
-// CHECK-FIXES: {{^}}#include <complex>{{$}}
-#include "ctype.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'ctype.h'; consider using 'cctype' instead
-// CHECK-FIXES: {{^}}#include <cctype>{{$}}
-#include "errno.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'errno.h'; consider using 'cerrno' instead
-// CHECK-FIXES: {{^}}#include <cerrno>{{$}}
-#include "fenv.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'fenv.h'; consider using 'cfenv' instead
-// CHECK-FIXES: {{^}}#include <cfenv>{{$}}
-#include "float.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'float.h'; consider using 'cfloat' instead
-// CHECK-FIXES: {{^}}#include <cfloat>{{$}}
-#include "inttypes.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'inttypes.h'; consider using 'cinttypes' instead
-// CHECK-FIXES: {{^}}#include <cinttypes>{{$}}
-#include "limits.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'limits.h'; consider using 'climits' instead
-// CHECK-FIXES: {{^}}#include <climits>{{$}}
-#include "locale.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'locale.h'; consider using 'clocale' instead
-// CHECK-FIXES: {{^}}#include <clocale>{{$}}
-#include "math.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead
-// CHECK-FIXES: {{^}}#include <cmath>{{$}}
-#include "setjmp.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'setjmp.h'; consider using 'csetjmp' instead
-// CHECK-FIXES: {{^}}#include <csetjmp>{{$}}
-#include "signal.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'signal.h'; consider using 'csignal' instead
-// CHECK-FIXES: {{^}}#include <csignal>{{$}}
-#include "stdarg.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdarg.h'; consider using 'cstdarg' instead
-// CHECK-FIXES: {{^}}#include <cstdarg>{{$}}
-#include "stddef.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stddef.h'; consider using 'cstddef' instead
-// CHECK-FIXES: {{^}}#include <cstddef>{{$}}
-#include "stdint.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdint.h'; consider using 'cstdint' instead
-// CHECK-FIXES: {{^}}#include <cstdint>{{$}}
-#include "stdio.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdio.h'; consider using 'cstdio' instead
-// CHECK-FIXES: {{^}}#include <cstdio>{{$}}
-#include "stdlib.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'stdlib.h'; consider using 'cstdlib' instead
-// CHECK-FIXES: {{^}}#include <cstdlib>{{$}}
-#include "string.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'string.h'; consider using 'cstring' instead
-// CHECK-FIXES: {{^}}#include <cstring>{{$}}
-#include "tgmath.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'tgmath.h'; consider using 'ctgmath' instead
-// CHECK-FIXES: {{^}}#include <ctgmath>{{$}}
-#include "time.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'time.h'; consider using 'ctime' instead
-// CHECK-FIXES: {{^}}#include <ctime>{{$}}
-#include "uchar.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'uchar.h'; consider using 'cuchar' instead
-// CHECK-FIXES: {{^}}#include <cuchar>{{$}}
-#include "wchar.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wchar.h'; consider using 'cwchar' instead
-// CHECK-FIXES: {{^}}#include <cwchar>{{$}}
-#include "wctype.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: inclusion of deprecated C++ header 'wctype.h'; consider using 'cwctype' instead
-// CHECK-FIXES: {{^}}#include <cwctype>
-
-// Headers that have no effect in C++; remove them
-#include "stdalign.h" // "stdalign.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdalign.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// "stdalign.h"{{$}}
-#include "stdbool.h" // "stdbool.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'stdbool.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// "stdbool.h"{{$}}
-#include "iso646.h" // "iso646.h"
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: including 'iso646.h' has no effect in C++; consider removing it
-// CHECK-FIXES: {{^}}// "iso646.h"{{$}}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-ios-base-aliases.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-ios-base-aliases.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-ios-base-aliases.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-deprecated-ios-base-aliases.cpp (removed)
@@ -1,239 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-deprecated-ios-base-aliases %t
-
-namespace std {
-class ios_base {
-public:
- typedef int io_state;
- typedef int open_mode;
- typedef int seek_dir;
-
- typedef int streampos;
- typedef int streamoff;
-};
-
-template <class CharT>
-class basic_ios : public ios_base {
-};
-} // namespace std
-
-// Test function return values (declaration)
-std::ios_base::io_state f_5();
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'std::ios_base::io_state' is deprecated; use 'std::ios_base::iostate' instead [modernize-deprecated-ios-base-aliases]
-// CHECK-FIXES: std::ios_base::iostate f_5();
-
-// Test function parameters.
-void f_6(std::ios_base::open_mode);
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 'std::ios_base::open_mode' is deprecated
-// CHECK-FIXES: void f_6(std::ios_base::openmode);
-void f_7(const std::ios_base::seek_dir &);
-// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'std::ios_base::seek_dir' is deprecated
-// CHECK-FIXES: void f_7(const std::ios_base::seekdir &);
-
-// Test on record type fields.
-struct A {
- std::ios_base::io_state field;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std::ios_base::iostate field;
-
- typedef std::ios_base::io_state int_ptr_type;
- // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: typedef std::ios_base::iostate int_ptr_type;
-};
-
-struct B : public std::ios_base {
- io_state a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: iostate a;
-};
-
-struct C : public std::basic_ios<char> {
- io_state a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: iostate a;
-};
-
-void f_1() {
- std::ios_base::io_state a;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std::ios_base::iostate a;
-
- // Check that spaces aren't modified unnecessarily.
- std :: ios_base :: io_state b;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std :: ios_base :: iostate b;
-
- // Test construction from a temporary.
- std::ios_base::io_state c = std::ios_base::io_state{};
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-MESSAGES: :[[@LINE-2]]:46: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std::ios_base::iostate c = std::ios_base::iostate{};
-
- typedef std::ios_base::io_state alias1;
- // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: typedef std::ios_base::iostate alias1;
- alias1 d(a);
-
- using alias2 = std::ios_base::io_state;
- // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: using alias2 = std::ios_base::iostate;
- alias2 e;
-
- // Test pointers.
- std::ios_base::io_state *f;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std::ios_base::iostate *f;
-
- // Test 'static' declarations.
- static std::ios_base::io_state g;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: static std::ios_base::iostate g;
-
- // Test with cv-qualifiers.
- const std::ios_base::io_state h(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: const std::ios_base::iostate h(0);
- volatile std::ios_base::io_state i;
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: volatile std::ios_base::iostate i;
- const volatile std::ios_base::io_state j(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: const volatile std::ios_base::iostate j(0);
-
- // Test auto and initializer-list.
- auto k = std::ios_base::io_state{};
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: auto k = std::ios_base::iostate{};
-
- std::ios_base::io_state l{std::ios_base::io_state()};
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std::ios_base::iostate l{std::ios_base::iostate()};
-
- // Test temporaries.
- std::ios_base::io_state();
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std::ios_base::iostate();
-
- // Test inherited type usage
- std::basic_ios<char>::io_state m;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: std::basic_ios<char>::iostate m;
-
- std::ios_base::streampos n;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::streampos' is deprecated [modernize-deprecated-ios-base-aliases]
-
- std::ios_base::streamoff o;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 'std::ios_base::streamoff' is deprecated [modernize-deprecated-ios-base-aliases]
-}
-
-// Test without the nested name specifiers.
-void f_2() {
- using namespace std;
-
- ios_base::io_state a;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: ios_base::iostate a;
-}
-
-// Test messing-up with macros.
-void f_4() {
-#define MACRO_1 std::ios_base::io_state
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: 'std::ios_base::io_state' is deprecated
- MACRO_1 a;
-
-#define MACRO_2 io_state
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 'std::ios_base::io_state' is deprecated
- std::ios_base::MACRO_2 b;
-
-#define MACRO_3 std::ios_base
- MACRO_3::io_state c;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: 'std::ios_base::io_state' is deprecated
-
-#define MACRO_4(type) type::io_state
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: 'std::ios_base::io_state' is deprecated
- MACRO_4(std::ios_base) d;
-
-#undef MACRO_1
-#undef MACRO_2
-#undef MACRO_3
-#undef MACRO_4
-}
-
-// Test function return values (definition).
-std::ios_base::io_state f_5()
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'std::ios_base::io_state' is deprecated
-// CHECK-FIXES: std::ios_base::iostate f_5()
-{
- // Test constructor.
- return std::ios_base::io_state(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: return std::ios_base::iostate(0);
-}
-
-// Test that other aliases with same name aren't replaced
-struct my_ios_base {
- typedef int io_state;
-};
-
-namespace ns_1 {
-struct my_ios_base2 {
- typedef int io_state;
-};
-} // namespace ns_1
-
-void f_8() {
- my_ios_base::io_state a;
-
- ns_1::my_ios_base2::io_state b;
-}
-
-// Test templates
-template <typename X>
-void f_9() {
- typename std::basic_ios<X>::io_state p;
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'std::ios_base::io_state' is deprecated
- typename std::ios_base::io_state q;
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: typename std::ios_base::iostate q;
-}
-
-template <typename T>
-void f_10(T arg) {
- T x(arg);
-}
-
-template <typename T>
-void f_11() {
- typename T::io_state x{};
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: 'std::ios_base::io_state' is deprecated
-}
-
-template <typename T>
-struct D : std::ios_base {
- io_state a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: iostate a;
-
- typename std::basic_ios<T>::io_state b;
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: 'std::ios_base::io_state' is deprecated
-};
-
-template <typename T>
-struct E {
- T t;
-};
-
-void f_12() {
- f_9<char>();
-
- f_10<std::ios_base::io_state>(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: f_10<std::ios_base::iostate>(0);
-
- f_11<std::ios_base>();
- D<char> d;
-
- E<std::ios_base::io_state> e;
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 'std::ios_base::io_state' is deprecated
- // CHECK-FIXES: E<std::ios_base::iostate> e;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-assert-failure.cpp (removed)
@@ -1,18 +0,0 @@
-// RUN: not clang-tidy %s -checks=-*,modernize-loop-convert --
-
-// Note: this test expects no assert failure happened in clang-tidy.
-
-class LinguisticItem {
- LinguisticItem *x0;
- class x1 {
- bool operator!= ( const x1 &;
- operator* ( ;
- LinguisticItem * &operator-> ( ;
- operator++ (
- } begin() const;
- x1 end() const {
- LinguisticStream x2;
- for (x1 x3 = x2.begin x3 != x2.end; ++x3)
- x3->x0
- }
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-basic.cpp (removed)
@@ -1,796 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -- -I %S/Inputs/modernize-loop-convert
-
-#include "structures.h"
-
-namespace Array {
-
-const int N = 6;
-const int NMinusOne = N - 1;
-int Arr[N] = {1, 2, 3, 4, 5, 6};
-const int ConstArr[N] = {1, 2, 3, 4, 5, 6};
-int (*PArr)[N] = &Arr;
-
-void f() {
- int Sum = 0;
-
- for (int I = 0; I < N; ++I) {
- Sum += Arr[I];
- int K;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead [modernize-loop-convert]
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: Sum += I;
- // CHECK-FIXES-NEXT: int K;
-
- for (int I = 0; I < N; ++I) {
- printf("Fibonacci number is %d\n", Arr[I]);
- Sum += Arr[I] + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2;
-
- for (int I = 0; I < N; ++I) {
- int X = Arr[I];
- int Y = Arr[I] + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: int X = I;
- // CHECK-FIXES-NEXT: int Y = I + 2;
-
- for (int I = 0; I < N; ++I) {
- int X = N;
- X = Arr[I];
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: int X = N;
- // CHECK-FIXES-NEXT: X = I;
-
- for (int I = 0; I < N; ++I) {
- Arr[I] += 1;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Arr)
- // CHECK-FIXES-NEXT: I += 1;
-
- for (int I = 0; I < N; ++I) {
- int X = Arr[I] + 2;
- Arr[I]++;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Arr)
- // CHECK-FIXES-NEXT: int X = I + 2;
- // CHECK-FIXES-NEXT: I++;
-
- for (int I = 0; I < N; ++I) {
- Arr[I] = 4 + Arr[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Arr)
- // CHECK-FIXES-NEXT: I = 4 + I;
-
- for (int I = 0; I < NMinusOne + 1; ++I) {
- Sum += Arr[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: Sum += I;
-
- for (int I = 0; I < N; ++I) {
- printf("Fibonacci number %d has address %p\n", Arr[I], &Arr[I]);
- Sum += Arr[I] + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Arr)
- // CHECK-FIXES-NEXT: printf("Fibonacci number %d has address %p\n", I, &I);
- // CHECK-FIXES-NEXT: Sum += I + 2;
-
- Val Teas[N];
- for (int I = 0; I < N; ++I) {
- Teas[I].g();
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & Tea : Teas)
- // CHECK-FIXES-NEXT: Tea.g();
-}
-
-const int *constArray() {
- for (int I = 0; I < N; ++I) {
- printf("2 * %d = %d\n", ConstArr[I], ConstArr[I] + ConstArr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : ConstArr)
- // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", I, I + I);
-
- const NonTriviallyCopyable NonCopy[N]{};
- for (int I = 0; I < N; ++I) {
- printf("2 * %d = %d\n", NonCopy[I].X, NonCopy[I].X + NonCopy[I].X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (const auto & I : NonCopy)
- // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", I.X, I.X + I.X);
-
- const TriviallyCopyableButBig Big[N]{};
- for (int I = 0; I < N; ++I) {
- printf("2 * %d = %d\n", Big[I].X, Big[I].X + Big[I].X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (const auto & I : Big)
- // CHECK-FIXES-NEXT: printf("2 * %d = %d\n", I.X, I.X + I.X);
-
- bool Something = false;
- for (int I = 0; I < N; ++I) {
- if (Something)
- return &ConstArr[I];
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (const int & I : ConstArr)
- // CHECK-FIXES-NEXT: if (Something)
- // CHECK-FIXES-NEXT: return &I;
-}
-
-struct HasArr {
- int Arr[N];
- Val ValArr[N];
- void implicitThis() {
- for (int I = 0; I < N; ++I) {
- printf("%d", Arr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: printf("%d", I);
-
- for (int I = 0; I < N; ++I) {
- printf("%d", ValArr[I].X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : ValArr)
- // CHECK-FIXES-NEXT: printf("%d", I.X);
- }
-
- void explicitThis() {
- for (int I = 0; I < N; ++I) {
- printf("%d", this->Arr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : this->Arr)
- // CHECK-FIXES-NEXT: printf("%d", I);
-
- for (int I = 0; I < N; ++I) {
- printf("%d", this->ValArr[I].X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : this->ValArr)
- // CHECK-FIXES-NEXT: printf("%d", I.X);
- }
-};
-
-struct HasIndirectArr {
- HasArr HA;
- void implicitThis() {
- for (int I = 0; I < N; ++I) {
- printf("%d", HA.Arr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : HA.Arr)
- // CHECK-FIXES-NEXT: printf("%d", I);
-
- for (int I = 0; I < N; ++I) {
- printf("%d", HA.ValArr[I].X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : HA.ValArr)
- // CHECK-FIXES-NEXT: printf("%d", I.X);
- }
-
- void explicitThis() {
- for (int I = 0; I < N; ++I) {
- printf("%d", this->HA.Arr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : this->HA.Arr)
- // CHECK-FIXES-NEXT: printf("%d", I);
-
- for (int I = 0; I < N; ++I) {
- printf("%d", this->HA.ValArr[I].X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : this->HA.ValArr)
- // CHECK-FIXES-NEXT: printf("%d", I.X);
- }
-};
-
-// Loops whose bounds are value-dependent should not be converted.
-template <int N>
-void dependentExprBound() {
- for (int I = 0; I < N; ++I)
- Arr[I] = 0;
-}
-template void dependentExprBound<20>();
-
-void memberFunctionPointer() {
- Val V;
- void (Val::*mfpArr[N])(void) = {&Val::g};
- for (int I = 0; I < N; ++I)
- (V.*mfpArr[I])();
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : mfpArr)
- // CHECK-FIXES-NEXT: (V.*I)();
-
- struct Foo {
- int (Val::*f)();
- } Foo[N];
-
- for (int I = 0; I < N; ++I)
- int R = (V.*(Foo[I].f))();
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Foo)
- // CHECK-FIXES-NEXT: int R = (V.*(I.f))();
-
-}
-
-} // namespace Array
-
-namespace Iterator {
-
-void f() {
- /// begin()/end() - based for loops here:
- T Tt;
- for (T::iterator It = Tt.begin(), E = Tt.end(); It != E; ++It) {
- printf("I found %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : Tt)
- // CHECK-FIXES-NEXT: printf("I found %d\n", It);
-
- T *Pt;
- for (T::iterator It = Pt->begin(), E = Pt->end(); It != E; ++It) {
- printf("I found %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : *Pt)
- // CHECK-FIXES-NEXT: printf("I found %d\n", It);
-
- S Ss;
- for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- S *Ps;
- for (S::iterator It = Ps->begin(), E = Ps->end(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & P : *Ps)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
-
- for (S::const_iterator It = Ss.cbegin(), E = Ss.cend(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto It : Ss)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- printf("s has value %d\n", It->X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- It->X = 3;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: It.X = 3;
-
- for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- (*It).X = 3;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: It.X = 3;
-
- for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- It->nonConstFun(4, 5);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: It.nonConstFun(4, 5);
-
- U Uu;
- for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
- printf("s has value %d\n", It->X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Uu)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Uu)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- for (U::iterator It = Uu.begin(), E = Uu.end(); It != E; ++It) {
- Val* a = It.operator->();
- }
-
- U::iterator A;
- for (U::iterator I = Uu.begin(), E = Uu.end(); I != E; ++I)
- int K = A->X + I->X;
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Uu)
- // CHECK-FIXES-NEXT: int K = A->X + I.X;
-
- dependent<int> V;
- for (dependent<int>::iterator It = V.begin(), E = V.end();
- It != E; ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-
- for (dependent<int>::iterator It(V.begin()), E = V.end();
- It != E; ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-
- doublyDependent<int, int> Intmap;
- for (doublyDependent<int, int>::iterator It = Intmap.begin(), E = Intmap.end();
- It != E; ++It) {
- printf("Intmap[%d] = %d", It->first, It->second);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Intmap)
- // CHECK-FIXES: printf("Intmap[%d] = %d", It.first, It.second);
-
- // PtrSet's iterator dereferences by value so auto & can't be used.
- {
- PtrSet<int *> Val_int_ptrs;
- for (PtrSet<int *>::iterator I = Val_int_ptrs.begin(),
- E = Val_int_ptrs.end();
- I != E; ++I) {
- (void) *I;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto Val_int_ptr : Val_int_ptrs)
- }
-
- // This container uses an iterator where the dereference type is a typedef of
- // a reference type. Make sure non-const auto & is still used. A failure here
- // means canonical types aren't being tested.
- {
- TypedefDerefContainer<int> Int_ptrs;
- for (TypedefDerefContainer<int>::iterator I = Int_ptrs.begin(),
- E = Int_ptrs.end();
- I != E; ++I) {
- (void) *I;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & Int_ptr : Int_ptrs)
- }
-
- {
- // Iterators returning an rvalue reference should disqualify the loop from
- // transformation.
- RValueDerefContainer<int> Container;
- for (RValueDerefContainer<int>::iterator I = Container.begin(),
- E = Container.end();
- I != E; ++I) {
- (void) *I;
- }
- }
-
- dependent<Val *> Dpp;
- for (dependent<Val *>::iterator I = Dpp.begin(), E = Dpp.end(); I != E; ++I) {
- printf("%d\n", (**I).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Dpp)
- // CHECK-FIXES-NEXT: printf("%d\n", (*I).X);
-
- for (dependent<Val *>::iterator I = Dpp.begin(), E = Dpp.end(); I != E; ++I) {
- printf("%d\n", (*I)->X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Dpp)
- // CHECK-FIXES-NEXT: printf("%d\n", I->X);
-}
-
-// Tests to verify the proper use of auto where the init variable type and the
-// initializer type differ or are mostly the same except for const qualifiers.
-void different_type() {
- // Ss.begin() returns a type 'iterator' which is just a non-const pointer and
- // differs from const_iterator only on the const qualification.
- S Ss;
- for (S::const_iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto It : Ss)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- S *Ps;
- for (S::const_iterator It = Ps->begin(), E = Ps->end(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto P : *Ps)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
-
- dependent<int> V;
- for (dependent<int>::const_iterator It = V.begin(), E = V.end();
- It != E; ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-
- for (dependent<int>::const_iterator It(V.begin()), E = V.end();
- It != E; ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-}
-
-// Tests to ensure that an implicit 'this' is picked up as the container.
-// If member calls are made to 'this' within the loop, the transform becomes
-// risky as these calls may affect state that affects the loop.
-class C {
-public:
- typedef MutableVal *iterator;
- typedef const MutableVal *const_iterator;
-
- iterator begin();
- iterator end();
- const_iterator begin() const;
- const_iterator end() const;
-
- void doSomething();
- void doSomething() const;
-
- void doLoop() {
- for (iterator I = begin(), E = end(); I != E; ++I)
- (void) *I;
- // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : *this)
-
- for (iterator I = C::begin(), E = C::end(); I != E; ++I)
- (void) *I;
- // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : *this)
-
- for (iterator I = begin(), E = end(); I != E; ++I) {
- (void) *I;
- doSomething();
- }
-
- for (iterator I = begin(); I != end(); ++I)
- (void) *I;
- // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : *this)
-
- for (iterator I = begin(); I != end(); ++I) {
- (void) *I;
- doSomething();
- }
- }
-
- void doLoop() const {
- for (const_iterator I = begin(), E = end(); I != E; ++I)
- (void) *I;
- // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto I : *this)
-
- for (const_iterator I = C::begin(), E = C::end(); I != E; ++I)
- (void) *I;
- // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto I : *this)
-
- for (const_iterator I = begin(), E = end(); I != E; ++I) {
- (void) *I;
- doSomething();
- }
- }
-};
-
-class C2 {
-public:
- typedef MutableVal *iterator;
-
- iterator begin() const;
- iterator end() const;
-
- void doLoop() {
- // The implicit 'this' will have an Implicit cast to const C2* wrapped
- // around it. Make sure the replacement still happens.
- for (iterator I = begin(), E = end(); I != E; ++I)
- (void) *I;
- // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : *this)
- }
-};
-
-} // namespace Iterator
-
-namespace PseudoArray {
-
-const int N = 6;
-dependent<int> V;
-dependent<int> *Pv;
-const dependent<NonTriviallyCopyable> Constv;
-const dependent<NonTriviallyCopyable> *Pconstv;
-
-transparent<dependent<int>> Cv;
-
-void f() {
- int Sum = 0;
- for (int I = 0, E = V.size(); I < E; ++I) {
- printf("Fibonacci number is %d\n", V[I]);
- Sum += V[I] + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2;
-
- for (int I = 0, E = V.size(); I < E; ++I) {
- printf("Fibonacci number is %d\n", V.at(I));
- Sum += V.at(I) + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2;
-
- for (int I = 0, E = Pv->size(); I < E; ++I) {
- printf("Fibonacci number is %d\n", Pv->at(I));
- Sum += Pv->at(I) + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : *Pv)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2;
-
- // This test will fail if size() isn't called repeatedly, since it
- // returns unsigned int, and 0 is deduced to be signed int.
- // FIXME: Insert the necessary explicit conversion, or write out the types
- // explicitly.
- for (int I = 0; I < Pv->size(); ++I) {
- printf("Fibonacci number is %d\n", (*Pv).at(I));
- Sum += (*Pv)[I] + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : *Pv)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2;
-
- for (int I = 0; I < Cv->size(); ++I) {
- printf("Fibonacci number is %d\n", Cv->at(I));
- Sum += Cv->at(I) + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : *Cv)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2;
-}
-
-// Ensure that 'const auto &' is used with containers of non-trivial types.
-void constness() {
- int Sum = 0;
- for (int I = 0, E = Constv.size(); I < E; ++I) {
- printf("Fibonacci number is %d\n", Constv[I].X);
- Sum += Constv[I].X + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (const auto & I : Constv)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
- // CHECK-FIXES-NEXT: Sum += I.X + 2;
-
- for (int I = 0, E = Constv.size(); I < E; ++I) {
- printf("Fibonacci number is %d\n", Constv.at(I).X);
- Sum += Constv.at(I).X + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (const auto & I : Constv)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
- // CHECK-FIXES-NEXT: Sum += I.X + 2;
-
- for (int I = 0, E = Pconstv->size(); I < E; ++I) {
- printf("Fibonacci number is %d\n", Pconstv->at(I).X);
- Sum += Pconstv->at(I).X + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (const auto & I : *Pconstv)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
- // CHECK-FIXES-NEXT: Sum += I.X + 2;
-
- // This test will fail if size() isn't called repeatedly, since it
- // returns unsigned int, and 0 is deduced to be signed int.
- // FIXME: Insert the necessary explicit conversion, or write out the types
- // explicitly.
- for (int I = 0; I < Pconstv->size(); ++I) {
- printf("Fibonacci number is %d\n", (*Pconstv).at(I).X);
- Sum += (*Pconstv)[I].X + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (const auto & I : *Pconstv)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I.X);
- // CHECK-FIXES-NEXT: Sum += I.X + 2;
-}
-
-void constRef(const dependent<int>& ConstVRef) {
- int sum = 0;
- // FIXME: This does not work with size_t (probably due to the implementation
- // of dependent); make dependent work exactly like a std container type.
- for (int I = 0; I < ConstVRef.size(); ++I) {
- sum += ConstVRef[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : ConstVRef)
- // CHECK-FIXES-NEXT: sum += I;
-
- for (auto I = ConstVRef.begin(), E = ConstVRef.end(); I != E; ++I) {
- sum += *I;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : ConstVRef)
- // CHECK-FIXES-NEXT: sum += I;
-}
-
-// Check for loops that don't mention containers.
-void noContainer() {
- for (auto I = 0; I < V.size(); ++I) {
- }
-
- for (auto I = 0; I < V.size(); ++I)
- ;
-}
-
-struct NoBeginEnd {
- unsigned size() const;
- unsigned& operator[](int);
- const unsigned& operator[](int) const;
-};
-
-struct NoConstBeginEnd {
- NoConstBeginEnd();
- unsigned size() const;
- unsigned* begin();
- unsigned* end();
- unsigned& operator[](int);
- const unsigned& operator[](int) const;
-};
-
-struct ConstBeginEnd {
- ConstBeginEnd();
- unsigned size() const;
- unsigned* begin() const;
- unsigned* end() const;
- unsigned& operator[](int);
- const unsigned& operator[](int) const;
-};
-
-// Shouldn't transform pseudo-array uses if the container doesn't provide
-// begin() and end() of the right const-ness.
-void NoBeginEndTest() {
- NoBeginEnd NBE;
- for (unsigned I = 0, E = NBE.size(); I < E; ++I)
- printf("%d\n", NBE[I]);
-
- const NoConstBeginEnd Const_NCBE;
- for (unsigned I = 0, E = Const_NCBE.size(); I < E; ++I)
- printf("%d\n", Const_NCBE[I]);
-
- ConstBeginEnd CBE;
- for (unsigned I = 0, E = CBE.size(); I < E; ++I)
- printf("%d\n", CBE[I]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (unsigned int I : CBE)
- // CHECK-FIXES-NEXT: printf("%d\n", I);
-
- const ConstBeginEnd Const_CBE;
- for (unsigned I = 0, E = Const_CBE.size(); I < E; ++I)
- printf("%d\n", Const_CBE[I]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (unsigned int I : Const_CBE)
- // CHECK-FIXES-NEXT: printf("%d\n", I);
-}
-
-struct DerefByValue {
- DerefByValue();
- struct iter { unsigned operator*(); };
- unsigned size() const;
- iter begin();
- iter end();
- unsigned operator[](int);
-};
-
-void derefByValueTest() {
- DerefByValue DBV;
- for (unsigned I = 0, E = DBV.size(); I < E; ++I) {
- printf("%d\n", DBV[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (unsigned int I : DBV)
- // CHECK-FIXES-NEXT: printf("%d\n", I);
-
- for (unsigned I = 0, E = DBV.size(); I < E; ++I) {
- auto f = [DBV, I]() {};
- printf("%d\n", DBV[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (unsigned int I : DBV)
- // CHECK-FIXES-NEXT: auto f = [DBV, &I]() {};
- // CHECK-FIXES-NEXT: printf("%d\n", I);
-}
-
-void fundamentalTypesTest() {
- const int N = 10;
- bool Bools[N];
- for (int i = 0; i < N; ++i)
- printf("%d", Bools[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (bool Bool : Bools)
-
- int Ints[N];
- unsigned short int Shorts[N];
- for (int i = 0; i < N; ++i)
- printf("%d", Shorts[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (unsigned short Short : Shorts)
-
- signed long Longs[N];
- for (int i = 0; i < N; ++i)
- printf("%d", Longs[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (long Long : Longs)
-
- long long int LongLongs[N];
- for (int i = 0; i < N; ++i)
- printf("%d", LongLongs[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (long long LongLong : LongLongs)
-
- char Chars[N];
- for (int i = 0; i < N; ++i)
- printf("%d", Chars[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (char Char : Chars)
-
- wchar_t WChars[N];
- for (int i = 0; i < N; ++i)
- printf("%d", WChars[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (wchar_t WChar : WChars)
-
- float Floats[N];
- for (int i = 0; i < N; ++i)
- printf("%d", Floats[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (float Float : Floats)
-
- double Doubles[N];
- for (int i = 0; i < N; ++i)
- printf("%d", Doubles[i]);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (double Double : Doubles)
-}
-
-} // namespace PseudoArray
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-camelback.cpp (removed)
@@ -1,33 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-loop-convert %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-loop-convert.NamingStyle, value: 'camelBack'}]}" \
-// RUN: -- -I %S/Inputs/modernize-loop-convert
-
-#include "structures.h"
-
-const int n = 10;
-int arr[n];
-int nums[n];
-
-void naming() {
- for (int i = 0; i < n; ++i) {
- printf("%d\n", arr[i]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
- // CHECK-FIXES: for (int i : arr)
- // CHECK-FIXES-NEXT: printf("%d\n", i);
-
- for (int i = 0; i < n; ++i) {
- printf("%d\n", nums[i]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int num : nums)
- // CHECK-FIXES-NEXT: printf("%d\n", num);
-
- int num = 0;
- for (int i = 0; i < n; ++i) {
- printf("%d\n", nums[i] + num);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int i : nums)
- // CHECK-FIXES-NEXT: printf("%d\n", i + num);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-const.cpp (removed)
@@ -1,360 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-loop-convert %t
-
-struct Str {
- Str() = default;
- Str(const Str &) = default;
- void constMember(int) const;
- void nonConstMember(int);
- bool operator<(const Str &str) const; // const operator.
- Str &operator=(const Str &str) = default; // non const operator.
-};
-
-// This class is non-trivially copyable because the copy-constructor and copy
-// assignment take non-const references.
-struct ModifiesRightSide {
- ModifiesRightSide() = default;
- ModifiesRightSide(ModifiesRightSide &) = default;
- bool operator<(ModifiesRightSide &) const;
- ModifiesRightSide &operator=(ModifiesRightSide &) = default;
-};
-
-template <typename T>
-void copyArg(T);
-
-template <typename T>
-void nonConstRefArg(T &);
-
-// If we define this as a template, the type is deduced to "T&",
-// and "const (T&) &" is the same as "T& &", and this collapses to "T&".
-void constRefArg(const Str &);
-void constRefArg(const ModifiesRightSide &);
-void constRefArg(const int &);
-
-void foo();
-
-const int N = 10;
-Str Array[N], OtherStr;
-ModifiesRightSide Right[N], OtherRight;
-int Ints[N], OtherInt;
-
-void memberFunctionsAndOperators() {
- // Calling const member functions or operator is a const usage.
- for (int I = 0; I < N; ++I) {
- Array[I].constMember(0);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
- // CHECK-FIXES: for (auto I : Array)
- // CHECK-FIXES-NEXT: I.constMember(0);
-
- for (int I = 0; I < N; ++I) {
- if (Array[I] < OtherStr)
- foo();
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto I : Array)
- // CHECK-FIXES-NEXT: if (I < OtherStr)
- for (int I = 0; I < N; ++I) {
- if (Right[I] < OtherRight)
- foo();
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (const auto & I : Right)
- // CHECK-FIXES-NEXT: if (I < OtherRight)
-
- // Calling non-const member functions is not.
- for (int I = 0; I < N; ++I) {
- Array[I].nonConstMember(0);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Array)
- // CHECK-FIXES-NEXT: I.nonConstMember(0);
-
- for (int I = 0; I < N; ++I) {
- Array[I] = OtherStr;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Array)
- // CHECK-FIXES-NEXT: I = OtherStr;
-
- for (int I = 0; I < N; ++I) {
- Right[I] = OtherRight;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Right)
- // CHECK-FIXES-NEXT: I = OtherRight;
-}
-
-void usedAsParameterToFunctionOrOperator() {
- // Copying is OK, as long as the copy constructor takes a const-reference.
- for (int I = 0; I < N; ++I) {
- copyArg(Array[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto I : Array)
- // CHECK-FIXES-NEXT: copyArg(I);
-
- for (int I = 0; I < N; ++I) {
- copyArg(Right[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Right)
- // CHECK-FIXES-NEXT: copyArg(I);
-
- // Using as a const reference argument is allowed.
- for (int I = 0; I < N; ++I) {
- constRefArg(Array[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto I : Array)
- // CHECK-FIXES-NEXT: constRefArg(I);
-
- for (int I = 0; I < N; ++I) {
- if (OtherStr < Array[I])
- foo();
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto I : Array)
- // CHECK-FIXES-NEXT: if (OtherStr < I)
-
- for (int I = 0; I < N; ++I) {
- constRefArg(Right[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (const auto & I : Right)
- // CHECK-FIXES-NEXT: constRefArg(I);
-
- // Using as a non-const reference is not.
- for (int I = 0; I < N; ++I) {
- nonConstRefArg(Array[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Array)
- // CHECK-FIXES-NEXT: nonConstRefArg(I);
- for (int I = 0; I < N; ++I) {
- nonConstRefArg(Right[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Right)
- // CHECK-FIXES-NEXT: nonConstRefArg(I);
- for (int I = 0; I < N; ++I) {
- if (OtherRight < Right[I])
- foo();
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Right)
- // CHECK-FIXES-NEXT: if (OtherRight < I)
-}
-
-void primitiveTypes() {
- // As argument to a function.
- for (int I = 0; I < N; ++I) {
- copyArg(Ints[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: copyArg(Int);
- for (int I = 0; I < N; ++I) {
- constRefArg(Ints[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: constRefArg(Int);
- for (int I = 0; I < N; ++I) {
- nonConstRefArg(Ints[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int & Int : Ints)
- // CHECK-FIXES-NEXT: nonConstRefArg(Int);
-
- // Builtin operators.
- // Comparisons.
- for (int I = 0; I < N; ++I) {
- if (Ints[I] < N)
- foo();
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: if (Int < N)
-
- for (int I = 0; I < N; ++I) {
- if (N == Ints[I])
- foo();
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: if (N == Int)
-
- // Assignment.
- for (int I = 0; I < N; ++I) {
- Ints[I] = OtherInt;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int & Int : Ints)
- // CHECK-FIXES-NEXT: Int = OtherInt;
-
- for (int I = 0; I < N; ++I) {
- OtherInt = Ints[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: OtherInt = Int;
-
- for (int I = 0; I < N; ++I) {
- OtherInt = Ints[I] = OtherInt;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int & Int : Ints)
- // CHECK-FIXES-NEXT: OtherInt = Int = OtherInt;
-
- // Arithmetic operations.
- for (int I = 0; I < N; ++I) {
- OtherInt += Ints[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: OtherInt += Int;
-
- for (int I = 0; I < N; ++I) {
- Ints[I] += Ints[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int & Int : Ints)
- // CHECK-FIXES-NEXT: Int += Int;
-
- for (int I = 0; I < N; ++I) {
- int Res = 5 * (Ints[I] + 1) - Ints[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: int Res = 5 * (Int + 1) - Int;
-}
-
-void takingReferences() {
- // We do it twice to prevent the check from thinking that they are aliases.
-
- // Class type.
- for (int I = 0; I < N; ++I) {
- Str &J = Array[I];
- Str &K = Array[I];
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & I : Array)
- // CHECK-FIXES-NEXT: Str &J = I;
- // CHECK-FIXES-NEXT: Str &K = I;
- for (int I = 0; I < N; ++I) {
- const Str &J = Array[I];
- const Str &K = Array[I];
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto I : Array)
- // CHECK-FIXES-NEXT: const Str &J = I;
- // CHECK-FIXES-NEXT: const Str &K = I;
-
- // Primitive type.
- for (int I = 0; I < N; ++I) {
- int &J = Ints[I];
- int &K = Ints[I];
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int & Int : Ints)
- // CHECK-FIXES-NEXT: int &J = Int;
- // CHECK-FIXES-NEXT: int &K = Int;
- for (int I = 0; I < N; ++I) {
- const int &J = Ints[I];
- const int &K = Ints[I];
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: const int &J = Int;
- // CHECK-FIXES-NEXT: const int &K = Int;
-
- // Aliases.
- for (int I = 0; I < N; ++I) {
- const Str &J = Array[I];
- (void)J;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto J : Array)
- for (int I = 0; I < N; ++I) {
- Str &J = Array[I];
- (void)J;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto & J : Array)
-
- for (int I = 0; I < N; ++I) {
- const int &J = Ints[I];
- (void)J;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int J : Ints)
-
- for (int I = 0; I < N; ++I) {
- int &J = Ints[I];
- (void)J;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int & J : Ints)
-}
-
-template <class T>
-struct vector {
- unsigned size() const;
- const T &operator[](int) const;
- T &operator[](int);
- T *begin();
- T *end();
- const T *begin() const;
- const T *end() const;
-};
-
-// If the elements are already constant, we won't do any ImplicitCast to const.
-void testContainerOfConstIents() {
- const int Ints[N]{};
- for (int I = 0; I < N; ++I) {
- OtherInt -= Ints[I];
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
-
- vector<const Str> Strs;
- for (int I = 0; I < Strs.size(); ++I) {
- Strs[I].constMember(0);
- constRefArg(Strs[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop
- // CHECK-FIXES: for (auto Str : Strs)
-}
-
-// When we are inside a const-qualified member functions, all the data members
-// are implicitly set as const. As before, there won't be any ImplicitCast to
-// const in their usages.
-class TestInsideConstFunction {
- const static int N = 10;
- int Ints[N];
- Str Array[N];
- vector<int> V;
-
- void foo() const {
- for (int I = 0; I < N; ++I) {
- if (Ints[I])
- copyArg(Ints[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
- // CHECK-FIXES: for (int Int : Ints)
-
- for (int I = 0; I < N; ++I) {
- Array[I].constMember(0);
- constRefArg(Array[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
- // CHECK-FIXES: for (auto I : Array)
-
- for (int I = 0; I < V.size(); ++I) {
- if (V[I])
- copyArg(V[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop
- // CHECK-FIXES: for (int I : V)
- }
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-extra.cpp (removed)
@@ -1,1085 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -- -I %S/Inputs/modernize-loop-convert
-
-#include "structures.h"
-
-namespace Dependency {
-
-void f() {
- const int N = 6;
- const int M = 8;
- int Arr[N][M];
-
- for (int I = 0; I < N; ++I) {
- int A = 0;
- int B = Arr[I][A];
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Arr)
- // CHECK-FIXES-NEXT: int A = 0;
- // CHECK-FIXES-NEXT: int B = I[A];
-
- for (int J = 0; J < M; ++J) {
- int A = 0;
- int B = Arr[A][J];
- }
-}
-
-} // namespace Dependency
-
-namespace NamingAlias {
-
-const int N = 10;
-
-Val Arr[N];
-dependent<Val> V;
-dependent<Val> *Pv;
-Val &func(Val &);
-void sideEffect(int);
-
-void aliasing() {
- // If the loop container is only used for a declaration of a temporary
- // variable to hold each element, we can name the new variable for the
- // converted range-based loop as the temporary variable's name.
-
- // In the following case, "T" is used as a temporary variable to hold each
- // element, and thus we consider the name "T" aliased to the loop.
- // The extra blank braces are left as a placeholder for after the variable
- // declaration is deleted.
- for (int I = 0; I < N; ++I) {
- Val &T = Arr[I];
- {}
- int Y = T.X;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & T : Arr)
- // CHECK-FIXES-NOT: Val &{{[a-z_]+}} =
- // CHECK-FIXES-NEXT: {}
- // CHECK-FIXES-NEXT: int Y = T.X;
-
- // The container was not only used to initialize a temporary loop variable for
- // the container's elements, so we do not alias the new loop variable.
- for (int I = 0; I < N; ++I) {
- Val &T = Arr[I];
- int Y = T.X;
- int Z = Arr[I].X + T.X;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Arr)
- // CHECK-FIXES-NEXT: Val &T = I;
- // CHECK-FIXES-NEXT: int Y = T.X;
- // CHECK-FIXES-NEXT: int Z = I.X + T.X;
-
- for (int I = 0; I < N; ++I) {
- Val T = Arr[I];
- int Y = T.X;
- int Z = Arr[I].X + T.X;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Arr)
- // CHECK-FIXES-NEXT: Val T = I;
- // CHECK-FIXES-NEXT: int Y = T.X;
- // CHECK-FIXES-NEXT: int Z = I.X + T.X;
-
- // The same for pseudo-arrays like std::vector<T> (or here dependent<Val>)
- // which provide a subscript operator[].
- for (int I = 0; I < V.size(); ++I) {
- Val &T = V[I];
- {}
- int Y = T.X;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & T : V)
- // CHECK-FIXES-NEXT: {}
- // CHECK-FIXES-NEXT: int Y = T.X;
-
- // The same with a call to at()
- for (int I = 0; I < Pv->size(); ++I) {
- Val &T = Pv->at(I);
- {}
- int Y = T.X;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & T : *Pv)
- // CHECK-FIXES-NEXT: {}
- // CHECK-FIXES-NEXT: int Y = T.X;
-
- for (int I = 0; I < N; ++I) {
- Val &T = func(Arr[I]);
- int Y = T.X;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Arr)
- // CHECK-FIXES-NEXT: Val &T = func(I);
- // CHECK-FIXES-NEXT: int Y = T.X;
-
- int IntArr[N];
- for (unsigned I = 0; I < N; ++I) {
- if (int Alias = IntArr[I]) {
- sideEffect(Alias);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Alias : IntArr)
- // CHECK-FIXES-NEXT: if (Alias)
-
- for (unsigned I = 0; I < N; ++I) {
- while (int Alias = IntArr[I]) {
- sideEffect(Alias);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Alias : IntArr)
- // CHECK-FIXES-NEXT: while (Alias)
-
- for (unsigned I = 0; I < N; ++I) {
- switch (int Alias = IntArr[I]) {
- default:
- sideEffect(Alias);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Alias : IntArr)
- // CHECK-FIXES-NEXT: switch (Alias)
-
- for (unsigned I = 0; I < N; ++I) {
- for (int Alias = IntArr[I]; Alias < N; ++Alias) {
- sideEffect(Alias);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Alias : IntArr)
- // CHECK-FIXES-NEXT: for (; Alias < N; ++Alias)
-
- for (unsigned I = 0; I < N; ++I) {
- for (unsigned J = 0; int Alias = IntArr[I]; ++J) {
- sideEffect(Alias);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Alias : IntArr)
- // CHECK-FIXES-NEXT: for (unsigned J = 0; Alias; ++J)
-
- struct IntRef { IntRef(); IntRef(const int& i); operator int*(); };
- for (int I = 0; I < N; ++I) {
- IntRef Int(IntArr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : IntArr)
- // CHECK-FIXES-NEXT: IntRef Int(I);
-
- int *PtrArr[N];
- for (unsigned I = 0; I < N; ++I) {
- const int* const P = PtrArr[I];
- printf("%d\n", *P);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto P : PtrArr)
- // CHECK-FIXES-NEXT: printf("%d\n", *P);
-
- IntRef Refs[N];
- for (unsigned I = 0; I < N; ++I) {
- int *P = Refs[I];
- printf("%d\n", *P);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & Ref : Refs)
- // CHECK-FIXES-NEXT: int *P = Ref;
- // CHECK-FIXES-NEXT: printf("%d\n", *P);
-
- // Ensure that removing the alias doesn't leave empty lines behind.
- for (int I = 0; I < N; ++I) {
- auto &X = IntArr[I];
- X = 0;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & X : IntArr) {
- // CHECK-FIXES-NEXT: {{^ X = 0;$}}
- // CHECK-FIXES-NEXT: {{^ }$}}
-}
-
-void refs_and_vals() {
- // The following tests check that the transform correctly preserves the
- // reference or value qualifiers of the aliased variable. That is, if the
- // variable was declared as a value, the loop variable will be declared as a
- // value and vice versa for references.
-
- S Ss;
- const S S_const = Ss;
-
- for (S::const_iterator It = S_const.begin(); It != S_const.end(); ++It) {
- MutableVal Alias = *It;
- {}
- Alias.X = 0;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto Alias : S_const)
- // CHECK-FIXES-NOT: MutableVal {{[a-z_]+}} =
- // CHECK-FIXES-NEXT: {}
- // CHECK-FIXES-NEXT: Alias.X = 0;
-
- for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- MutableVal Alias = *It;
- {}
- Alias.X = 0;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto Alias : Ss)
- // CHECK-FIXES-NOT: MutableVal {{[a-z_]+}} =
- // CHECK-FIXES-NEXT: {}
- // CHECK-FIXES-NEXT: Alias.X = 0;
-
- for (S::iterator It = Ss.begin(), E = Ss.end(); It != E; ++It) {
- MutableVal &Alias = *It;
- {}
- Alias.X = 0;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & Alias : Ss)
- // CHECK-FIXES-NOT: MutableVal &{{[a-z_]+}} =
- // CHECK-FIXES-NEXT: {}
- // CHECK-FIXES-NEXT: Alias.X = 0;
-
- dependent<int> Dep, Other;
- for (dependent<int>::iterator It = Dep.begin(), E = Dep.end(); It != E; ++It) {
- printf("%d\n", *It);
- const int& Idx = Other[0];
- unsigned Othersize = Other.size();
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : Dep)
- // CHECK-FIXES-NEXT: printf("%d\n", It);
- // CHECK-FIXES-NEXT: const int& Idx = Other[0];
- // CHECK-FIXES-NEXT: unsigned Othersize = Other.size();
-
- for (int i = 0; i < Other.size(); ++i) {
- Other.at(i);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & i : Other)
- // CHECK-FIXES: i;
-
- for (int I = 0, E = Dep.size(); I != E; ++I) {
- int Idx = Other.at(I);
- Other.at(I, I); // Should not trigger assert failure.
- }
-}
-
-struct MemberNaming {
- const static int N = 10;
- int Ints[N], Ints_[N];
- dependent<int> DInts;
- void loops() {
- for (int I = 0; I < N; ++I) {
- printf("%d\n", Ints[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: printf("%d\n", Int);
-
- for (int I = 0; I < N; ++I) {
- printf("%d\n", Ints_[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Int : Ints_)
- // CHECK-FIXES-NEXT: printf("%d\n", Int);
-
- for (int I = 0; I < DInts.size(); ++I) {
- printf("%d\n", DInts[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (int DInt : DInts)
- // CHECK-FIXES-NEXT: printf("%d\n", DInt);
- }
-
- void outOfLine();
-};
-void MemberNaming::outOfLine() {
- for (int I = 0; I < N; ++I) {
- printf("%d\n", Ints[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Int : Ints)
- // CHECK-FIXES-NEXT: printf("%d\n", Int);
-
- for (int I = 0; I < N; ++I) {
- printf("%d\n", Ints_[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Int : Ints_)
- // CHECK-FIXES-NEXT: printf("%d\n", Int);
-}
-
-} // namespace NamingAlias
-
-namespace NamingConlict {
-
-#define MAX(a, b) (a > b) ? a : b
-#define DEF 5
-
-const int N = 10;
-int Nums[N];
-int Sum = 0;
-
-namespace ns {
-struct St {
- int X;
-};
-}
-
-void sameNames() {
- int Num = 0;
- for (int I = 0; I < N; ++I) {
- printf("Fibonacci number is %d\n", Nums[I]);
- Sum += Nums[I] + 2 + Num;
- (void)Nums[I];
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Nums)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2 + Num;
- // CHECK-FIXES-NEXT: (void)I;
-
- int Elem = 0;
- for (int I = 0; I < N; ++I) {
- printf("Fibonacci number is %d\n", Nums[I]);
- Sum += Nums[I] + 2 + Num + Elem;
- (void)Nums[I];
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Nums)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", I);
- // CHECK-FIXES-NEXT: Sum += I + 2 + Num + Elem;
- // CHECK-FIXES-NEXT: (void)I;
-}
-
-void oldIndexConflict() {
- for (int Num = 0; Num < N; ++Num) {
- printf("Num: %d\n", Nums[Num]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int Num : Nums)
- // CHECK-FIXES-NEXT: printf("Num: %d\n", Num);
-
- S Things;
- for (S::iterator Thing = Things.begin(), End = Things.end(); Thing != End; ++Thing) {
- printf("Thing: %d %d\n", Thing->X, (*Thing).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & Thing : Things)
- // CHECK-FIXES-NEXT: printf("Thing: %d %d\n", Thing.X, Thing.X);
-}
-
-void macroConflict() {
- S MAXs;
- for (S::iterator It = MAXs.begin(), E = MAXs.end(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- printf("Max of 3 and 5: %d\n", MAX(3, 5));
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : MAXs)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
- // CHECK-FIXES-NEXT: printf("Max of 3 and 5: %d\n", MAX(3, 5));
-
- for (S::const_iterator It = MAXs.begin(), E = MAXs.end(); It != E; ++It) {
- printf("s has value %d\n", (*It).X);
- printf("Max of 3 and 5: %d\n", MAX(3, 5));
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto It : MAXs)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
- // CHECK-FIXES-NEXT: printf("Max of 3 and 5: %d\n", MAX(3, 5));
-
- T DEFs;
- for (T::iterator It = DEFs.begin(), E = DEFs.end(); It != E; ++It) {
- if (*It == DEF) {
- printf("I found %d\n", *It);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : DEFs)
- // CHECK-FIXES-NEXT: if (It == DEF)
- // CHECK-FIXES-NEXT: printf("I found %d\n", It);
-}
-
-void keywordConflict() {
- T ints;
- for (T::iterator It = ints.begin(), E = ints.end(); It != E; ++It) {
- *It = 5;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : ints)
- // CHECK-FIXES-NEXT: It = 5;
-
- U __FUNCTION__s;
- for (U::iterator It = __FUNCTION__s.begin(), E = __FUNCTION__s.end();
- It != E; ++It) {
- int __FUNCTION__s_It = (*It).X + 2;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : __FUNCTION__s)
- // CHECK-FIXES-NEXT: int __FUNCTION__s_It = It.X + 2;
-}
-
-void typeConflict() {
- T Vals;
- // Using the name "Val", although it is the name of an existing struct, is
- // safe in this loop since it will only exist within this scope.
- for (T::iterator It = Vals.begin(), E = Vals.end(); It != E; ++It)
- (void) *It;
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & Val : Vals)
-
- // We cannot use the name "Val" in this loop since there is a reference to
- // it in the body of the loop.
- for (T::iterator It = Vals.begin(), E = Vals.end(); It != E; ++It) {
- *It = sizeof(Val);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : Vals)
- // CHECK-FIXES-NEXT: It = sizeof(Val);
-
- typedef struct Val TD;
- U TDs;
- // Naming the variable "TD" within this loop is safe because the typedef
- // was never used within the loop.
- for (U::iterator It = TDs.begin(), E = TDs.end(); It != E; ++It)
- (void) *It;
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & TD : TDs)
-
- // "TD" cannot be used in this loop since the typedef is being used.
- for (U::iterator It = TDs.begin(), E = TDs.end(); It != E; ++It) {
- TD V;
- V.X = 5;
- (void) *It;
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : TDs)
- // CHECK-FIXES-NEXT: TD V;
- // CHECK-FIXES-NEXT: V.X = 5;
-
- using ns::St;
- T Sts;
- for (T::iterator It = Sts.begin(), E = Sts.end(); It != E; ++It) {
- *It = sizeof(St);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : Sts)
- // CHECK-FIXES-NEXT: It = sizeof(St);
-}
-
-} // namespace NamingConflict
-
-namespace FreeBeginEnd {
-
-// FIXME: Loop Convert should detect free begin()/end() functions.
-
-struct MyArray {
- unsigned size();
-};
-
-template <typename T>
-struct MyContainer {
-};
-
-int *begin(const MyArray &Arr);
-int *end(const MyArray &Arr);
-
-template <typename T>
-T *begin(const MyContainer<T> &C);
-template <typename T>
-T *end(const MyContainer<T> &C);
-
-// The Loop Convert Transform doesn't detect free functions begin()/end() and
-// so fails to transform these cases which it should.
-void f() {
- MyArray Arr;
- for (unsigned I = 0, E = Arr.size(); I < E; ++I) {
- }
-
- MyContainer<int> C;
- for (int *I = begin(C), *E = end(C); I != E; ++I) {
- }
-}
-
-} // namespace FreeBeginEnd
-
-namespace Nesting {
-
-void g(S::iterator It);
-void const_g(S::const_iterator It);
-class Foo {
- public:
- void g(S::iterator It);
- void const_g(S::const_iterator It);
-};
-
-void f() {
- const int N = 10;
- const int M = 15;
- Val Arr[N];
- for (int I = 0; I < N; ++I) {
- for (int J = 0; J < N; ++J) {
- int K = Arr[I].X + Arr[J].X;
- // The repeat is there to allow FileCheck to make sure the two variable
- // names aren't the same.
- int L = Arr[I].X + Arr[J].X;
- }
- }
- // CHECK-MESSAGES: :[[@LINE-8]]:3: warning: use range-based for loop instead
- // CHECK-MESSAGES: :[[@LINE-8]]:5: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Arr)
- // CHECK-FIXES-NEXT: for (auto & J : Arr)
- // CHECK-FIXES-NEXT: int K = I.X + J.X;
- // CHECK-FIXES-NOT: int L = I.X + I.X;
-
- // The inner loop is also convertible, but doesn't need to be converted
- // immediately. FIXME: update this test when that changes.
- Val Nest[N][M];
- for (int I = 0; I < N; ++I) {
- for (int J = 0; J < M; ++J) {
- printf("Got item %d", Nest[I][J].X);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Nest)
- // CHECK-FIXES-NEXT: for (int J = 0; J < M; ++J)
- // CHECK-FIXES-NEXT: printf("Got item %d", I[J].X);
-
- // Note that the order of M and N are switched for this test.
- for (int J = 0; J < M; ++J) {
- for (int I = 0; I < N; ++I) {
- printf("Got item %d", Nest[I][J].X);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use range-based for loop instead
- // CHECK-FIXES-NOT: for (auto & {{[a-zA-Z_]+}} : Nest[I])
- // CHECK-FIXES: for (int J = 0; J < M; ++J)
- // CHECK-FIXES-NEXT: for (auto & I : Nest)
- // CHECK-FIXES-NEXT: printf("Got item %d", I[J].X);
-
- // The inner loop is also convertible.
- Nested<T> NestT;
- for (Nested<T>::iterator I = NestT.begin(), E = NestT.end(); I != E; ++I) {
- for (T::iterator TI = (*I).begin(), TE = (*I).end(); TI != TE; ++TI) {
- printf("%d", *TI);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : NestT)
- // CHECK-FIXES-NEXT: for (T::iterator TI = I.begin(), TE = I.end(); TI != TE; ++TI)
- // CHECK-FIXES-NEXT: printf("%d", *TI);
-
- // The inner loop is also convertible.
- Nested<S> NestS;
- for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
- for (S::const_iterator SI = (*I).begin(), SE = (*I).end(); SI != SE; ++SI) {
- printf("%d", *SI);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto I : NestS)
- // CHECK-FIXES-NEXT: for (S::const_iterator SI = I.begin(), SE = I.end(); SI != SE; ++SI)
- // CHECK-FIXES-NEXT: printf("%d", *SI);
-
- for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
- const S &Ss = *I;
- for (S::const_iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) {
- printf("%d", *SI);
- const_g(SI);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto Ss : NestS)
-
- for (Nested<S>::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
- S &Ss = *I;
- for (S::iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) {
- printf("%d", *SI);
- g(SI);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & Ss : NestS)
-
- Foo foo;
- for (Nested<S>::const_iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
- const S &Ss = *I;
- for (S::const_iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) {
- printf("%d", *SI);
- foo.const_g(SI);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto Ss : NestS)
-
- for (Nested<S>::iterator I = NestS.begin(), E = NestS.end(); I != E; ++I) {
- S &Ss = *I;
- for (S::iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI) {
- printf("%d", *SI);
- foo.g(SI);
- }
- }
- // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & Ss : NestS)
-
-}
-
-} // namespace Nesting
-
-namespace SingleIterator {
-
-void complexContainer() {
- X Exes[5];
- int Index = 0;
-
- for (S::iterator I = Exes[Index].getS().begin(), E = Exes[Index].getS().end(); I != E; ++I) {
- MutableVal K = *I;
- MutableVal J = *I;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Exes[Index].getS())
- // CHECK-FIXES-NEXT: MutableVal K = I;
- // CHECK-FIXES-NEXT: MutableVal J = I;
-}
-
-void f() {
- /// begin()/end() - based for loops here:
- T Tt;
- for (T::iterator It = Tt.begin(); It != Tt.end(); ++It) {
- printf("I found %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : Tt)
- // CHECK-FIXES-NEXT: printf("I found %d\n", It);
-
- T *Pt;
- for (T::iterator It = Pt->begin(); It != Pt->end(); ++It) {
- printf("I found %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : *Pt)
- // CHECK-FIXES-NEXT: printf("I found %d\n", It);
-
- S Ss;
- for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- S *Ps;
- for (S::iterator It = Ps->begin(); It != Ps->end(); ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & P : *Ps)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
-
- for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
- printf("s has value %d\n", It->X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
- It->X = 3;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: It.X = 3;
-
- for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
- (*It).X = 3;
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: It.X = 3;
-
- for (S::iterator It = Ss.begin(); It != Ss.end(); ++It) {
- It->nonConstFun(4, 5);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Ss)
- // CHECK-FIXES-NEXT: It.nonConstFun(4, 5);
-
- U Uu;
- for (U::iterator It = Uu.begin(); It != Uu.end(); ++It) {
- printf("s has value %d\n", It->X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Uu)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- for (U::iterator It = Uu.begin(); It != Uu.end(); ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : Uu)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- U::iterator A;
- for (U::iterator I = Uu.begin(); I != Uu.end(); ++I)
- int K = A->X + I->X;
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & I : Uu)
- // CHECK-FIXES-NEXT: int K = A->X + I.X;
-
- dependent<int> V;
- for (dependent<int>::iterator It = V.begin();
- It != V.end(); ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-
- for (dependent<int>::iterator It(V.begin());
- It != V.end(); ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-
- doublyDependent<int, int> intmap;
- for (doublyDependent<int, int>::iterator It = intmap.begin();
- It != intmap.end(); ++It) {
- printf("intmap[%d] = %d", It->first, It->second);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & It : intmap)
- // CHECK-FIXES-NEXT: printf("intmap[%d] = %d", It.first, It.second);
-}
-
-void different_type() {
- // Tests to verify the proper use of auto where the init variable type and the
- // initializer type differ or are mostly the same except for const qualifiers.
-
- // Ss.begin() returns a type 'iterator' which is just a non-const pointer and
- // differs from const_iterator only on the const qualification.
- S Ss;
- for (S::const_iterator It = Ss.begin(); It != Ss.end(); ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto It : Ss)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", It.X);
-
- S *Ps;
- for (S::const_iterator It = Ps->begin(); It != Ps->end(); ++It) {
- printf("s has value %d\n", (*It).X);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto P : *Ps)
- // CHECK-FIXES-NEXT: printf("s has value %d\n", P.X);
-
- dependent<int> V;
- for (dependent<int>::const_iterator It = V.begin(); It != V.end(); ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-
- for (dependent<int>::const_iterator It(V.begin()); It != V.end(); ++It) {
- printf("Fibonacci number is %d\n", *It);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int It : V)
- // CHECK-FIXES-NEXT: printf("Fibonacci number is %d\n", It);
-}
-
-} // namespace SingleIterator
-
-
-namespace Macros {
-
-#define TWO_PARAM(x, y) if (x == y) {}
-#define THREE_PARAM(x, y, z) if (x == y) {z;}
-
-const int N = 10;
-int Arr[N];
-
-void messing_with_macros() {
- for (int I = 0; I < N; ++I) {
- printf("Value: %d\n", Arr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: printf("Value: %d\n", I);
-
- for (int I = 0; I < N; ++I) {
- printf("Value: %d\n", CONT Arr[I]);
- }
-
- // Multiple macro arguments.
- for (int I = 0; I < N; ++I) {
- TWO_PARAM(Arr[I], Arr[I]);
- THREE_PARAM(Arr[I], Arr[I], Arr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Arr)
- // CHECK-FIXES-NEXT: TWO_PARAM(I, I);
- // CHECK-FIXES-NEXT: THREE_PARAM(I, I, I);
-}
-
-} // namespace Macros
-
-namespace Templates {
-
-template <class Container>
-void set_union(Container &container) {
- for (typename Container::const_iterator SI = container.begin(),
- SE = container.end(); SI != SE; ++SI) {
- (void) *SI;
- }
-
- S Ss;
- for (S::iterator SI = Ss.begin(), SE = Ss.end(); SI != SE; ++SI)
- (void) *SI;
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (auto & SI : Ss)
-}
-
-void template_instantiation() {
- S Ss;
- set_union(Ss);
-}
-
-} // namespace Templates
-
-namespace Lambdas {
-
-void capturesIndex() {
- const int N = 10;
- int Arr[N];
- // FIXME: the next four loops could be convertible, if the capture list is
- // also changed.
-
- for (int I = 0; I < N; ++I)
- auto F1 = [Arr, I]() { int R1 = Arr[I] + 1; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto F1 = [Arr, &I]() { int R1 = I + 1; };
-
- for (int I = 0; I < N; ++I)
- auto F2 = [Arr, &I]() { int R2 = Arr[I] + 3; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto F2 = [Arr, &I]() { int R2 = I + 3; };
-
- // FIXME: alias don't work if the index is captured.
- // Alias declared inside lambda (by value).
- for (int I = 0; I < N; ++I)
- auto F3 = [&Arr, I]() { int R3 = Arr[I]; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto F3 = [&Arr, &I]() { int R3 = I; };
-
-
- for (int I = 0; I < N; ++I)
- auto F4 = [&Arr, &I]() { int R4 = Arr[I]; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto F4 = [&Arr, &I]() { int R4 = I; };
-
- // Alias declared inside lambda (by reference).
- for (int I = 0; I < N; ++I)
- auto F5 = [&Arr, I]() { int &R5 = Arr[I]; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Arr)
- // CHECK-FIXES-NEXT: auto F5 = [&Arr, &I]() { int &R5 = I; };
-
-
- for (int I = 0; I < N; ++I)
- auto F6 = [&Arr, &I]() { int &R6 = Arr[I]; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Arr)
- // CHECK-FIXES-NEXT: auto F6 = [&Arr, &I]() { int &R6 = I; };
-
- for (int I = 0; I < N; ++I) {
- auto F = [Arr, I](int k) {
- printf("%d\n", Arr[I] + k);
- };
- F(Arr[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto F = [Arr, &I](int k)
- // CHECK-FIXES-NEXT: printf("%d\n", I + k);
- // CHECK-FIXES: F(I);
-}
-
-void implicitCapture() {
- const int N = 10;
- int Arr[N];
- // Index is used, not convertible.
- for (int I = 0; I < N; ++I) {
- auto G1 = [&]() {
- int R = Arr[I];
- int J = I;
- };
- }
-
- for (int I = 0; I < N; ++I) {
- auto G2 = [=]() {
- int R = Arr[I];
- int J = I;
- };
- }
-
- // Convertible.
- for (int I = 0; I < N; ++I) {
- auto G3 = [&]() {
- int R3 = Arr[I];
- int J3 = Arr[I] + R3;
- };
- }
- // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto G3 = [&]()
- // CHECK-FIXES-NEXT: int R3 = I;
- // CHECK-FIXES-NEXT: int J3 = I + R3;
-
- for (int I = 0; I < N; ++I) {
- auto G4 = [=]() {
- int R4 = Arr[I] + 5;
- };
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto G4 = [=]()
- // CHECK-FIXES-NEXT: int R4 = I + 5;
-
- // Alias by value.
- for (int I = 0; I < N; ++I) {
- auto G5 = [&]() {
- int R5 = Arr[I];
- int J5 = 8 + R5;
- };
- }
- // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int R5 : Arr)
- // CHECK-FIXES-NEXT: auto G5 = [&]()
- // CHECK-FIXES-NEXT: int J5 = 8 + R5;
-
- // Alias by reference.
- for (int I = 0; I < N; ++I) {
- auto G6 = [&]() {
- int &R6 = Arr[I];
- int J6 = -1 + R6;
- };
- }
- // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & R6 : Arr)
- // CHECK-FIXES-NEXT: auto G6 = [&]()
- // CHECK-FIXES-NEXT: int J6 = -1 + R6;
-}
-
-void iterators() {
- dependent<int> Dep;
-
- for (dependent<int>::iterator I = Dep.begin(), E = Dep.end(); I != E; ++I)
- auto H1 = [&I]() { int R = *I; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Dep)
- // CHECK-FIXES-NEXT: auto H1 = [&I]() { int R = I; };
-
- for (dependent<int>::iterator I = Dep.begin(), E = Dep.end(); I != E; ++I)
- auto H2 = [&]() { int R = *I + 2; };
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int & I : Dep)
- // CHECK-FIXES-NEXT: auto H2 = [&]() { int R = I + 2; };
-
- for (dependent<int>::const_iterator I = Dep.begin(), E = Dep.end();
- I != E; ++I)
- auto H3 = [I]() { int R = *I; };
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Dep)
- // CHECK-FIXES-NEXT: auto H3 = [&I]() { int R = I; };
-
- for (dependent<int>::const_iterator I = Dep.begin(), E = Dep.end();
- I != E; ++I)
- auto H4 = [&]() { int R = *I + 1; };
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Dep)
- // CHECK-FIXES-NEXT: auto H4 = [&]() { int R = I + 1; };
-
- for (dependent<int>::const_iterator I = Dep.begin(), E = Dep.end();
- I != E; ++I)
- auto H5 = [=]() { int R = *I; };
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int R : Dep)
- // CHECK-FIXES-NEXT: auto H5 = [=]() { };
-}
-
-void captureByValue() {
- // When the index is captured by value, we should replace this by a capture
- // by reference. This avoids extra copies.
- // FIXME: this could change semantics on array or pseudoarray loops if the
- // container is captured by copy.
- const int N = 10;
- int Arr[N];
- dependent<int> Dep;
-
- for (int I = 0; I < N; ++I) {
- auto C1 = [&Arr, I]() { if (Arr[I] == 1); };
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Arr)
- // CHECK-FIXES-NEXT: auto C1 = [&Arr, &I]() { if (I == 1); };
-
- for (unsigned I = 0; I < Dep.size(); ++I) {
- auto C2 = [&Dep, I]() { if (Dep[I] == 2); };
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Dep)
- // CHECK-FIXES-NEXT: auto C2 = [&Dep, &I]() { if (I == 2); };
-}
-
-} // namespace Lambdas
-
-namespace InitLists {
-
-struct D { int Ii; };
-struct E { D Dd; };
-int g(int B);
-
-void f() {
- const unsigned N = 3;
- int Array[N];
-
- // Subtrees of InitListExpr are visited twice. Test that we do not do repeated
- // replacements.
- for (unsigned I = 0; I < N; ++I) {
- int A{ Array[I] };
- int B{ g(Array[I]) };
- int C{ g( { Array[I] } ) };
- D Dd{ { g( { Array[I] } ) } };
- E Ee{ { { g( { Array[I] } ) } } };
- }
- // CHECK-MESSAGES: :[[@LINE-7]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : Array)
- // CHECK-FIXES-NEXT: int A{ I };
- // CHECK-FIXES-NEXT: int B{ g(I) };
- // CHECK-FIXES-NEXT: int C{ g( { I } ) };
- // CHECK-FIXES-NEXT: D Dd{ { g( { I } ) } };
- // CHECK-FIXES-NEXT: E Ee{ { { g( { I } ) } } };
-}
-
-} // namespace InitLists
-
-void bug28341() {
- char v[5];
- for(int i = 0; i < 5; ++i) {
- unsigned char value = v[i];
- if (value > 127)
- ;
- // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for(unsigned char value : v)
- // CHECK-FIXES-NEXT: if (value > 127)
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-lowercase.cpp (removed)
@@ -1,41 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-loop-convert %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-loop-convert.NamingStyle, value: 'lower_case'}]}" \
-// RUN: -- -I %S/Inputs/modernize-loop-convert
-
-#include "structures.h"
-
-const int n = 10;
-int arr[n];
-int nums[n];
-int nums_[n];
-
-void naming() {
- for (int i = 0; i < n; ++i) {
- printf("%d\n", arr[i]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
- // CHECK-FIXES: for (int i : arr)
- // CHECK-FIXES-NEXT: printf("%d\n", i);
-
- for (int i = 0; i < n; ++i) {
- printf("%d\n", nums[i]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int num : nums)
- // CHECK-FIXES-NEXT: printf("%d\n", num);
-
- for (int i = 0; i < n; ++i) {
- printf("%d\n", nums_[i]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int num : nums_)
- // CHECK-FIXES-NEXT: printf("%d\n", num);
-
- int num = 0;
- for (int i = 0; i < n; ++i) {
- printf("%d\n", nums[i] + num);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int i : nums)
- // CHECK-FIXES-NEXT: printf("%d\n", i + num);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-negative.cpp (removed)
@@ -1,485 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-loop-convert %t -- -- -I %S/Inputs/modernize-loop-convert
-
-#include "structures.h"
-
-// CHECK-FIXES-NOT: for ({{.*[^:]:[^:].*}})
-// CHECK-MESSAGES-NOT: modernize-loop-convert
-
-namespace Negative {
-
-const int N = 6;
-int Arr[N] = {1, 2, 3, 4, 5, 6};
-int (*pArr)[N] = &Arr;
-int Sum = 0;
-
-// Checks for the Index start and end:
-void IndexStartAndEnd() {
- for (int I = 0; I < N + 1; ++I)
- Sum += Arr[I];
-
- for (int I = 0; I < N - 1; ++I)
- Sum += Arr[I];
-
- for (int I = 1; I < N; ++I)
- Sum += Arr[I];
-
- for (int I = 1; I < N; ++I)
- Sum += Arr[I];
-
- for (int I = 0;; ++I)
- Sum += (*pArr)[I];
-}
-
-// Checks for invalid increment steps:
-void increment() {
- for (int I = 0; I < N; --I)
- Sum += Arr[I];
-
- for (int I = 0; I < N; I)
- Sum += Arr[I];
-
- for (int I = 0; I < N;)
- Sum += Arr[I];
-
- for (int I = 0; I < N; I += 2)
- Sum++;
-}
-
-// Checks to make sure that the Index isn't used outside of the array:
-void IndexUse() {
- for (int I = 0; I < N; ++I)
- Arr[I] += 1 + I;
-}
-
-// Check for loops that don't mention arrays
-void noArray() {
- for (int I = 0; I < N; ++I)
- Sum += I;
-
- for (int I = 0; I < N; ++I) {
- }
-
- for (int I = 0; I < N; ++I)
- ;
-}
-
-// Checks for incorrect loop variables.
-void mixedVariables() {
- int BadIndex;
- for (int I = 0; BadIndex < N; ++I)
- Sum += Arr[I];
-
- for (int I = 0; I < N; ++BadIndex)
- Sum += Arr[I];
-
- for (int I = 0; BadIndex < N; ++BadIndex)
- Sum += Arr[I];
-
- for (int I = 0; BadIndex < N; ++BadIndex)
- Sum += Arr[BadIndex];
-}
-
-// Checks for multiple arrays Indexed.
-void multipleArrays() {
- int BadArr[N];
-
- for (int I = 0; I < N; ++I)
- Sum += Arr[I] + BadArr[I];
-
- for (int I = 0; I < N; ++I) {
- int K = BadArr[I];
- Sum += Arr[I] + K;
- }
-}
-
-}
-
-namespace NegativeIterator {
-
-S Ss;
-T Tt;
-U Tu;
-
-struct BadBeginEnd : T {
- iterator notBegin();
- iterator notEnd();
-};
-
-void notBeginOrEnd() {
- BadBeginEnd Bad;
- for (T::iterator I = Bad.notBegin(), E = Bad.end(); I != E; ++I)
- int K = *I;
-
- for (T::iterator I = Bad.begin(), E = Bad.notEnd(); I != E; ++I)
- int K = *I;
-}
-
-void badLoopShapes() {
- for (T::iterator I = Tt.begin(), E = Tt.end(), F = E; I != E; ++I)
- int K = *I;
-
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E;)
- int K = *I;
-
- for (T::iterator I = Tt.begin(), E = Tt.end();; ++I)
- int K = *I;
-
- T::iterator OutsideI;
- T::iterator OutsideE;
-
- for (; OutsideI != OutsideE; ++OutsideI)
- int K = *OutsideI;
-}
-
-void iteratorArrayMix() {
- int Lower;
- const int N = 6;
- for (T::iterator I = Tt.begin(), E = Tt.end(); Lower < N; ++I)
- int K = *I;
-
- for (T::iterator I = Tt.begin(), E = Tt.end(); Lower < N; ++Lower)
- int K = *I;
-}
-
-struct ExtraConstructor : T::iterator {
- ExtraConstructor(T::iterator, int);
- explicit ExtraConstructor(T::iterator);
-};
-
-void badConstructor() {
- for (T::iterator I = ExtraConstructor(Tt.begin(), 0), E = Tt.end();
- I != E; ++I)
- int K = *I;
- for (T::iterator I = ExtraConstructor(Tt.begin()), E = Tt.end(); I != E; ++I)
- int K = *I;
-}
-
-void foo(S::iterator It) {}
-class Foo {public: void bar(S::iterator It); };
-Foo Fo;
-
-void iteratorUsed() {
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I)
- foo(I);
-
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I)
- Fo.bar(I);
-
- S::iterator Ret;
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I)
- Ret = I;
-}
-
-void iteratorMemberUsed() {
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E; ++I)
- I.X = *I;
-
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E; ++I)
- int K = I.X + *I;
-
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E; ++I)
- int K = E.X + *I;
-}
-
-void iteratorMethodCalled() {
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E; ++I)
- I.insert(3);
-
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E; ++I)
- if (I != I)
- int K = 3;
-}
-
-void iteratorOperatorCalled() {
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E; ++I)
- int K = *(++I);
-
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I)
- MutableVal K = *(++I);
-}
-
-void differentContainers() {
- T Other;
- for (T::iterator I = Tt.begin(), E = Other.end(); I != E; ++I)
- int K = *I;
-
- for (T::iterator I = Other.begin(), E = Tt.end(); I != E; ++I)
- int K = *I;
-
- S OtherS;
- for (S::iterator I = Ss.begin(), E = OtherS.end(); I != E; ++I)
- MutableVal K = *I;
-
- for (S::iterator I = OtherS.begin(), E = Ss.end(); I != E; ++I)
- MutableVal K = *I;
-}
-
-void wrongIterators() {
- T::iterator Other;
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != Other; ++I)
- int K = *I;
-}
-
-struct EvilArrow : U {
- // Please, no one ever write code like this.
- U *operator->();
-};
-
-void differentMemberAccessTypes() {
- EvilArrow A;
- for (EvilArrow::iterator I = A.begin(), E = A->end(); I != E; ++I)
- Val K = *I;
- for (EvilArrow::iterator I = A->begin(), E = A.end(); I != E; ++I)
- Val K = *I;
-}
-
-void f(const T::iterator &It, int);
-void f(const T &It, int);
-void g(T &It, int);
-
-void iteratorPassedToFunction() {
- for (T::iterator I = Tt.begin(), E = Tt.end(); I != E; ++I)
- f(I, *I);
-}
-
-// FIXME: These tests can be removed if this tool ever does enough analysis to
-// decide that this is a safe transformation. Until then, we don't want it
-// applied.
-void iteratorDefinedOutside() {
- T::iterator TheEnd = Tt.end();
- for (T::iterator I = Tt.begin(); I != TheEnd; ++I)
- int K = *I;
-
- T::iterator TheBegin = Tt.begin();
- for (T::iterator E = Tt.end(); TheBegin != E; ++TheBegin)
- int K = *TheBegin;
-}
-
-} // namespace NegativeIterator
-
-namespace NegativePseudoArray {
-
-const int N = 6;
-dependent<int> V;
-dependent<int> *Pv;
-
-int Sum = 0;
-
-// Checks for the Index start and end:
-void IndexStartAndEnd() {
- for (int I = 0; I < V.size() + 1; ++I)
- Sum += V[I];
-
- for (int I = 0; I < V.size() - 1; ++I)
- Sum += V[I];
-
- for (int I = 1; I < V.size(); ++I)
- Sum += V[I];
-
- for (int I = 1; I < V.size(); ++I)
- Sum += V[I];
-
- for (int I = 0;; ++I)
- Sum += (*Pv)[I];
-}
-
-// Checks for invalid increment steps:
-void increment() {
- for (int I = 0; I < V.size(); --I)
- Sum += V[I];
-
- for (int I = 0; I < V.size(); I)
- Sum += V[I];
-
- for (int I = 0; I < V.size();)
- Sum += V[I];
-
- for (int I = 0; I < V.size(); I += 2)
- Sum++;
-}
-
-// Checks to make sure that the Index isn't used outside of the container:
-void IndexUse() {
- for (int I = 0; I < V.size(); ++I)
- V[I] += 1 + I;
-}
-
-// Checks for incorrect loop variables.
-void mixedVariables() {
- int BadIndex;
- for (int I = 0; BadIndex < V.size(); ++I)
- Sum += V[I];
-
- for (int I = 0; I < V.size(); ++BadIndex)
- Sum += V[I];
-
- for (int I = 0; BadIndex < V.size(); ++BadIndex)
- Sum += V[I];
-
- for (int I = 0; BadIndex < V.size(); ++BadIndex)
- Sum += V[BadIndex];
-}
-
-// Checks for an array Indexed in addition to the container.
-void multipleArrays() {
- int BadArr[N];
-
- for (int I = 0; I < V.size(); ++I)
- Sum += V[I] + BadArr[I];
-
- for (int I = 0; I < V.size(); ++I)
- Sum += BadArr[I];
-
- for (int I = 0; I < V.size(); ++I) {
- int K = BadArr[I];
- Sum += K + 2;
- }
-
- for (int I = 0; I < V.size(); ++I) {
- int K = BadArr[I];
- Sum += V[I] + K;
- }
-}
-
-// Checks for multiple containers being Indexed container.
-void multipleContainers() {
- dependent<int> BadArr;
-
- for (int I = 0; I < V.size(); ++I)
- Sum += V[I] + BadArr[I];
-
- for (int I = 0; I < V.size(); ++I)
- Sum += BadArr[I];
-
- for (int I = 0; I < V.size(); ++I) {
- int K = BadArr[I];
- Sum += K + 2;
- }
-
- for (int I = 0; I < V.size(); ++I) {
- int K = BadArr[I];
- Sum += V[I] + K;
- }
-}
-
-// Check to make sure that dereferenced pointers-to-containers behave nicely.
-void derefContainer() {
- // Note the dependent<T>::operator*() returns another dependent<T>.
- // This test makes sure that we don't allow an arbitrary number of *'s.
- for (int I = 0; I < Pv->size(); ++I)
- Sum += (**Pv).at(I);
-
- for (int I = 0; I < Pv->size(); ++I)
- Sum += (**Pv)[I];
-}
-
-void wrongEnd() {
- int Bad;
- for (int I = 0, E = V.size(); I < Bad; ++I)
- Sum += V[I];
-}
-
-// Checks to see that non-const member functions are not called on the container
-// object.
-// These could be conceivably allowed with a lower required confidence level.
-void memberFunctionCalled() {
- for (int I = 0; I < V.size(); ++I) {
- Sum += V[I];
- V.foo();
- }
-
- for (int I = 0; I < V.size(); ++I) {
- Sum += V[I];
- dependent<int>::iterator It = V.begin();
- }
-}
-
-} // namespace NegativePseudoArray
-
-namespace NegativeMultiEndCall {
-
-S Ss;
-T Tt;
-U Uu;
-
-void f(X);
-void f(S);
-void f(T);
-
-void complexContainer() {
- X Xx;
- for (S::iterator I = Xx.Ss.begin(), E = Xx.Ss.end(); I != E; ++I) {
- f(Xx);
- MutableVal K = *I;
- }
-
- for (T::iterator I = Xx.Tt.begin(), E = Xx.Tt.end(); I != E; ++I) {
- f(Xx);
- int K = *I;
- }
-
- for (S::iterator I = Xx.Ss.begin(), E = Xx.Ss.end(); I != E; ++I) {
- f(Xx.Ss);
- MutableVal K = *I;
- }
-
- for (T::iterator I = Xx.Tt.begin(), E = Xx.Tt.end(); I != E; ++I) {
- f(Xx.Tt);
- int K = *I;
- }
-
- for (S::iterator I = Xx.getS().begin(), E = Xx.getS().end(); I != E; ++I) {
- f(Xx.getS());
- MutableVal K = *I;
- }
-
- X Exes[5];
- int Index = 0;
-
- for (S::iterator I = Exes[Index].getS().begin(),
- E = Exes[Index].getS().end();
- I != E; ++I) {
- Index++;
- MutableVal K = *I;
- }
-}
-
-} // namespace NegativeMultiEndCall
-
-namespace NoUsages {
-
-const int N = 6;
-int Arr[N] = {1, 2, 3, 4, 5, 6};
-S Ss;
-dependent<int> V;
-int Count = 0;
-
-void foo();
-
-void f() {
- for (int I = 0; I < N; ++I) {}
- for (int I = 0; I < N; ++I)
- printf("Hello world\n");
- for (int I = 0; I < N; ++I)
- ++Count;
- for (int I = 0; I < N; ++I)
- foo();
-
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I) {}
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I)
- printf("Hello world\n");
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I)
- ++Count;
- for (S::iterator I = Ss.begin(), E = Ss.end(); I != E; ++I)
- foo();
-
- for (int I = 0; I < V.size(); ++I) {}
- for (int I = 0; I < V.size(); ++I)
- printf("Hello world\n");
- for (int I = 0; I < V.size(); ++I)
- ++Count;
- for (int I = 0; I < V.size(); ++I)
- foo();
-}
-
-} // namespace NoUsages
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert-uppercase.cpp (removed)
@@ -1,41 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-loop-convert %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-loop-convert.NamingStyle, value: 'UPPER_CASE'}]}" \
-// RUN: -- -I %S/Inputs/modernize-loop-convert
-
-#include "structures.h"
-
-const int N = 10;
-int ARR[N];
-int NUMS[N];
-int NUMS_[N];
-
-void naming() {
- for (int I = 0; I < N; ++I) {
- printf("%d\n", ARR[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead [modernize-loop-convert]
- // CHECK-FIXES: for (int I : ARR)
- // CHECK-FIXES-NEXT: printf("%d\n", I);
-
- for (int I = 0; I < N; ++I) {
- printf("%d\n", NUMS[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int NUM : NUMS)
- // CHECK-FIXES-NEXT: printf("%d\n", NUM);
-
- for (int I = 0; I < N; ++I) {
- printf("%d\n", NUMS_[I]);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int NUM : NUMS_)
- // CHECK-FIXES-NEXT: printf("%d\n", NUM);
-
- int NUM = 0;
- for (int I = 0; I < N; ++I) {
- printf("%d\n", NUMS[I] + NUM);
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use range-based for loop instead
- // CHECK-FIXES: for (int I : NUMS)
- // CHECK-FIXES-NEXT: printf("%d\n", I + NUM);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-loop-convert.c (removed)
@@ -1,12 +0,0 @@
-// RUN: clang-tidy %s -checks=-*,modernize-loop-convert -- -std=c11 | count 0
-
-// Note: this test expects no diagnostics, but FileCheck cannot handle that,
-// hence the use of | count 0.
-
-int arr[6] = {1, 2, 3, 4, 5, 6};
-
-void f(void) {
- for (int i = 0; i < 6; ++i) {
- (void)arr[i];
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared-header.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared-header.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared-header.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared-header.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-make-shared %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: modernize-make-shared.MakeSmartPtrFunction, \
-// RUN: value: 'my::MakeShared'}, \
-// RUN: {key: modernize-make-shared.MakeSmartPtrFunctionHeader, \
-// RUN: value: 'make_shared_util.h'} \
-// RUN: ]}" \
-// RUN: -- -I %S/Inputs/modernize-smart-ptr
-
-#include "shared_ptr.h"
-// CHECK-FIXES: #include "make_shared_util.h"
-
-void f() {
- std::shared_ptr<int> P1 = std::shared_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use my::MakeShared instead
- // CHECK-FIXES: std::shared_ptr<int> P1 = my::MakeShared<int>();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-shared.cpp (removed)
@@ -1,297 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-make-shared %t -- -- -I %S/Inputs/modernize-smart-ptr
-
-#include "shared_ptr.h"
-// CHECK-FIXES: #include <memory>
-
-struct Base {
- Base();
- Base(int, int);
-};
-
-struct Derived : public Base {
- Derived();
- Derived(int, int);
-};
-
-struct APair {
- int a, b;
-};
-
-struct DPair {
- DPair() : a(0), b(0) {}
- DPair(int x, int y) : a(y), b(x) {}
- int a, b;
-};
-
-struct Empty {};
-
-template <class T>
-using shared_ptr_ = std::shared_ptr<T>;
-
-void *operator new(__SIZE_TYPE__ Count, void *Ptr);
-
-int g(std::shared_ptr<int> P);
-
-std::shared_ptr<Base> getPointer() {
- return std::shared_ptr<Base>(new Base);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_shared instead
- // CHECK-FIXES: return std::make_shared<Base>();
-}
-
-void basic() {
- std::shared_ptr<int> P1 = std::shared_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: std::shared_ptr<int> P1 = std::make_shared<int>();
-
- P1.reset(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: P1 = std::make_shared<int>();
-
- P1 = std::shared_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: P1 = std::make_shared<int>();
-
- // Without parenthesis.
- std::shared_ptr<int> P2 = std::shared_ptr<int>(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: std::shared_ptr<int> P2 = std::make_shared<int>();
-
- P2.reset(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: P2 = std::make_shared<int>();
-
- P2 = std::shared_ptr<int>(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: P2 = std::make_shared<int>();
-
- // With auto.
- auto P3 = std::shared_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_shared instead
- // CHECK-FIXES: auto P3 = std::make_shared<int>();
-
- std::shared_ptr<int> P4 = std::shared_ptr<int>((new int));
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: std::shared_ptr<int> P4 = std::make_shared<int>();
-
- P4.reset((((new int()))));
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: P4 = std::make_shared<int>();
-
- P4 = std::shared_ptr<int>(((new int)));
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_shared instead [modernize-make-shared]
- // CHECK-FIXES: P4 = std::make_shared<int>();
-
- {
- // No std.
- using namespace std;
- shared_ptr<int> Q = shared_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_shared instead
- // CHECK-FIXES: shared_ptr<int> Q = std::make_shared<int>();
-
- Q = shared_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_shared instead
- // CHECK-FIXES: Q = std::make_shared<int>();
- }
-
- std::shared_ptr<int> R(new int());
-
- // Create the shared_ptr as a parameter to a function.
- int T = g(std::shared_ptr<int>(new int()));
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_shared instead
- // CHECK-FIXES: int T = g(std::make_shared<int>());
-
- // Only replace if the type in the template is the same as the type returned
- // by the new operator.
- auto Pderived = std::shared_ptr<Base>(new Derived());
-
- // OK to replace for reset and assign
- Pderived.reset(new Derived());
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::make_shared instead
- // CHECK-FIXES: Pderived = std::make_shared<Derived>();
-
- Pderived = std::shared_ptr<Derived>(new Derived());
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use std::make_shared instead
- // CHECK-FIXES: Pderived = std::make_shared<Derived>();
-
- // FIXME: OK to replace if assigned to shared_ptr<Base>
- Pderived = std::shared_ptr<Base>(new Derived());
-
- // FIXME: OK to replace when auto is not used
- std::shared_ptr<Base> PBase = std::shared_ptr<Base>(new Derived());
-
- // The pointer is returned by the function, nothing to do.
- std::shared_ptr<Base> RetPtr = getPointer();
-
- // This emulates std::move.
- std::shared_ptr<int> Move = static_cast<std::shared_ptr<int> &&>(P1);
-
- // Placement arguments should not be removed.
- int *PInt = new int;
- std::shared_ptr<int> Placement = std::shared_ptr<int>(new (PInt) int{3});
- Placement.reset(new (PInt) int{3});
- Placement = std::shared_ptr<int>(new (PInt) int{3});
-}
-
-// Calling make_smart_ptr from within a member function of a type with a
-// private or protected constructor would be ill-formed.
-class Private {
-private:
- Private(int z) {}
-
-public:
- Private() {}
- void create() {
- auto callsPublic = std::shared_ptr<Private>(new Private);
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_shared instead
- // CHECK-FIXES: auto callsPublic = std::make_shared<Private>();
- auto ptr = std::shared_ptr<Private>(new Private(42));
- ptr.reset(new Private(42));
- ptr = std::shared_ptr<Private>(new Private(42));
- }
-
- virtual ~Private();
-};
-
-class Protected {
-protected:
- Protected() {}
-
-public:
- Protected(int, int) {}
- void create() {
- auto callsPublic = std::shared_ptr<Protected>(new Protected(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_shared instead
- // CHECK-FIXES: auto callsPublic = std::make_shared<Protected>(1, 2);
- auto ptr = std::shared_ptr<Protected>(new Protected);
- ptr.reset(new Protected);
- ptr = std::shared_ptr<Protected>(new Protected);
- }
-};
-
-void initialization(int T, Base b) {
- // Test different kinds of initialization of the pointee.
-
- // Direct initialization with parenthesis.
- std::shared_ptr<DPair> PDir1 = std::shared_ptr<DPair>(new DPair(1, T));
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<DPair> PDir1 = std::make_shared<DPair>(1, T);
- PDir1.reset(new DPair(1, T));
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_shared instead
- // CHECK-FIXES: PDir1 = std::make_shared<DPair>(1, T);
-
- // Direct initialization with braces.
- std::shared_ptr<DPair> PDir2 = std::shared_ptr<DPair>(new DPair{2, T});
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<DPair> PDir2 = std::make_shared<DPair>(2, T);
- PDir2.reset(new DPair{2, T});
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_shared instead
- // CHECK-FIXES: PDir2 = std::make_shared<DPair>(2, T);
-
- // Aggregate initialization.
- std::shared_ptr<APair> PAggr = std::shared_ptr<APair>(new APair{T, 1});
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<APair> PAggr = std::make_shared<APair>(APair{T, 1});
- PAggr.reset(new APair{T, 1});
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_shared instead
- // CHECK-FIXES: std::make_shared<APair>(APair{T, 1});
-
- // Test different kinds of initialization of the pointee, when the shared_ptr
- // is initialized with braces.
-
- // Direct initialization with parenthesis.
- std::shared_ptr<DPair> PDir3 = std::shared_ptr<DPair>{new DPair(3, T)};
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<DPair> PDir3 = std::make_shared<DPair>(3, T);
-
- // Direct initialization with braces.
- std::shared_ptr<DPair> PDir4 = std::shared_ptr<DPair>{new DPair{4, T}};
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<DPair> PDir4 = std::make_shared<DPair>(4, T);
-
- // Aggregate initialization.
- std::shared_ptr<APair> PAggr2 = std::shared_ptr<APair>{new APair{T, 2}};
- // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<APair> PAggr2 = std::make_shared<APair>(APair{T, 2});
-
- // Direct initialization with parenthesis, without arguments.
- std::shared_ptr<DPair> PDir5 = std::shared_ptr<DPair>(new DPair());
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<DPair> PDir5 = std::make_shared<DPair>();
-
- // Direct initialization with braces, without arguments.
- std::shared_ptr<DPair> PDir6 = std::shared_ptr<DPair>(new DPair{});
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<DPair> PDir6 = std::make_shared<DPair>();
-
- // Aggregate initialization without arguments.
- std::shared_ptr<Empty> PEmpty = std::shared_ptr<Empty>(new Empty{});
- // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<Empty> PEmpty = std::make_shared<Empty>(Empty{});
-}
-
-void aliases() {
- typedef std::shared_ptr<int> IntPtr;
- IntPtr Typedef = IntPtr(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_shared instead
- // CHECK-FIXES: IntPtr Typedef = std::make_shared<int>();
-
- // We use 'bool' instead of '_Bool'.
- typedef std::shared_ptr<bool> BoolPtr;
- BoolPtr BoolType = BoolPtr(new bool);
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::make_shared instead
- // CHECK-FIXES: BoolPtr BoolType = std::make_shared<bool>();
-
- // We use 'Base' instead of 'struct Base'.
- typedef std::shared_ptr<Base> BasePtr;
- BasePtr StructType = BasePtr(new Base);
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_shared instead
-// CHECK-FIXES: BasePtr StructType = std::make_shared<Base>();
-
-#define PTR shared_ptr<int>
- std::shared_ptr<int> Macro = std::PTR(new int);
-// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_shared instead
-// CHECK-FIXES: std::shared_ptr<int> Macro = std::make_shared<int>();
-#undef PTR
-
- std::shared_ptr<int> Using = shared_ptr_<int>(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_shared instead
- // CHECK-FIXES: std::shared_ptr<int> Using = std::make_shared<int>();
-}
-
-void whitespaces() {
- // clang-format off
- auto Space = std::shared_ptr <int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_shared instead
- // CHECK-FIXES: auto Space = std::make_shared<int>();
-
- auto Spaces = std :: shared_ptr <int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_shared instead
- // CHECK-FIXES: auto Spaces = std::make_shared<int>();
- // clang-format on
-}
-
-void nesting() {
- auto Nest = std::shared_ptr<std::shared_ptr<int>>(new std::shared_ptr<int>(new int));
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use std::make_shared instead
- // CHECK-FIXES: auto Nest = std::make_shared<std::shared_ptr<int>>(new int);
- Nest.reset(new std::shared_ptr<int>(new int));
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_shared instead
- // CHECK-FIXES: Nest = std::make_shared<std::shared_ptr<int>>(new int);
- Nest->reset(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_shared instead
- // CHECK-FIXES: *Nest = std::make_shared<int>();
-}
-
-void reset() {
- std::shared_ptr<int> P;
- P.reset();
- P.reset(nullptr);
- P.reset(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use std::make_shared instead
- // CHECK-FIXES: P = std::make_shared<int>();
-
- auto Q = &P;
- Q->reset(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead
- // CHECK-FIXES: *Q = std::make_shared<int>();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-cxx11.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-cxx11.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-cxx11.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11 %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
-
-#include "unique_ptr.h"
-// CHECK-FIXES: #include "unique_ptr.h"
-
-void f() {
- auto my_ptr = std::unique_ptr<int>(new int(1));
- // CHECK-FIXES: auto my_ptr = std::unique_ptr<int>(new int(1));
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-header.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-header.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-header.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-header.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-make-unique %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: modernize-make-unique.MakeSmartPtrFunction, \
-// RUN: value: 'my::MakeUnique'}, \
-// RUN: {key: modernize-make-unique.MakeSmartPtrFunctionHeader, \
-// RUN: value: 'make_unique_util.h'} \
-// RUN: ]}" \
-// RUN: -- -I %S/Inputs/modernize-smart-ptr
-
-#include "unique_ptr.h"
-// CHECK-FIXES: #include "make_unique_util.h"
-
-void f() {
- std::unique_ptr<int> P1 = std::unique_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use my::MakeUnique instead
- // CHECK-FIXES: std::unique_ptr<int> P1 = my::MakeUnique<int>();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-inaccessible-ctors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-inaccessible-ctors.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-inaccessible-ctors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-inaccessible-ctors.cpp (removed)
@@ -1,113 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14,c++17 -check-suffix=CXX-14-17 %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -D CXX_14_17=1
-// RUN: %check_clang_tidy -std=c++2a -check-suffix=CXX-2A %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr -D CXX_2A=1
-
-#include "unique_ptr.h"
-// CHECK-FIXES: #include <memory>
-
-struct NoCopyMoveCtor {
-#ifdef CXX_2A
- // C++2a requires to see the default constructor, otherwise it is illgal.
- NoCopyMoveCtor() = default;
-#endif
-#ifdef CXX_14_17
- int a, b;
-#endif
- NoCopyMoveCtor(const NoCopyMoveCtor &) = delete; // implies move ctor is deleted
-};
-
-struct NoCopyMoveCtorVisible {
-#ifdef CXX_2A
- NoCopyMoveCtorVisible() = default;
-#endif
-private:
- NoCopyMoveCtorVisible(const NoCopyMoveCtorVisible&) = default;
- NoCopyMoveCtorVisible(NoCopyMoveCtorVisible&&) = default;
-};
-
-struct OnlyMoveCtor {
- OnlyMoveCtor() = default;
- OnlyMoveCtor(OnlyMoveCtor&&) = default;
- OnlyMoveCtor(const OnlyMoveCtor &) = delete;
-};
-
-struct OnlyCopyCtor {
-#ifdef CXX_2A
- OnlyCopyCtor() = default;
-#endif
- OnlyCopyCtor(const OnlyCopyCtor&) = default;
- OnlyCopyCtor(OnlyCopyCtor&&) = delete;
-};
-
-struct OnlyCopyCtorVisible {
-#ifdef CXX_2A
- OnlyCopyCtorVisible() = default;
-#endif
- OnlyCopyCtorVisible(const OnlyCopyCtorVisible &) = default;
-
-private:
- OnlyCopyCtorVisible(OnlyCopyCtorVisible &&) = default;
-};
-
-struct ImplicitDeletedCopyCtor {
- const OnlyMoveCtor ctor;
-};
-
-void f() {
- auto my_ptr = std::unique_ptr<int>(new int(1));
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:17: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto my_ptr = std::make_unique<int>(1);
- // CHECK-MESSAGES-CXX-2A: :[[@LINE-3]]:17: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-2A: auto my_ptr = std::make_unique<int>(1);
-
- // "new NoCopyMoveCtor{}" is processed differently in C++14/17 and C++2a:
- // * In C++14/17, it is recognized as aggregate initialization,
- // no fixes will be generated although the generated fix is compilable.
- // * In C++2a, it is is recognized as default constructor initialization (
- // similar to "new NoCopyMoveCtor()"), the check will emit the fix and the
- // fix is correct.
- auto PNoCopyMoveCtor = std::unique_ptr<NoCopyMoveCtor>(new NoCopyMoveCtor{});
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:26: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto PNoCopyMoveCtor = std::unique_ptr<NoCopyMoveCtor>(new NoCopyMoveCtor{});
- // CHECK-MESSAGES-CXX-2A: :[[@LINE-3]]:26: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-2A: auto PNoCopyMoveCtor = std::make_unique<NoCopyMoveCtor>();
-
- auto PNoCopyMoveCtorVisible = std::unique_ptr<NoCopyMoveCtorVisible>(new NoCopyMoveCtorVisible{});
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:33: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto PNoCopyMoveCtorVisible = std::unique_ptr<NoCopyMoveCtorVisible>(new NoCopyMoveCtorVisible{});
- // CHECK-MESSAGES-CXX-2A: :[[@LINE-3]]:33: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-2A: auto PNoCopyMoveCtorVisible = std::make_unique<NoCopyMoveCtorVisible>();
-
- auto POnlyMoveCtor = std::unique_ptr<OnlyMoveCtor>(new OnlyMoveCtor{});
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:24: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto POnlyMoveCtor = std::unique_ptr<OnlyMoveCtor>(new OnlyMoveCtor{});
- // CHECK-MESSAGES-CXX-2A: :[[@LINE-3]]:24: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-2A: auto POnlyMoveCtor = std::make_unique<OnlyMoveCtor>();
-
- auto POnlyCopyCtor = std::unique_ptr<OnlyCopyCtor>(new OnlyCopyCtor{});
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:24: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto POnlyCopyCtor = std::unique_ptr<OnlyCopyCtor>(new OnlyCopyCtor{});
- // CHECK-MESSAGES-CXX-2A: :[[@LINE-3]]:24: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-2A: auto POnlyCopyCtor = std::make_unique<OnlyCopyCtor>();
-
- auto POnlyCopyCtorVisible = std::unique_ptr<OnlyCopyCtorVisible>(new OnlyCopyCtorVisible{});
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:31: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto POnlyCopyCtorVisible = std::unique_ptr<OnlyCopyCtorVisible>(new OnlyCopyCtorVisible{});
- // CHECK-MESSAGES-CXX-2A: :[[@LINE-3]]:31: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-2A: auto POnlyCopyCtorVisible = std::make_unique<OnlyCopyCtorVisible>();
-
- // This is aggregate initialization in C++2a, no fix will be generated.
- auto PImplicitDeletedCopyCtor = std::unique_ptr<ImplicitDeletedCopyCtor>(new ImplicitDeletedCopyCtor{});
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:35: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto PImplicitDeletedCopyCtor = std::unique_ptr<ImplicitDeletedCopyCtor>(new ImplicitDeletedCopyCtor{});
- // CHECK-MESSAGES-CXX-2A: :[[@LINE-3]]:35: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-2A: auto PImplicitDeletedCopyCtor = std::unique_ptr<ImplicitDeletedCopyCtor>(new ImplicitDeletedCopyCtor{});
-
-
-#ifdef CXX_14_17
- // FIXME: it is impossible to use make_unique for this case, the check should
- // stop emitting the message.
- auto PNoCopyMoveCtor2 = std::unique_ptr<NoCopyMoveCtor>(new NoCopyMoveCtor{1, 2});
- // CHECK-MESSAGES-CXX-14-17: :[[@LINE-1]]:27: warning: use std::make_unique instead
- // CHECK-FIXES-CXX-14-17: auto PNoCopyMoveCtor2 = std::unique_ptr<NoCopyMoveCtor>(new NoCopyMoveCtor{1, 2});
-#endif
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique-macros.cpp (removed)
@@ -1,28 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-make-unique.IgnoreMacros, value: 0}]}" \
-// RUN: -- -I %S/Inputs/modernize-smart-ptr
-
-#include "unique_ptr.h"
-
-class Foo {};
-class Bar {};
-#define DEFINE(...) __VA_ARGS__
-// CHECK-FIXES: {{^}}#define DEFINE(...) __VA_ARGS__{{$}}
-template<typename T>
-void g2(std::unique_ptr<Foo> *t) {
- DEFINE(
- // CHECK-FIXES: {{^ *}}DEFINE({{$}}
- auto p = std::unique_ptr<Foo>(new Foo);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead
- // CHECK-FIXES: {{^ *}}auto p = std::unique_ptr<Foo>(new Foo);{{$}}
- t->reset(new Foo);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
- // CHECK-FIXES: {{^ *}}t->reset(new Foo);{{$}}
- );
- // CHECK-FIXES: {{^ *}});{{$}}
-}
-void macro() {
- std::unique_ptr<Foo> *t;
- g2<Bar>(t);
-}
-#undef DEFINE
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (removed)
@@ -1,570 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-make-unique %t -- -- -I %S/Inputs/modernize-smart-ptr
-
-#include "unique_ptr.h"
-#include "initializer_list.h"
-// CHECK-FIXES: #include <memory>
-
-struct Base {
- Base();
- Base(int, int);
-};
-
-struct Derived : public Base {
- Derived();
- Derived(int, int);
-};
-
-struct APair {
- int a, b;
-};
-
-struct DPair {
- DPair() : a(0), b(0) {}
- DPair(int x, int y) : a(y), b(x) {}
- int a, b;
-};
-
-template<typename T>
-struct MyVector {
- MyVector(std::initializer_list<T>);
-};
-
-struct Empty {};
-
-
-struct E {
- E(std::initializer_list<int>);
- E();
-};
-
-struct F {
- F(std::initializer_list<int>);
- F();
- int a;
-};
-
-struct G {
- G(std::initializer_list<int>);
- G(int);
-};
-
-struct H {
- H(std::vector<int>);
- H(std::vector<int> &, double);
- H(MyVector<int>, int);
-};
-
-struct I {
- I(G);
-};
-
-struct J {
- J(E e, int);
-};
-
-namespace {
-class Foo {};
-} // namespace
-
-namespace bar {
-class Bar {};
-} // namespace bar
-
-template <class T>
-using unique_ptr_ = std::unique_ptr<T>;
-
-void *operator new(__SIZE_TYPE__ Count, void *Ptr);
-
-int g(std::unique_ptr<int> P);
-
-std::unique_ptr<Base> getPointer() {
- return std::unique_ptr<Base>(new Base);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
- // CHECK-FIXES: return std::make_unique<Base>();
-}
-
-void basic() {
- std::unique_ptr<int> P1 = std::unique_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: std::unique_ptr<int> P1 = std::make_unique<int>();
-
- P1.reset(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: P1 = std::make_unique<int>();
-
- P1 = std::unique_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: P1 = std::make_unique<int>();
-
- // Without parenthesis.
- std::unique_ptr<int> P2 = std::unique_ptr<int>(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: std::unique_ptr<int> P2 = std::make_unique<int>();
-
- P2.reset(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: P2 = std::make_unique<int>();
-
- P2 = std::unique_ptr<int>(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: P2 = std::make_unique<int>();
-
- // With auto.
- auto P3 = std::unique_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
- // CHECK-FIXES: auto P3 = std::make_unique<int>();
-
- std::unique_ptr<int> P4 = std::unique_ptr<int>((new int));
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: std::unique_ptr<int> P4 = std::make_unique<int>();
- P4.reset((new int));
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: P4 = std::make_unique<int>();
- std::unique_ptr<int> P5 = std::unique_ptr<int>((((new int))));
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: std::unique_ptr<int> P5 = std::make_unique<int>();
- P5.reset(((((new int)))));
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead [modernize-make-unique]
- // CHECK-FIXES: P5 = std::make_unique<int>();
-
- {
- // No std.
- using namespace std;
- unique_ptr<int> Q = unique_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use std::make_unique instead
- // CHECK-FIXES: unique_ptr<int> Q = std::make_unique<int>();
-
- Q = unique_ptr<int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
- // CHECK-FIXES: Q = std::make_unique<int>();
- }
-
- std::unique_ptr<int> R(new int());
-
- // Create the unique_ptr as a parameter to a function.
- int T = g(std::unique_ptr<int>(new int()));
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
- // CHECK-FIXES: int T = g(std::make_unique<int>());
-
- // Only replace if the type in the template is the same as the type returned
- // by the new operator.
- auto Pderived = std::unique_ptr<Base>(new Derived());
-
- // OK to replace for reset and assign
- Pderived.reset(new Derived());
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::make_unique instead
- // CHECK-FIXES: Pderived = std::make_unique<Derived>();
-
- Pderived = std::unique_ptr<Derived>(new Derived());
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use std::make_unique instead
- // CHECK-FIXES: Pderived = std::make_unique<Derived>();
-
- // FIXME: OK to replace if assigned to unique_ptr<Base>
- Pderived = std::unique_ptr<Base>(new Derived());
-
- // FIXME: OK to replace when auto is not used
- std::unique_ptr<Base> PBase = std::unique_ptr<Base>(new Derived());
-
- // The pointer is returned by the function, nothing to do.
- std::unique_ptr<Base> RetPtr = getPointer();
-
- // This emulates std::move.
- std::unique_ptr<int> Move = static_cast<std::unique_ptr<int> &&>(P1);
-
- // Placement arguments should not be removed.
- int *PInt = new int;
- std::unique_ptr<int> Placement = std::unique_ptr<int>(new (PInt) int{3});
- Placement.reset(new (PInt) int{3});
- Placement = std::unique_ptr<int>(new (PInt) int{3});
-}
-
-// Calling make_smart_ptr from within a member function of a type with a
-// private or protected constructor would be ill-formed.
-class Private {
-private:
- Private(int z) {}
-
-public:
- Private() {}
- void create() {
- auto callsPublic = std::unique_ptr<Private>(new Private);
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
- // CHECK-FIXES: auto callsPublic = std::make_unique<Private>();
- auto ptr = std::unique_ptr<Private>(new Private(42));
- ptr.reset(new Private(42));
- ptr = std::unique_ptr<Private>(new Private(42));
- }
-
- virtual ~Private();
-};
-
-class Protected {
-protected:
- Protected() {}
-
-public:
- Protected(int, int) {}
- void create() {
- auto callsPublic = std::unique_ptr<Protected>(new Protected(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
- // CHECK-FIXES: auto callsPublic = std::make_unique<Protected>(1, 2);
- auto ptr = std::unique_ptr<Protected>(new Protected);
- ptr.reset(new Protected);
- ptr = std::unique_ptr<Protected>(new Protected);
- }
-};
-
-void initialization(int T, Base b) {
- // Test different kinds of initialization of the pointee.
-
- // Direct initialization with parenthesis.
- std::unique_ptr<DPair> PDir1 = std::unique_ptr<DPair>(new DPair(1, T));
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<DPair> PDir1 = std::make_unique<DPair>(1, T);
- PDir1.reset(new DPair(1, T));
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
- // CHECK-FIXES: PDir1 = std::make_unique<DPair>(1, T);
-
- // Direct initialization with braces.
- std::unique_ptr<DPair> PDir2 = std::unique_ptr<DPair>(new DPair{2, T});
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<DPair> PDir2 = std::make_unique<DPair>(2, T);
- PDir2.reset(new DPair{2, T});
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
- // CHECK-FIXES: PDir2 = std::make_unique<DPair>(2, T);
-
- // Aggregate initialization.
- std::unique_ptr<APair> PAggr = std::unique_ptr<APair>(new APair{T, 1});
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<APair> PAggr = std::make_unique<APair>(APair{T, 1});
- PAggr.reset(new APair{T, 1});
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
- // CHECK-FIXES: std::make_unique<APair>(APair{T, 1});
-
- // Check aggregate init with intermediate temporaries.
- std::unique_ptr<APair> PAggrTemp = std::unique_ptr<APair>(new APair({T, 1}));
- // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<APair> PAggrTemp = std::unique_ptr<APair>(new APair({T, 1}));
- PAggrTemp.reset(new APair({T, 1}));
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
- // CHECK-FIXES: PAggrTemp.reset(new APair({T, 1}));
-
- // Test different kinds of initialization of the pointee, when the unique_ptr
- // is initialized with braces.
-
- // Direct initialization with parenthesis.
- std::unique_ptr<DPair> PDir3 = std::unique_ptr<DPair>{new DPair(3, T)};
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<DPair> PDir3 = std::make_unique<DPair>(3, T);
-
- // Direct initialization with braces.
- std::unique_ptr<DPair> PDir4 = std::unique_ptr<DPair>{new DPair{4, T}};
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<DPair> PDir4 = std::make_unique<DPair>(4, T);
-
- // Aggregate initialization.
- std::unique_ptr<APair> PAggr2 = std::unique_ptr<APair>{new APair{T, 2}};
- // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<APair> PAggr2 = std::make_unique<APair>(APair{T, 2});
-
- // Direct initialization with parenthesis, without arguments.
- std::unique_ptr<DPair> PDir5 = std::unique_ptr<DPair>(new DPair());
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<DPair> PDir5 = std::make_unique<DPair>();
-
- // Direct initialization with braces, without arguments.
- std::unique_ptr<DPair> PDir6 = std::unique_ptr<DPair>(new DPair{});
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<DPair> PDir6 = std::make_unique<DPair>();
-
- // Aggregate initialization without arguments.
- std::unique_ptr<Empty> PEmpty = std::unique_ptr<Empty>(new Empty{});
- // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<Empty> PEmpty = std::make_unique<Empty>(Empty{});
-
- // Initialization with default constructor.
- std::unique_ptr<E> PE1 = std::unique_ptr<E>(new E{});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<E> PE1 = std::make_unique<E>();
- PE1.reset(new E{});
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PE1 = std::make_unique<E>();
-
- // No warnings for `auto` new expression.
- PE1.reset(new auto(E()));
-
- //============================================================================
- // NOTE: For initlializer-list constructors, the check only gives warnings,
- // and no fixes are generated.
- //============================================================================
-
- // Initialization with the initializer-list constructor.
- std::unique_ptr<E> PE2 = std::unique_ptr<E>(new E{1, 2});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<E> PE2 = std::unique_ptr<E>(new E{1, 2});
- PE2.reset(new E{1, 2});
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PE2.reset(new E{1, 2});
-
- // Initialization with default constructor.
- std::unique_ptr<F> PF1 = std::unique_ptr<F>(new F());
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<F> PF1 = std::make_unique<F>();
- PF1.reset(new F());
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PF1 = std::make_unique<F>();
-
- // Initialization with default constructor.
- std::unique_ptr<F> PF2 = std::unique_ptr<F>(new F{});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<F> PF2 = std::make_unique<F>();
- PF2.reset(new F());
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PF2 = std::make_unique<F>();
-
- // Initialization with the initializer-list constructor.
- std::unique_ptr<F> PF3 = std::unique_ptr<F>(new F{1});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<F> PF3 = std::unique_ptr<F>(new F{1});
- PF3.reset(new F{1});
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PF3.reset(new F{1});
-
- // Initialization with the initializer-list constructor.
- std::unique_ptr<F> PF4 = std::unique_ptr<F>(new F{1, 2});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<F> PF4 = std::unique_ptr<F>(new F{1, 2});
-
- // Initialization with the initializer-list constructor.
- std::unique_ptr<F> PF5 = std::unique_ptr<F>(new F({1, 2}));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<F> PF5 = std::unique_ptr<F>(new F({1, 2}));
-
- // Initialization with the initializer-list constructor as the default
- // constructor is not present.
- std::unique_ptr<G> PG1 = std::unique_ptr<G>(new G{});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<G> PG1 = std::unique_ptr<G>(new G{});
- PG1.reset(new G{});
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PG1.reset(new G{});
-
- // Initialization with the initializer-list constructor.
- std::unique_ptr<G> PG2 = std::unique_ptr<G>(new G{1});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<G> PG2 = std::unique_ptr<G>(new G{1});
-
- // Initialization with the initializer-list constructor.
- std::unique_ptr<G> PG3 = std::unique_ptr<G>(new G{1, 2});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<G> PG3 = std::unique_ptr<G>(new G{1, 2});
-
- std::unique_ptr<H> PH1 = std::unique_ptr<H>(new H({1, 2, 3}));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<H> PH1 = std::unique_ptr<H>(new H({1, 2, 3}));
- PH1.reset(new H({1, 2, 3}));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PH1.reset(new H({1, 2, 3}));
-
- std::unique_ptr<H> PH2 = std::unique_ptr<H>(new H({1, 2, 3}, 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<H> PH2 = std::unique_ptr<H>(new H({1, 2, 3}, 1));
- PH2.reset(new H({1, 2, 3}, 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PH2.reset(new H({1, 2, 3}, 1));
-
- std::unique_ptr<H> PH3 = std::unique_ptr<H>(new H({1, 2, 3}, 1.0));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<H> PH3 = std::unique_ptr<H>(new H({1, 2, 3}, 1.0));
- PH3.reset(new H({1, 2, 3}, 1.0));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PH3.reset(new H({1, 2, 3}, 1.0));
-
- std::unique_ptr<I> PI1 = std::unique_ptr<I>(new I(G({1, 2, 3})));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<I> PI1 = std::make_unique<I>(G({1, 2, 3}));
- PI1.reset(new I(G({1, 2, 3})));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PI1 = std::make_unique<I>(G({1, 2, 3}));
-
- std::unique_ptr<J> PJ1 = std::unique_ptr<J>(new J({1, 2}, 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<J> PJ1 = std::unique_ptr<J>(new J({1, 2}, 1));
- PJ1.reset(new J({1, 2}, 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PJ1.reset(new J({1, 2}, 1));
-
- std::unique_ptr<J> PJ2 = std::unique_ptr<J>(new J(E{1, 2}, 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<J> PJ2 = std::unique_ptr<J>(new J(E{1, 2}, 1));
- PJ2.reset(new J(E{1, 2}, 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PJ2.reset(new J(E{1, 2}, 1));
-
- std::unique_ptr<J> PJ3 = std::unique_ptr<J>(new J{ {1, 2}, 1 });
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<J> PJ3 = std::unique_ptr<J>(new J{ {1, 2}, 1 });
- PJ3.reset(new J{ {1, 2}, 1 });
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PJ3.reset(new J{ {1, 2}, 1 });
-
- std::unique_ptr<J> PJ4 = std::unique_ptr<J>(new J{E{1, 2}, 1});
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<J> PJ4 = std::unique_ptr<J>(new J{E{1, 2}, 1});
- PJ4.reset(new J{E{1, 2}, 1});
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
- // CHECK-FIXES: PJ4.reset(new J{E{1, 2}, 1});
-
- std::unique_ptr<Foo> FF = std::unique_ptr<Foo>(new Foo());
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning:
- // CHECK-FIXES: std::unique_ptr<Foo> FF = std::make_unique<Foo>();
- FF.reset(new Foo());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
- // CHECK-FIXES: FF = std::make_unique<Foo>();
-
- std::unique_ptr<bar::Bar> BB = std::unique_ptr<bar::Bar>(new bar::Bar());
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning:
- // CHECK-FIXES: std::unique_ptr<bar::Bar> BB = std::make_unique<bar::Bar>();
- BB.reset(new bar::Bar());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
- // CHECK-FIXES: BB = std::make_unique<bar::Bar>();
-
- std::unique_ptr<Foo[]> FFs;
- FFs.reset(new Foo[5]);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning:
- // CHECK-FIXES: FFs = std::make_unique<Foo[]>(5);
- FFs.reset(new Foo[5]());
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning:
- // CHECK-FIXES: FFs = std::make_unique<Foo[]>(5);
- const int Num = 1;
- FFs.reset(new Foo[Num]);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning:
- // CHECK-FIXES: FFs = std::make_unique<Foo[]>(Num);
- int Num2 = 1;
- FFs.reset(new Foo[Num2]);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning:
- // CHECK-FIXES: FFs = std::make_unique<Foo[]>(Num2);
-
- std::unique_ptr<int[]> FI;
- FI.reset(new int[5]()); // default initialization.
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning:
- // CHECK-FIXES: FI = std::make_unique<int[]>(5);
-
- // The check doesn't give warnings and fixes for cases where the original new
- // expresion doesn't do any initialization.
- FI.reset(new int[5]);
- FI.reset(new int[Num]);
- FI.reset(new int[Num2]);
-}
-
-void aliases() {
- typedef std::unique_ptr<int> IntPtr;
- IntPtr Typedef = IntPtr(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead
- // CHECK-FIXES: IntPtr Typedef = std::make_unique<int>();
-
- // We use 'bool' instead of '_Bool'.
- typedef std::unique_ptr<bool> BoolPtr;
- BoolPtr BoolType = BoolPtr(new bool);
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::make_unique instead
- // CHECK-FIXES: BoolPtr BoolType = std::make_unique<bool>();
-
- // We use 'Base' instead of 'struct Base'.
- typedef std::unique_ptr<Base> BasePtr;
- BasePtr StructType = BasePtr(new Base);
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead
-// CHECK-FIXES: BasePtr StructType = std::make_unique<Base>();
-
-#define PTR unique_ptr<int>
- std::unique_ptr<int> Macro = std::PTR(new int);
-// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead
-// CHECK-FIXES: std::unique_ptr<int> Macro = std::make_unique<int>();
-#undef PTR
-
- std::unique_ptr<int> Using = unique_ptr_<int>(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead
- // CHECK-FIXES: std::unique_ptr<int> Using = std::make_unique<int>();
-}
-
-void whitespaces() {
- // clang-format off
- auto Space = std::unique_ptr <int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use std::make_unique instead
- // CHECK-FIXES: auto Space = std::make_unique<int>();
-
- auto Spaces = std :: unique_ptr <int>(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use std::make_unique instead
- // CHECK-FIXES: auto Spaces = std::make_unique<int>();
- // clang-format on
-}
-
-void nesting() {
- auto Nest = std::unique_ptr<std::unique_ptr<int>>(new std::unique_ptr<int>(new int));
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use std::make_unique instead
- // CHECK-FIXES: auto Nest = std::make_unique<std::unique_ptr<int>>(new int);
- Nest.reset(new std::unique_ptr<int>(new int));
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use std::make_unique instead
- // CHECK-FIXES: Nest = std::make_unique<std::unique_ptr<int>>(new int);
- Nest->reset(new int);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use std::make_unique instead
- // CHECK-FIXES: *Nest = std::make_unique<int>();
-}
-
-void reset() {
- std::unique_ptr<int> P;
- P.reset();
- P.reset(nullptr);
- P.reset(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use std::make_unique instead
- // CHECK-FIXES: P = std::make_unique<int>();
-
- auto Q = &P;
- Q->reset(new int());
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_unique instead
- // CHECK-FIXES: *Q = std::make_unique<int>();
-}
-
-#define DEFINE(...) __VA_ARGS__
-template<typename T>
-void g2(std::unique_ptr<Foo> *t) {
- DEFINE(auto p = std::unique_ptr<Foo>(new Foo); t->reset(new Foo););
-}
-void macro() {
- std::unique_ptr<Foo> *t;
- g2<bar::Bar>(t);
-}
-#undef DEFINE
-
-class UniqueFoo : public std::unique_ptr<Foo> {
- public:
- void foo() {
- reset(new Foo);
- this->reset(new Foo);
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use std::make_unique instead
- // CHECK-FIXES: *this = std::make_unique<Foo>();
- (*this).reset(new Foo);
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use std::make_unique instead
- // CHECK-FIXES: (*this) = std::make_unique<Foo>();
- }
-};
-
-// Ignore statements inside a template instantiation.
-template<typename T>
-void template_fun(T* t) {
- std::unique_ptr<T> t2 = std::unique_ptr<T>(new T);
- t2.reset(new T);
-}
-
-void invoke_template() {
- Foo* foo;
- template_fun(foo);
-}
-
-void no_fix_for_invalid_new_loc() {
- // FIXME: Although the code is valid, the end location of `new struct Base` is
- // invalid. Correct it once https://bugs.llvm.org/show_bug.cgi?id=35952 is
- // fixed.
- auto T = std::unique_ptr<Base>(new struct Base);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::make_unique instead
- // CHECK-FIXES: auto T = std::unique_ptr<Base>(new struct Base);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-header.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: cp %S/Inputs/modernize-pass-by-value/header.h %T/pass-by-value-header.h
-// RUN: clang-tidy %s -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
-// RUN: FileCheck -input-file=%T/pass-by-value-header.h %s -check-prefix=CHECK-FIXES
-// FIXME: Make the test work in all language modes.
-
-#include "pass-by-value-header.h"
-// CHECK-MESSAGES: :8:5: warning: pass by value and use std::move [modernize-pass-by-value]
-// CHECK-FIXES: #include <utility>
-// CHECK-FIXES: A(ThreadId tid) : threadid(std::move(tid)) {}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-macro-header.cpp (removed)
@@ -1,18 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -isystem %S/Inputs/Headers
-
-// CHECK-FIXES: #include <utility>
-
-#define HEADER <./a.h>
-#include HEADER
-
-struct A {
- A(const A &) {}
- A(A &&) {}
-};
-
-struct B {
- B(const A &a) : a(a) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value]
-// CHECK-FIXES: B(A a) : a(std::move(a)) {}
- A a;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: cat %S/Inputs/modernize-pass-by-value/header-with-fix.h > %T/pass-by-value-header-with-fix.h
-// RUN: sed -e 's#//.*$##' %s > %t.cpp
-// RUN: clang-tidy %t.cpp -checks='-*,modernize-pass-by-value' -header-filter='.*' -fix -- -std=c++11 -I %T | FileCheck %s -check-prefix=CHECK-MESSAGES -implicit-check-not="{{warning|error}}:"
-// RUN: FileCheck -input-file=%t.cpp %s -check-prefix=CHECK-FIXES
-// RUN: FileCheck -input-file=%T/pass-by-value-header-with-fix.h %s -check-prefix=CHECK-HEADER-FIXES
-
-#include "pass-by-value-header-with-fix.h"
-// CHECK-HEADER-FIXES: Foo(S s);
-Foo::Foo(const S &s) : s(s) {}
-// CHECK-MESSAGES: :9:10: warning: pass by value and use std::move [modernize-pass-by-value]
-// CHECK-FIXES: #include <utility>
-// CHECK-FIXES: Foo::Foo(S s) : s(std::move(s)) {}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp (removed)
@@ -1,215 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-pass-by-value %t -- -- -fno-delayed-template-parsing
-
-namespace {
-// POD types are trivially move constructible.
-struct POD {
- int a, b, c;
-};
-
-struct Movable {
- int a, b, c;
- Movable() = default;
- Movable(const Movable &) {}
- Movable(Movable &&) {}
-};
-
-struct NotMovable {
- NotMovable() = default;
- NotMovable(const NotMovable &) = default;
- NotMovable(NotMovable &&) = delete;
- int a, b, c;
-};
-}
-
-struct A {
- A(const Movable &M) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move [modernize-pass-by-value]
- // CHECK-FIXES: A(Movable M) : M(std::move(M)) {}
- Movable M;
-};
-
-// Test that we aren't modifying other things than a parameter.
-Movable GlobalObj;
-struct B {
- B(const Movable &M) : M(GlobalObj) {}
- // CHECK-FIXES: B(const Movable &M) : M(GlobalObj) {}
- Movable M;
-};
-
-// Test that a parameter with more than one reference to it won't be changed.
-struct C {
- // Tests extra-reference in body.
- C(const Movable &M) : M(M) { this->i = M.a; }
- // CHECK-FIXES: C(const Movable &M) : M(M) { this->i = M.a; }
-
- // Tests extra-reference in init-list.
- C(const Movable &M, int) : M(M), i(M.a) {}
- // CHECK-FIXES: C(const Movable &M, int) : M(M), i(M.a) {}
- Movable M;
- int i;
-};
-
-// Test that both declaration and definition are updated.
-struct D {
- D(const Movable &M);
- // CHECK-FIXES: D(Movable M);
- Movable M;
-};
-D::D(const Movable &M) : M(M) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
-// CHECK-FIXES: D::D(Movable M) : M(std::move(M)) {}
-
-// Test with default parameter.
-struct E {
- E(const Movable &M = Movable()) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
- // CHECK-FIXES: E(Movable M = Movable()) : M(std::move(M)) {}
- Movable M;
-};
-
-// Test with object that can't be moved.
-struct F {
- F(const NotMovable &NM) : NM(NM) {}
- // CHECK-FIXES: F(const NotMovable &NM) : NM(NM) {}
- NotMovable NM;
-};
-
-// Test unnamed parameter in declaration.
-struct G {
- G(const Movable &);
- // CHECK-FIXES: G(Movable );
- Movable M;
-};
-G::G(const Movable &M) : M(M) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
-// CHECK-FIXES: G::G(Movable M) : M(std::move(M)) {}
-
-// Test parameter with and without qualifier.
-namespace ns_H {
-typedef ::Movable HMovable;
-}
-struct H {
- H(const ns_H::HMovable &M);
- // CHECK-FIXES: H(ns_H::HMovable M);
- ns_H::HMovable M;
-};
-using namespace ns_H;
-H::H(const HMovable &M) : M(M) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: pass by value and use std::move
-// CHECK-FIXES: H(HMovable M) : M(std::move(M)) {}
-
-// Try messing up with macros.
-#define MOVABLE_PARAM(Name) const Movable & Name
-// CHECK-FIXES: #define MOVABLE_PARAM(Name) const Movable & Name
-struct I {
- I(MOVABLE_PARAM(M)) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
- // CHECK-FIXES: I(MOVABLE_PARAM(M)) : M(M) {}
- Movable M;
-};
-#undef MOVABLE_PARAM
-
-// Test that templates aren't modified.
-template <typename T> struct J {
- J(const T &M) : M(M) {}
- // CHECK-FIXES: J(const T &M) : M(M) {}
- T M;
-};
-J<Movable> j1(Movable());
-J<NotMovable> j2(NotMovable());
-
-struct K_Movable {
- K_Movable() = default;
- K_Movable(const K_Movable &) = default;
- K_Movable(K_Movable &&o) { dummy = o.dummy; }
- int dummy;
-};
-
-// Test with movable type with an user defined move constructor.
-struct K {
- K(const K_Movable &M) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
- // CHECK-FIXES: K(K_Movable M) : M(std::move(M)) {}
- K_Movable M;
-};
-
-template <typename T> struct L {
- L(const Movable &M) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
- // CHECK-FIXES: L(Movable M) : M(std::move(M)) {}
- Movable M;
-};
-L<int> l(Movable());
-
-// Test with a non-instantiated template class.
-template <typename T> struct N {
- N(const Movable &M) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
- // CHECK-FIXES: N(Movable M) : M(std::move(M)) {}
-
- Movable M;
- T A;
-};
-
-// Test with value parameter.
-struct O {
- O(Movable M) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
- // CHECK-FIXES: O(Movable M) : M(std::move(M)) {}
- Movable M;
-};
-
-// Test with a const-value parameter.
-struct P {
- P(const Movable M) : M(M) {}
- // CHECK-FIXES: P(const Movable M) : M(M) {}
- Movable M;
-};
-
-// Test with multiples parameters where some need to be changed and some don't.
-// need to.
-struct Q {
- Q(const Movable &A, const Movable &B, const Movable &C, double D)
- : A(A), B(B), C(C), D(D) {}
- // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: pass by value and use std::move
- // CHECK-MESSAGES: :[[@LINE-3]]:41: warning: pass by value and use std::move
- // CHECK-FIXES: Q(const Movable &A, Movable B, Movable C, double D)
- // CHECK-FIXES: : A(A), B(std::move(B)), C(std::move(C)), D(D) {}
- const Movable &A;
- Movable B;
- Movable C;
- double D;
-};
-
-// Test that value-parameters with a nested name specifier are left as-is.
-namespace ns_R {
-typedef ::Movable RMovable;
-}
-struct R {
- R(ns_R::RMovable M) : M(M) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: pass by value and use std::move
- // CHECK-FIXES: R(ns_R::RMovable M) : M(std::move(M)) {}
- ns_R::RMovable M;
-};
-
-// Test with rvalue parameter.
-struct S {
- S(Movable &&M) : M(M) {}
- // CHECK-FIXES: S(Movable &&M) : M(M) {}
- Movable M;
-};
-
-template <typename T, int N> struct array { T A[N]; };
-
-// Test that types that are trivially copyable will not use std::move. This will
-// cause problems with performance-move-const-arg, as it will revert it.
-struct T {
- T(array<int, 10> a) : a_(a) {}
- // CHECK-FIXES: T(array<int, 10> a) : a_(a) {}
- array<int, 10> a_;
-};
-
-struct U {
- U(const POD &M) : M(M) {}
- POD M;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-delimiter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-delimiter.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-delimiter.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-delimiter.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-raw-string-literal %t -- -config='{CheckOptions: [{key: "modernize-raw-string-literal.DelimiterStem", value: "str"}, {key: modernize-raw-string-literal.ReplaceShorterLiterals, value: 1}]}'
-
-char const *const ContainsSentinel{"who\\ops)\""};
-// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const ContainsSentinel{R"str(who\ops)")str"};{{$}}
-
-//char const *const ContainsDelim{"whoops)\")lit\""};
-// CHECK-XMESSAGES: :[[@LINE-1]]:33: warning: {{.*}} can be written as a raw string literal
-// CHECK-XFIXES: {{^}}char const *const ContainsDelim{R"lit1(whoops)")lit")lit1"};{{$}}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-replace-shorter.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-replace-shorter.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-replace-shorter.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal-replace-shorter.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-raw-string-literal %t
-
-// Don't replace these, because the raw literal would be longer.
-char const *const JustAQuote("quote:\'");
-char const *const NeedDelimiter("\":)\"");
-
-char const *const ManyQuotes("quotes:\'\'\'\'");
-// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const ManyQuotes(R"(quotes:'''')");{{$}}
-
-char const *const LongOctal("\042\072\051\042");
-// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const LongOctal(R"lit(":)")lit");{{$}}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-raw-string-literal.cpp (removed)
@@ -1,132 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s modernize-raw-string-literal %t -- -config="{CheckOptions: [{key: modernize-raw-string-literal.ReplaceShorterLiterals, value: 1}]}"
-// FIXME: Fix the checker to work in C++2a mode.
-
-char const *const BackSlash("goink\\frob");
-// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: escaped string literal can be written as a raw string literal [modernize-raw-string-literal]
-// CHECK-FIXES: {{^}}char const *const BackSlash(R"(goink\frob)");{{$}}
-
-char const *const PlainLiteral("plain literal");
-
-// Non-printable ASCII characters.
-char const *const Nul("goink\\\000");
-char const *const Soh("goink\\\001");
-char const *const Stx("goink\\\002");
-char const *const Etx("goink\\\003");
-char const *const Enq("goink\\\004");
-char const *const Ack("goink\\\005");
-char const *const Bell("goink\\\afrob");
-char const *const BackSpace("goink\\\bfrob");
-char const *const HorizontalTab("goink\\\tfrob");
-char const *const NewLine("goink\nfrob");
-char const *const VerticalTab("goink\\\vfrob");
-char const *const FormFeed("goink\\\ffrob");
-char const *const CarraigeReturn("goink\\\rfrob");
-char const *const So("goink\\\016");
-char const *const Si("goink\\\017");
-char const *const Dle("goink\\\020");
-char const *const Dc1("goink\\\021");
-char const *const Dc2("goink\\\022");
-char const *const Dc3("goink\\\023");
-char const *const Dc4("goink\\\024");
-char const *const Nak("goink\\\025");
-char const *const Syn("goink\\\026");
-char const *const Etb("goink\\\027");
-char const *const Can("goink\\\030");
-char const *const Em("goink\\\031");
-char const *const Sub("goink\\\032");
-char const *const Esc("goink\\\033");
-char const *const Fs("goink\\\034");
-char const *const Gs("goink\\\035");
-char const *const Rs("goink\\\036");
-char const *const Us("goink\\\037");
-char const *const HexNonPrintable("\\\x03");
-char const *const Delete("\\\177");
-char const *const MultibyteSnowman("\xE2\x98\x83");
-// CHECK-FIXES: {{^}}char const *const MultibyteSnowman("\xE2\x98\x83");{{$}}
-
-char const *const TrailingSpace("A line \\with space. \n");
-char const *const TrailingNewLine("A single \\line.\n");
-char const *const AlreadyRaw(R"(foobie\\bletch)");
-char const *const UTF8Literal(u8"foobie\\bletch");
-char const *const UTF8RawLiteral(u8R"(foobie\\bletch)");
-// TODO: enable these tests once all supported compilers
-// support char16_t and char32_t (VS2013 does not)
-// char16_t const *const UTF16Literal(u"foobie\\bletch");
-// char16_t const *const UTF16RawLiteral(uR"(foobie\\bletch)");
-// char32_t const *const UTF32Literal(U"foobie\\bletch");
-// char32_t const *const UTF32RawLiteral(UR"(foobie\\bletch)");
-wchar_t const *const WideLiteral(L"foobie\\bletch");
-wchar_t const *const WideRawLiteral(LR"(foobie\\bletch)");
-
-char const *const SingleQuote("goink\'frob");
-// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal
-// CHECK-XFIXES: {{^}}char const *const SingleQuote(R"(goink'frob)");{{$}}
-
-char const *const DoubleQuote("goink\"frob");
-// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const DoubleQuote(R"(goink"frob)");{{$}}
-
-char const *const QuestionMark("goink\?frob");
-// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const QuestionMark(R"(goink?frob)");{{$}}
-
-char const *const RegEx("goink\\(one|two\\)\\\\\\?.*\\nfrob");
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const RegEx(R"(goink\(one|two\)\\\?.*\nfrob)");{{$}}
-
-char const *const Path("C:\\Program Files\\Vendor\\Application\\Application.exe");
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const Path(R"(C:\Program Files\Vendor\Application\Application.exe)");{{$}}
-
-char const *const ContainsSentinel("who\\ops)\"");
-// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const ContainsSentinel(R"lit(who\ops)")lit");{{$}}
-
-char const *const ContainsDelim("whoops)\")lit\"");
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const ContainsDelim(R"lit1(whoops)")lit")lit1");{{$}}
-
-char const *const OctalPrintable("\100\\");
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const OctalPrintable(R"(@\)");{{$}}
-
-char const *const HexPrintable("\x40\\");
-// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: {{.*}} can be written as a raw string literal
-// CHECK-FIXES: {{^}}char const *const HexPrintable(R"(@\)");{{$}}
-
-char const *const prettyFunction(__PRETTY_FUNCTION__);
-char const *const function(__FUNCTION__);
-char const *const func(__func__);
-
-#define TRICK(arg_) #arg_
-char const *const MacroBody = TRICK(foo\\bar);
-
-#define HAT(rabbit_) #rabbit_ "foo\\bar"
-char const *const StringizedMacroArgument = HAT(foo\\bar);
-
-#define SUBST(lit_) lit_
-char const *const MacroArgument = SUBST("foo\\bar");
-// FIXME: We should be able to replace this string literal macro argument
-
-template <typename T>
-void fn(char const *const Arg) {
- char const *const Str("foo\\bar");
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}} can be written as a raw string literal
- // CHECK-FIXES: {{^}} char const *const Str(R"(foo\bar)");{{$}}
-}
-
-template <>
-void fn<int>(char const *const Arg) {
- char const *const Str("foo\\bar");
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: {{.*}} can be written as a raw string literal
- // CHECK-FIXES: {{^}} char const *const Str(R"(foo\bar)");{{$}}
-}
-
-void callFn() {
- fn<int>("foo\\bar");
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}} can be written as a raw string literal
- // CHECK-FIXES: {{^}} fn<int>(R"(foo\bar)");{{$}}
- fn<double>("foo\\bar");
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} can be written as a raw string literal
- // CHECK-FIXES: {{^}} fn<double>(R"(foo\bar)");{{$}}
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg-delayed.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg-delayed.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg-delayed.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg-delayed.cpp (removed)
@@ -1,28 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-redundant-void-arg %t -- -- -fdelayed-template-parsing
-
-int foo(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
-// CHECK-FIXES: {{^}}int foo() {{{$}}
- return 0;
-}
-
-template <class T>
-struct MyFoo {
- int foo(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
-// CHECK-FIXES: {{^}} int foo() {{{$}}
- return 0;
- }
-};
-// Explicit instantiation.
-template class MyFoo<int>;
-
-template <class T>
-struct MyBar {
- // This declaration isn't instantiated and won't be parsed 'delayed-template-parsing'.
- int foo(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
-// CHECK-FIXES: {{^}} int foo() {{{$}}
- return 0;
- }
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.c (removed)
@@ -1,58 +0,0 @@
-// RUN: clang-tidy -checks=-*,modernize-redundant-void-arg %s -- -x c | count 0
-
-#define NULL 0
-
-extern int i;
-
-int foo2() {
- return 0;
-}
-
-int j = 1;
-
-int foo(void) {
- return 0;
-}
-
-typedef unsigned int my_uint;
-
-typedef void my_void;
-
-// A function taking void and returning a pointer to function taking void
-// and returning int.
-int (*returns_fn_void_int(void))(void);
-
-typedef int (*returns_fn_void_int_t(void))(void);
-
-int (*returns_fn_void_int(void))(void) {
- return NULL;
-}
-
-// A function taking void and returning a pointer to a function taking void
-// and returning a pointer to a function taking void and returning void.
-void (*(*returns_fn_returns_fn_void_void(void))(void))(void);
-
-typedef void (*(*returns_fn_returns_fn_void_void_t(void))(void))(void);
-
-void (*(*returns_fn_returns_fn_void_void(void))(void))(void) {
- return NULL;
-}
-
-void bar() {
- int i;
- int *pi = NULL;
- void *pv = (void *) pi;
- float f;
- float *fi;
- double d;
- double *pd;
-}
-
-void (*f1)(void);
-void (*f2)(void) = NULL;
-void (*f3)(void) = bar;
-void (*fa)();
-void (*fb)() = NULL;
-void (*fc)() = bar;
-
-typedef void (function_ptr)(void);
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp (removed)
@@ -1,558 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-redundant-void-arg %t
-
-#define NULL 0
-
-int foo();
-
-void bar();
-
-void bar2();
-
-extern "C" void ecfoo(void);
-
-extern "C" void ecfoo(void) {
-}
-
-extern int i;
-
-int j = 1;
-
-int foo(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
-// CHECK-FIXES: {{^}}int foo() {{{$}}
- return 0;
-}
-
-typedef unsigned int my_uint;
-
-typedef void my_void;
-
-// A function taking void and returning a pointer to function taking void
-// and returning int.
-int (*returns_fn_void_int(void))(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function declaration
-// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function declaration
-// CHECK-FIXES: {{^}}int (*returns_fn_void_int())();{{$}}
-
-typedef int (*returns_fn_void_int_t(void))(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: {{.*}} in typedef
-// CHECK-MESSAGES: :[[@LINE-2]]:44: warning: {{.*}} in typedef
-// CHECK-FIXES: {{^}}typedef int (*returns_fn_void_int_t())();{{$}}
-
-// Should work for type aliases as well as typedef.
-using returns_fn_void_int_t2 = int (*(void))(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: {{.*}} in type alias
-// CHECK-MESSAGES: :[[@LINE-2]]:46: warning: {{.*}} in type alias
-// CHECK-FIXES: {{^}}using returns_fn_void_int_t2 = int (*())();{{$}}
-
-int (*returns_fn_void_int(void))(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function definition
-// CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^}}int (*returns_fn_void_int())() {{{$}}
- return nullptr;
-}
-
-// A function taking void and returning a pointer to a function taking void
-// and returning a pointer to a function taking void and returning void.
-void (*(*returns_fn_returns_fn_void_void(void))(void))(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: {{.*}} in function declaration
-// CHECK-MESSAGES: :[[@LINE-2]]:49: warning: {{.*}} in function declaration
-// CHECK-MESSAGES: :[[@LINE-3]]:56: warning: {{.*}} in function declaration
-// CHECK-FIXES: {{^}}void (*(*returns_fn_returns_fn_void_void())())();{{$}}
-
-typedef void (*(*returns_fn_returns_fn_void_void_t(void))(void))(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:52: warning: {{.*}} in typedef
-// CHECK-MESSAGES: :[[@LINE-2]]:59: warning: {{.*}} in typedef
-// CHECK-MESSAGES: :[[@LINE-3]]:66: warning: {{.*}} in typedef
-// CHECK-FIXES: {{^}}typedef void (*(*returns_fn_returns_fn_void_void_t())())();{{$}}
-
-void (*(*returns_fn_returns_fn_void_void(void))(void))(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: {{.*}} in function definition
-// CHECK-MESSAGES: :[[@LINE-2]]:49: warning: {{.*}} in function definition
-// CHECK-MESSAGES: :[[@LINE-3]]:56: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^}}void (*(*returns_fn_returns_fn_void_void())())() {{{$}}
- return nullptr;
-}
-
-void bar(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^}}void bar() {{{$}}
-}
-
-void op_fn(int i) {
-}
-
-class gronk {
-public:
- gronk();
- ~gronk();
-
- void foo();
- void bar();
- void bar2
- ();
- void operation(int i) { }
-
-private:
- int m_i;
- int *m_pi;
- float m_f;
- float *m_pf;
- double m_d;
- double *m_pd;
-
- void (*f1)(void);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}} in field declaration
- // CHECK-FIXES: {{^ }}void (*f1)();{{$}}
-
- void (*op)(int i);
-
- void (gronk::*p1)(void);
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in field declaration
- // CHECK-FIXES: {{^ }}void (gronk::*p1)();{{$}}
-
- int (gronk::*p_mi);
-
- void (gronk::*p2)(int);
-
- void (*(*returns_fn_returns_fn_void_void(void))(void))(void);
- // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: {{.*}} in function declaration
- // CHECK-MESSAGES: :[[@LINE-2]]:51: warning: {{.*}} in function declaration
- // CHECK-MESSAGES: :[[@LINE-3]]:58: warning: {{.*}} in function declaration
- // CHECK-FIXES: {{^}} void (*(*returns_fn_returns_fn_void_void())())();{{$}}
-
- void (*(*(gronk::*returns_fn_returns_fn_void_void_mem)(void))(void))(void);
- // CHECK-MESSAGES: :[[@LINE-1]]:58: warning: {{.*}} in field declaration
- // CHECK-MESSAGES: :[[@LINE-2]]:65: warning: {{.*}} in field declaration
- // CHECK-MESSAGES: :[[@LINE-3]]:72: warning: {{.*}} in field declaration
- // CHECK-FIXES: {{^}} void (*(*(gronk::*returns_fn_returns_fn_void_void_mem)())())();{{$}}
-};
-
-int i;
-int *pi;
-void *pv = (void *) pi;
-float f;
-float *fi;
-double d;
-double *pd;
-
-void (*f1)(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}} in variable declaration
-// CHECK-FIXES: {{^}}void (*f1)();{{$}}
-
-void (*f2)(void) = nullptr;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (*f2)() = nullptr;{{$}}
-
-void (*f2b)(void)(nullptr);
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (*f2b)()(nullptr);{{$}}
-
-void (*f2c)(void){nullptr};
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (*f2c)(){nullptr};{{$}}
-
-void (*f2d)(void) = NULL;
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (*f2d)() = NULL;{{$}}
-
-void (*f2e)(void)(NULL);
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (*f2e)()(NULL);{{$}}
-
-void (*f2f)(void){NULL};
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (*f2f)(){NULL};{{$}}
-
-void (*f3)(void) = bar;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (*f3)() = bar;{{$}}
-
-void (*o1)(int i);
-void (*o2)(int i) = nullptr;
-void (*o3)(int i)(nullptr);
-void (*o4)(int i){nullptr};
-void (*o5)(int i) = NULL;
-void (*o6)(int i)(NULL);
-void (*o7)(int i){NULL};
-void (*o8)(int i) = op_fn;
-
-void (*fa)();
-
-void (*fb)() = nullptr;
-
-void (*fc)() = bar;
-
-typedef void (function_ptr)(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:29: warning: {{.*}} in typedef
-// CHECK-FIXES: {{^}}typedef void (function_ptr)();{{$}}
-
-// intentionally not LLVM style to check preservation of whitesapce
-typedef void (function_ptr2)
- (
- void
- );
-// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: {{.*}} in typedef
-// CHECK-FIXES: {{^typedef void \(function_ptr2\)$}}
-// CHECK-FIXES-NEXT: {{^ \($}}
-// CHECK-FIXES-NEXT: {{^ $}}
-// CHECK-FIXES-NEXT: {{^ \);$}}
-
-// intentionally not LLVM style to check preservation of whitesapce
-typedef
-void
-(
-*
-(
-*
-returns_fn_returns_fn_void_void_t2
-(
-void
-)
-)
-(
-void
-)
-)
-(
-void
-)
-;
-// CHECK-MESSAGES: :[[@LINE-11]]:1: warning: {{.*}} in typedef
-// CHECK-MESSAGES: :[[@LINE-8]]:1: warning: {{.*}} in typedef
-// CHECK-MESSAGES: :[[@LINE-5]]:1: warning: {{.*}} in typedef
-// CHECK-FIXES: {{^typedef$}}
-// CHECK-FIXES-NEXT: {{^void$}}
-// CHECK-FIXES-NEXT: {{^\($}}
-// CHECK-FIXES-NEXT: {{^\*$}}
-// CHECK-FIXES-NEXT: {{^\($}}
-// CHECK-FIXES-NEXT: {{^\*$}}
-// CHECK-FIXES-NEXT: {{^returns_fn_returns_fn_void_void_t2$}}
-// CHECK-FIXES-NEXT: {{^\($}}
-// CHECK-FIXES-NOT: {{[^ ]}}
-// CHECK-FIXES: {{^\)$}}
-// CHECK-FIXES-NEXT: {{^\)$}}
-// CHECK-FIXES-NEXT: {{^\($}}
-// CHECK-FIXES-NOT: {{[^ ]}}
-// CHECK-FIXES: {{^\)$}}
-// CHECK-FIXES-NEXT: {{^\)$}}
-// CHECK-FIXES-NEXT: {{^\($}}
-// CHECK-FIXES-NOT: {{[^ ]}}
-// CHECK-FIXES: {{^\)$}}
-// CHECK-FIXES-NEXT: {{^;$}}
-
-
-void (gronk::*p1)(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}} in variable declaration
-// CHECK-FIXES: {{^}}void (gronk::*p1)();{{$}}
-
-void (gronk::*p2)(void) = &gronk::foo;
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}} in variable declaration with initializer
-// CHECK-FIXES: {{^}}void (gronk::*p2)() = &gronk::foo;{{$}}
-
-typedef void (gronk::*member_function_ptr)(void);
-// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: {{.*}} in typedef
-// CHECK-FIXES: {{^}}typedef void (gronk::*member_function_ptr)();{{$}}
-
-// intentionally not LLVM style to check preservation of whitesapce
-typedef void (gronk::*member_function_ptr2)
- (
- void
- );
-// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: {{.*}} in typedef
-// CHECK-FIXES: {{^typedef void \(gronk::\*member_function_ptr2\)$}}
-// CHECK-FIXES-NEXT: {{^ \($}}
-// CHECK-FIXES-NEXT: {{^ $}}
-// CHECK-FIXES-NEXT: {{^ \);$}}
-
-void gronk::foo() {
- void (*f1)(void) = &::bar;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
- // CHECK-FIXES: {{^ }}void (*f1)() = &::bar;{{$}}
-
- void (*f2)(void);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration
- // CHECK-FIXES: {{^ }}void (*f2)();{{$}}
-
- // intentionally not LLVM style to check preservation of whitesapce
- void (*f3)
- (
- void
- );
- // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: {{.*}} in variable declaration
- // CHECK-FIXES: {{^ }}void (*f3){{$}}
- // CHECK-FIXES-NEXT: {{^ \($}}
- // CHECK-FIXES-NEXT: {{^ $}}
- // CHECK-FIXES-NEXT: {{^ \);$}}
-}
-
-void gronk::bar(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^}}void gronk::bar() {{{$}}
- void (gronk::*p3)(void) = &gronk::foo;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in variable declaration with initializer
- // CHECK-FIXES: {{^ }}void (gronk::*p3)() = &gronk::foo;{{$}}
-
- void (gronk::*p4)(void);
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}} in variable declaration
- // CHECK-FIXES: {{^ }}void (gronk::*p4)();{{$}}
-
- // intentionally not LLVM style to check preservation of whitesapce
- void (gronk::*p5)
- (
- void
- );
- // CHECK-MESSAGES: :[[@LINE-2]]:11: warning: {{.*}} in variable declaration
- // CHECK-FIXES: {{^ }}void (gronk::*p5){{$}}
- // CHECK-FIXES-NEXT: {{^ \($}}
- // CHECK-FIXES-NExT: {{^ $}}
- // CHECK-FIXES-NExT: {{^ \);$}}
-}
-
-// intentionally not LLVM style to check preservation of whitesapce
-void gronk::bar2
- (
- void
- )
-// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^void gronk::bar2$}}
-// CHECK-FIXES-NEXT: {{^ \($}}
-// CHECK-FIXES-NEXT: {{^ $}}
-// CHECK-FIXES-NEXT: {{^ \)$}}
-{
-}
-
-gronk::gronk(void)
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^}}gronk::gronk(){{$}}
- : f1(nullptr),
- p1(nullptr) {
-}
-
-gronk::~gronk(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^}}gronk::~gronk() {{{$}}
-}
-
-class nutter {
-public:
- nutter();
-};
-
-nutter::nutter(void) {
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}} in function definition
-// CHECK-FIXES: {{^}}nutter::nutter() {{{$}}
- void (*f3)(void) = static_cast<void (*)(void)>(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
- // CHECK-MESSAGES: :[[@LINE-2]]:43: warning: {{.*}} in named cast
- // CHECK-FIXES: void (*f3)() = static_cast<void (*)()>(0);{{$}}
-
- void (*f4)(void) = (void (*)(void)) 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
- // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: {{.*}} in cast expression
- // CHECK-FIXES: void (*f4)() = (void (*)()) 0;{{$}}
-
- void (*f5)(void) = reinterpret_cast<void (*)(void)>(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}} in variable declaration with initializer
- // CHECK-MESSAGES: :[[@LINE-2]]:48: warning: {{.*}} in named cast
- // CHECK-FIXES: void (*f5)() = reinterpret_cast<void (*)()>(0);{{$}}
-
- // intentionally not LLVM style to check preservation of whitesapce
- void (*f6)(void) = static_cast<void (*)
- (
- void
- )>(0);
- // CHECK-MESSAGES: :[[@LINE-4]]:14: warning: {{.*}} in variable declaration with initializer
- // CHECK-MESSAGES: :[[@LINE-3]]:11: warning: {{.*}} in named cast
- // CHECK-FIXES: {{^ }}void (*f6)() = static_cast<void (*){{$}}
- // CHECK-FIXES-NEXT: {{^ \($}}
- // CHECK-FIXES-NEXT: {{^ $}}
- // CHECK-FIXES-NEXT: {{^ }})>(0);{{$}}
-
- // intentionally not LLVM style to check preservation of whitesapce
- void (*f7)(void) = (void (*)
- (
- void
- )) 0;
- // CHECK-MESSAGES: :[[@LINE-4]]:14: warning: {{.*}} in variable declaration with initializer
- // CHECK-MESSAGES: :[[@LINE-3]]:11: warning: {{.*}} in cast expression
- // CHECK-FIXES: {{^ }}void (*f7)() = (void (*){{$}}
- // CHECK-FIXES-NEXT: {{^ \($}}
- // CHECK-FIXES-NEXT: {{^ $}}
- // CHECK-FIXES-NEXT: {{^ \)\) 0;$}}
-
- // intentionally not LLVM style to check preservation of whitesapce
- void (*f8)(void) = reinterpret_cast<void (*)
- (
- void
- )>(0);
- // CHECK-MESSAGES: :[[@LINE-4]]:14: warning: {{.*}} in variable declaration with initializer
- // CHECK-MESSAGES: :[[@LINE-3]]:11: warning: {{.*}} in named cast
- // CHECK-FIXES: {{^ }}void (*f8)() = reinterpret_cast<void (*){{$}}
- // CHECK-FIXES-NEXT: {{^ \($}}
- // CHECK-FIXES-NEXT: {{^ $}}
- // CHECK-FIXES-NEXT: {{^ \)>\(0\);$}}
-
- void (*o1)(int) = static_cast<void (*)(int)>(0);
- void (*o2)(int) = (void (*)(int)) 0;
- void (*o3)(int) = reinterpret_cast<void (*)(int)>(0);
-}
-
-class generator {
-public:
- int operator()(void) { return 1; }
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: {{.*}} in function definition
- // CHECK-FIXES: {{^ }}int operator()() { return 1; }{{$}}
-};
-
-void test_lambda_functions() {
- auto lamb_duh = [](void (*fn)(void)) { (*fn)(); };
- // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: {{.*}} in variable declaration
- // CHECK-FIXES: {{^ }}auto lamb_duh = [](void (*fn)()) { (*fn)(); };{{$}}
-
- auto lambda_generator = [](void) { return 1; };
- // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: {{.*}} in lambda expression
- // CHECK-FIXES: {{^ }}auto lambda_generator = []() { return 1; };{{$}}
-
- auto gen2 = []() { return 1; };
-
- auto gen3 = []{ return 1; };
-
- auto void_returner = [](void) -> void (*)(void) { return f1; };
- // CHECK-MESSAGES: [[@LINE-1]]:27: warning: {{.*}} in lambda expression
- // CHECK-MESSAGES: [[@LINE-2]]:45: warning: {{.*}} in lambda expression
- // CHECK-FIXES: {{^ }}auto void_returner = []() -> void (*)() { return f1; };{{$}}
-}
-
-#define M(x) x
-
-M(void inmacro(void) {})
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: {{.*}} in function definition
-// CHECK-FIXES: M(void inmacro() {})
-
-#define F(A, B) \
- struct F_##A##_##B { \
- F_##A##_##B(void); \
- }; \
- F_##A##_##B::F_##A##_##B(void)
-
-F(Foo, Bar) {
-
-}
-
-struct DefinitionWithNoBody {
- DefinitionWithNoBody(void) = delete;
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: {{.*}} in function definition
- // CHECK-FIXES: DefinitionWithNoBody() = delete;
-};
-
-
-
-#define BODY {}
-#define LAMBDA1 [](void){}
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
-// CHECK-FIXES: LAMBDA1 [](){}
-
-#define LAMBDA2 [](void)BODY
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
-// CHECK-FIXES: LAMBDA2 []()BODY
-
-#define LAMBDA3(captures, args, body) captures args body
-#define WRAP(...) __VA_ARGS__
-
-#define LAMBDA4 (void)LAMBDA3([],(void),BODY)
-// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
-// CHECK-FIXES: LAMBDA4 (void)LAMBDA3([],(),BODY)
-
-#define LAMBDA5 []() -> void (*)(void) {return BODY;}
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
-// CHECK-FIXES: LAMBDA5 []() -> void (*)() {return BODY;}
-void lambda_expression_with_macro_test(){
- (void)LAMBDA1;
- (void)LAMBDA2;
- (void)LAMBDA3([], (void), BODY);
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
- // CHECK-FIXES: (void)LAMBDA3([], (), BODY);
-
- LAMBDA4;
- LAMBDA5;
- WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP((void)), WRAP(BODY)))));
- // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
- // CHECK-FIXES: WRAP((void)WRAP(WRAP(LAMBDA3(WRAP([]), WRAP(()), WRAP(BODY)))));
-
- (void)WRAP([](void) {});
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
- // CHECK-FIXES: (void)WRAP([]() {});
-
- [](void) BODY;
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: redundant void argument list in lambda expression [modernize-redundant-void-arg]
- // CHECK-FIXES: []() BODY;
-}
-
-namespace qqq {
-void foo() BODY
-void bar(void) BODY;
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition
-// CHECK-FIXES: void bar() BODY;
-}
-
-struct S_1 {
- void g_1(void) const {
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
- // CHECK-FIXES: void g_1() const {
- int a;
- (void)a;
- }
-
- void g_2() const {
- int a;
- (void)a;
- }
-};
-
-template <typename T0>
-struct S_2 {
- void g_1(void) const {
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
- // CHECK-FIXES: void g_1() const {
- int a;
- (void)a;
- }
-
- void g_2() const {
- int a;
- (void)a;
- }
-};
-
-template <typename T0>
-struct S_3 {
- template <typename T1>
- void g_1(void) const {
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
- // CHECK-FIXES: void g_1() const {
- int a;
- (void)a;
- }
- template <typename T2>
- void g_2() const {
- int a;
- (void)a;
- }
-};
-
-template <typename T1>
-void g_3(void) {
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: redundant void argument list in function definition [modernize-redundant-void-arg]
- // CHECK-FIXES: void g_3() {
- int a;
- (void)a;
-}
-
-//Template instantiation
-void f_testTemplate() {
- S_1();
- S_2<int>();
- S_3<int>();
- g_3<int>();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-replace-auto-ptr.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-replace-auto-ptr.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-replace-auto-ptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-replace-auto-ptr.cpp (removed)
@@ -1,303 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-replace-auto-ptr %t -- -- -I %S/Inputs/modernize-replace-auto-ptr
-
-// CHECK-FIXES: #include <utility>
-
-#include "memory.h"
-
-// Instrumentation for auto_ptr_ref test.
-struct Base {};
-struct Derived : Base {};
-std::auto_ptr<Derived> create_derived_ptr();
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated, use unique_ptr instead [modernize-replace-auto-ptr]
-// CHECK-FIXES: std::unique_ptr<Derived> create_derived_ptr();
-
-
-// Test function return values (declaration)
-std::auto_ptr<char> f_5();
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated
-// CHECK-FIXES: std::unique_ptr<char> f_5()
-
-
-// Test function parameters.
-void f_6(std::auto_ptr<int>);
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: auto_ptr is deprecated
-// CHECK-FIXES: void f_6(std::unique_ptr<int>);
-void f_7(const std::auto_ptr<int> &);
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: auto_ptr is deprecated
-// CHECK-FIXES: void f_7(const std::unique_ptr<int> &);
-
-
-// Test on record type fields.
-struct A {
- std::auto_ptr<int> field;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> field;
-
- typedef std::auto_ptr<int> int_ptr_type;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: auto_ptr is deprecated
- // CHECK-FIXES: typedef std::unique_ptr<int> int_ptr_type;
-};
-
-
-// FIXME: Test template WITH instantiation.
-template <typename T> struct B {
- typedef typename std::auto_ptr<T> created_type;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: auto_ptr is deprecated
- // CHECK-FIXES: typedef typename std::unique_ptr<T> created_type;
-
- created_type create() { return std::auto_ptr<T>(new T()); }
- // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: auto_ptr is deprecated
- // CHECK-FIXES: created_type create() { return std::unique_ptr<T>(new T()); }
-};
-
-
-// Test 'using' in a namespace (declaration)
-namespace ns_1 {
-// Test multiple using declarations.
- using std::auto_ptr;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated
- // CHECK-FIXES: using std::unique_ptr;
- using std::auto_ptr;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated
- // CHECK-FIXES: using std::unique_ptr;
-}
-
-
-namespace ns_2 {
-template <typename T> struct auto_ptr {};
-}
-
-void f_1() {
- std::auto_ptr<int> a;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> a;
-
- // Check that spaces aren't modified unnecessarily.
- std:: auto_ptr <int> b;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: auto_ptr is deprecated
- // CHECK-FIXES: std:: unique_ptr <int> b;
- std :: auto_ptr < char > c(new char());
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: auto_ptr is deprecated
- // CHECK-FIXES: std :: unique_ptr < char > c(new char());
-
- // Test construction from a temporary.
- std::auto_ptr<char> d = std::auto_ptr<char>();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<char> d = std::unique_ptr<char>();
-
- typedef std::auto_ptr<int> int_ptr_t;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: auto_ptr is deprecated
- // CHECK-FIXES: typedef std::unique_ptr<int> int_ptr_t;
- int_ptr_t e(new int());
-
- // Test pointers.
- std::auto_ptr<int> *f;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> *f;
-
- // Test 'static' declarations.
- static std::auto_ptr<int> g;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: auto_ptr is deprecated
- // CHECK-FIXES: static std::unique_ptr<int> g;
-
- // Test with cv-qualifiers.
- const std::auto_ptr<int> h;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated
- // CHECK-FIXES: const std::unique_ptr<int> h;
- volatile std::auto_ptr<int> i;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: auto_ptr is deprecated
- // CHECK-FIXES: volatile std::unique_ptr<int> i;
- const volatile std::auto_ptr<int> j;
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: auto_ptr is deprecated
- // CHECK-FIXES: const volatile std::unique_ptr<int> j;
-
- // Test auto and initializer-list.
- auto k = std::auto_ptr<int>{};
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: auto_ptr is deprecated
- // CHECK-FIXES: auto k = std::unique_ptr<int>{};
- std::auto_ptr<int> l{std::auto_ptr<int>()};
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> l{std::unique_ptr<int>()};
-
- // Test interlocked auto_ptr.
- std::auto_ptr<std::auto_ptr<int> > m;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-MESSAGES: :[[@LINE-2]]:22: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<std::unique_ptr<int> > m;
-
- // Test temporaries.
- std::auto_ptr<char>();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<char>();
-
- // Test void-specialization.
- std::auto_ptr<void> n;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<void> n;
-
- // Test template WITH instantiation (instantiation).
- B<double> o;
- std::auto_ptr<double> p(o.create());
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<double> p(o.create());
-
- // Test 'using' in a namespace ("definition").
- ns_1::auto_ptr<int> q;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: auto_ptr is deprecated
- // CHECK-FIXES: ns_1::unique_ptr<int> q;
-
- // Test construction with an 'auto_ptr_ref'.
- std::auto_ptr<Base> r(create_derived_ptr());
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<Base> r(create_derived_ptr());
-}
-
-// Test without the nested name specifiers.
-void f_2() {
- using namespace std;
-
- auto_ptr<int> a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: auto_ptr is deprecated
- // CHECK-FIXES: unique_ptr<int> a;
-}
-
-// Test using declaration.
-void f_3() {
- using std::auto_ptr;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: auto_ptr is deprecated
- // CHECK-FIXES: using std::unique_ptr;
-
- auto_ptr<int> a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: auto_ptr is deprecated
- // CHECK-FIXES: unique_ptr<int> a;
-}
-
-// Test messing-up with macros.
-void f_4() {
-#define MACRO_1 <char>
- std::auto_ptr MACRO_1 p(new char());
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr MACRO_1 p(new char());
-#define MACRO_2 auto_ptr
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: auto_ptr is deprecated
- // CHECK-FIXES: #define MACRO_2 unique_ptr
- std::MACRO_2<int> q;
-#define MACRO_3(Type) std::auto_ptr<Type>
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: auto_ptr is deprecated
- // CHECK-FIXES: #define MACRO_3(Type) std::unique_ptr<Type>
- MACRO_3(float)r(new float());
-#define MACRO_4 std::auto_ptr
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: auto_ptr is deprecated
- // CHECK-FIXES: #define MACRO_4 std::unique_ptr
- using MACRO_4;
-#undef MACRO_1
-#undef MACRO_2
-#undef MACRO_3
-#undef MACRO_4
-}
-
-// Test function return values (definition).
-std::auto_ptr<char> f_5()
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<char> f_5()
-{
- // Test constructor.
- return std::auto_ptr<char>(new char());
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: auto_ptr is deprecated
- // CHECK-FIXES: return std::unique_ptr<char>(new char());
-}
-
-// Test that non-std auto_ptr aren't replaced.
-void f_8() {
- ns_2::auto_ptr<char> a;
- using namespace ns_2;
- auto_ptr<int> b;
-}
-
-// Fail to modify when the template is never instantiated.
-//
-// This might not be an issue. If it's never used it doesn't really matter if
-// it's changed or not. If it's a header and one of the source use it, then it
-// will still be changed.
-template <typename X>
-void f() {
- std::auto_ptr<X> p;
-}
-
-// FIXME: Alias template could be replaced if a matcher existed.
-namespace std {
-template <typename T> using aaaaaaaa = auto_ptr<T>;
-}
-
-// We want to avoid replacing 'aaaaaaaa' by unique_ptr here. It's better to
-// change the type alias directly.
-std::aaaaaaaa<int> d;
-
-
-void takes_ownership_fn(std::auto_ptr<int> x);
-// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: auto_ptr is deprecated
-// CHECK-FIXES: void takes_ownership_fn(std::unique_ptr<int> x);
-
-std::auto_ptr<int> get_by_value();
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: auto_ptr is deprecated
-// CHECK-FIXES: std::unique_ptr<int> get_by_value();
-
-class Wrapper {
- public:
- std::auto_ptr<int> &get_wrapped();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
-
- private:
- std::auto_ptr<int> wrapped;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
-};
-
-void f() {
- std::auto_ptr<int> a, b, c;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> a, b, c;
- Wrapper wrapper_a, wrapper_b;
-
- a = b;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::move to transfer ownership
- // CHECK-FIXES: a = std::move(b);
-
- wrapper_a.get_wrapped() = wrapper_b.get_wrapped();
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use std::move to transfer ownership
- // CHECK-FIXES: wrapper_a.get_wrapped() = std::move(wrapper_b.get_wrapped());
-
- // Test that 'std::move()' is inserted when call to the
- // copy-constructor are made.
- takes_ownership_fn(c);
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::move to transfer ownership
- // CHECK-FIXES: takes_ownership_fn(std::move(c));
- takes_ownership_fn(wrapper_a.get_wrapped());
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::move to transfer ownership
- // CHECK-FIXES: takes_ownership_fn(std::move(wrapper_a.get_wrapped()));
-
- std::auto_ptr<int> d[] = { std::auto_ptr<int>(new int(1)),
- std::auto_ptr<int>(new int(2)) };
- // CHECK-MESSAGES: :[[@LINE-2]]:8: warning: auto_ptr is deprecated
- // CHECK-MESSAGES: :[[@LINE-3]]:35: warning: auto_ptr is deprecated
- // CHECK-MESSAGES: :[[@LINE-3]]:35: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> d[] = { std::unique_ptr<int>(new int(1)),
- // CHECK-FIXES-NEXT: std::unique_ptr<int>(new int(2)) };
- std::auto_ptr<int> e = d[0];
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: use std::move to transfer ownership
- // CHECK: std::unique_ptr<int> e = std::move(d[0]);
-
- // Test that std::move() is not used when assigning an rvalue
- std::auto_ptr<int> f;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> f;
- f = std::auto_ptr<int>(new int(0));
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: auto_ptr is deprecated
- // CHECK-NEXT: f = std::unique_ptr<int>(new int(0));
-
- std::auto_ptr<int> g = get_by_value();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: auto_ptr is deprecated
- // CHECK-FIXES: std::unique_ptr<int> g = get_by_value();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-replace-random-shuffle.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-replace-random-shuffle.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-replace-random-shuffle.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-replace-random-shuffle.cpp (removed)
@@ -1,57 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-replace-random-shuffle %t
-
-//CHECK-FIXES: #include <random>
-
-namespace std {
-template <typename T> struct vec_iterator {
- T *ptr;
- vec_iterator operator++(int);
-};
-
-template <typename T> struct vector {
- typedef vec_iterator<T> iterator;
-
- iterator begin();
- iterator end();
-};
-
-template <typename FwIt>
-void random_shuffle(FwIt begin, FwIt end);
-
-template <typename FwIt, typename randomFunc>
-void random_shuffle(FwIt begin, FwIt end, randomFunc& randomfunc);
-
-template <typename FwIt>
-void shuffle(FwIt begin, FwIt end);
-} // namespace std
-
-// Random Func
-int myrandom (int i) { return i;}
-
-using namespace std;
-
-int main() {
- std::vector<int> vec;
-
- std::random_shuffle(vec.begin(), vec.end());
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' instead
- // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
-
- std::shuffle(vec.begin(), vec.end());
-
- random_shuffle(vec.begin(), vec.end());
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' instead
- // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
-
- std::random_shuffle(vec.begin(), vec.end(), myrandom);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' and an alternative random mechanism instead
- // CHECK-FIXES: std::shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
-
- random_shuffle(vec.begin(), vec.end(), myrandom);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::random_shuffle' has been removed in C++17; use 'std::shuffle' and an alternative random mechanism instead
- // CHECK-FIXES: shuffle(vec.begin(), vec.end(), std::mt19937(std::random_device()()));
-
- shuffle(vec.begin(), vec.end());
-
- return 0;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-return-braced-init-list.cpp (removed)
@@ -1,199 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14 %s modernize-return-braced-init-list %t
-// FIXME: Fix the checker to work in C++17 mode.
-
-namespace std {
-typedef decltype(sizeof(int)) size_t;
-
-// libc++'s implementation
-template <class _E>
-class initializer_list {
- const _E *__begin_;
- size_t __size_;
-
- initializer_list(const _E *__b, size_t __s)
- : __begin_(__b),
- __size_(__s) {}
-
-public:
- typedef _E value_type;
- typedef const _E &reference;
- typedef const _E &const_reference;
- typedef size_t size_type;
-
- typedef const _E *iterator;
- typedef const _E *const_iterator;
-
- initializer_list() : __begin_(nullptr), __size_(0) {}
-
- size_t size() const { return __size_; }
- const _E *begin() const { return __begin_; }
- const _E *end() const { return __begin_ + __size_; }
-};
-
-template <typename T>
-class vector {
-public:
- vector(T) {}
- vector(std::initializer_list<T>) {}
-};
-}
-
-class Bar {};
-
-Bar b0;
-
-class Foo {
-public:
- Foo(Bar) {}
- explicit Foo(Bar, unsigned int) {}
- Foo(unsigned int) {}
-};
-
-class Baz {
-public:
- Foo m() {
- Bar bm;
- return Foo(bm);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: avoid repeating the return type from the declaration; use a braced initializer list instead [modernize-return-braced-init-list]
- // CHECK-FIXES: return {bm};
- }
-};
-
-class Quux : public Foo {
-public:
- Quux(Bar bar) : Foo(bar) {}
- Quux(unsigned, unsigned, unsigned k = 0) : Foo(k) {}
-};
-
-Foo f() {
- Bar b1;
- return Foo(b1);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
- // CHECK-FIXES: return {b1};
-}
-
-Foo f2() {
- Bar b2;
- return {b2};
-}
-
-auto f3() {
- Bar b3;
- return Foo(b3);
-}
-
-#define A(b) Foo(b)
-
-Foo f4() {
- Bar b4;
- return A(b4);
-}
-
-Foo f5() {
- Bar b5;
- return Quux(b5);
-}
-
-Foo f6() {
- Bar b6;
- return Foo(b6, 1);
-}
-
-std::vector<int> f7() {
- int i7 = 1;
- return std::vector<int>(i7);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
-}
-
-Bar f8() {
- return {};
-}
-
-Bar f9() {
- return Bar();
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
-}
-
-Bar f10() {
- return Bar{};
-}
-
-Foo f11(Bar b11) {
- return Foo(b11);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
- // CHECK-FIXES: return {b11};
-}
-
-Foo f12() {
- return f11(Bar());
-}
-
-Foo f13() {
- return Foo(Bar()); // 13
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
- // CHECK-FIXES: return {Bar()}; // 13
-}
-
-Foo f14() {
- // FIXME: Type narrowing should not occur!
- return Foo(-1);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
- // CHECK-FIXES: return {-1};
-}
-
-Foo f15() {
- return Foo(f10());
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
- // CHECK-FIXES: return {f10()};
-}
-
-Quux f16() {
- return Quux(1, 2);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
- // CHECK-FIXES: return {1, 2};
-}
-
-Quux f17() {
- return Quux(1, 2, 3);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: avoid repeating the return type
- // CHECK-FIXES: return {1, 2, 3};
-}
-
-template <typename T>
-T f19() {
- return T();
-}
-
-Bar i1 = f19<Bar>();
-Baz i2 = f19<Baz>();
-
-template <typename T>
-Foo f20(T t) {
- return Foo(t);
-}
-
-Foo i3 = f20(b0);
-
-template <typename T>
-class BazT {
-public:
- T m() {
- Bar b;
- return T(b);
- }
-
- Foo m2(T t) {
- return Foo(t);
- }
-};
-
-BazT<Foo> bazFoo;
-Foo i4 = bazFoo.m();
-Foo i5 = bazFoo.m2(b0);
-
-BazT<Quux> bazQuux;
-Foo i6 = bazQuux.m();
-Foo i7 = bazQuux.m2(b0);
-
-auto v1 = []() { return std::vector<int>({1, 2}); }();
-auto v2 = []() -> std::vector<int> { return std::vector<int>({1, 2}); }();
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp (removed)
@@ -1,87 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-shrink-to-fit %t
-
-namespace std {
-template <typename T> struct vector { void swap(vector &other); };
-}
-
-void f() {
- std::vector<int> v;
-
- std::vector<int>(v).swap(v);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should be used to reduce the capacity of a shrinkable container [modernize-shrink-to-fit]
- // CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
-
- std::vector<int> &vref = v;
- std::vector<int>(vref).swap(vref);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}vref.shrink_to_fit();{{$}}
-
- std::vector<int> *vptr = &v;
- std::vector<int>(*vptr).swap(*vptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}vptr->shrink_to_fit();{{$}}
-}
-
-struct X {
- std::vector<int> v;
- void f() {
- std::vector<int>(v).swap(v);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
-
- std::vector<int> *vptr = &v;
- std::vector<int>(*vptr).swap(*vptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}vptr->shrink_to_fit();{{$}}
- }
-};
-
-template <typename T> void g() {
- std::vector<int> v;
- std::vector<int>(v).swap(v);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
-
- std::vector<T> v2;
- std::vector<T>(v2).swap(v2);
- // CHECK-FIXES: {{^ }}std::vector<T>(v2).swap(v2);{{$}}
-}
-
-template <typename T> void g2() {
- std::vector<int> v;
- std::vector<int>(v).swap(v);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
-
- T v3;
- T(v3).swap(v3);
- // CHECK-FIXES: {{^ }}T(v3).swap(v3);{{$}}
-}
-
-#define COPY_AND_SWAP_INT_VEC(x) std::vector<int>(x).swap(x)
-// CHECK-FIXES: #define COPY_AND_SWAP_INT_VEC(x) std::vector<int>(x).swap(x)
-
-void h() {
- g<int>();
- g<double>();
- g<bool>();
- g2<std::vector<int>>();
- std::vector<int> v;
- COPY_AND_SWAP_INT_VEC(v);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}COPY_AND_SWAP_INT_VEC(v);{{$}}
-}
-
-void PR38315() {
- typedef std::vector<int> Vector;
- Vector v;
- Vector(v).swap(v);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}v.shrink_to_fit();{{$}}
-
- using Vector2 = std::vector<int>;
- Vector2 v2;
- Vector2(v2).swap(v2);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
- // CHECK-FIXES: {{^ }}v2.shrink_to_fit();{{$}}
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-unary-static-assert.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-unary-static-assert.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-unary-static-assert.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-unary-static-assert.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-unary-static-assert %t
-
-#define FOO static_assert(sizeof(a) <= 15, "");
-#define MSG ""
-
-void f_textless(int a) {
- static_assert(sizeof(a) <= 10, "");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use unary 'static_assert' when the string literal is an empty string [modernize-unary-static-assert]
- // CHECK-FIXES: {{^}} static_assert(sizeof(a) <= 10 );{{$}}
- static_assert(sizeof(a) <= 12, L"");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use unary 'static_assert' when
- // CHECK-FIXES: {{^}} static_assert(sizeof(a) <= 12 );{{$}}
- FOO
- // CHECK-FIXES: {{^}} FOO{{$}}
- static_assert(sizeof(a) <= 17, MSG);
- // CHECK-FIXES: {{^}} static_assert(sizeof(a) <= 17, MSG);{{$}}
-}
-
-void f_with_tex(int a) {
- static_assert(sizeof(a) <= 10, "Size of variable a is out of range!");
-}
-
-void f_unary(int a) { static_assert(sizeof(a) <= 10); }
-
-void f_incorrect_assert() { static_assert(""); }
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast-remove-stars.cpp (removed)
@@ -1,233 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'} , {key: modernize-use-auto.MinTypeNameLength, value: '0'}]}" \
-// RUN: -- -frtti
-
-struct A {
- virtual ~A() {}
-};
-
-struct B : public A {};
-
-struct C {};
-
-void f_static_cast() {
- long l = 1;
- int i1 = static_cast<int>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto i1 = static_cast<int>(l);
-
- const int i2 = static_cast<int>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: const auto i2 = static_cast<int>(l);
-
- long long ll = static_cast<long long>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ll = static_cast<long long>(l);
- unsigned long long ull = static_cast<unsigned long long>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ull = static_cast<unsigned long long>(l);
- unsigned int ui = static_cast<unsigned int>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ui = static_cast<unsigned int>(l);
- long double ld = static_cast<long double>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ld = static_cast<long double>(l);
-
- A *a = new B();
- B *b1 = static_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto b1 = static_cast<B *>(a);
-
- B *const b2 = static_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto const b2 = static_cast<B *>(a);
-
- const B *b3 = static_cast<const B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: const auto b3 = static_cast<const B *>(a);
-
- B &b4 = static_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b4 = static_cast<B &>(*a);
-
- const B &b5 = static_cast<const B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: const auto &b5 = static_cast<const B &>(*a);
-
- B &b6 = static_cast<B &>(*a), &b7 = static_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b6 = static_cast<B &>(*a), &b7 = static_cast<B &>(*a);
-
- // Don't warn when non-cast involved
- long double cast = static_cast<long double>(l), noncast = 5;
-
- // Don't warn when auto is already being used.
- auto i3 = static_cast<int>(l);
- auto *b8 = static_cast<B *>(a);
- auto &b9 = static_cast<B &>(*a);
-}
-
-void f_dynamic_cast() {
- A *a = new B();
- B *b1 = dynamic_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto b1 = dynamic_cast<B *>(a);
-
- B &b2 = dynamic_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b2 = dynamic_cast<B &>(*a);
-}
-
-void f_reinterpret_cast() {
- auto *a = new A();
- C *c1 = reinterpret_cast<C *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto c1 = reinterpret_cast<C *>(a);
-
- C &c2 = reinterpret_cast<C &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &c2 = reinterpret_cast<C &>(*a);
-}
-
-void f_const_cast() {
- const A *a1 = new A();
- A *a2 = const_cast<A *>(a1);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto a2 = const_cast<A *>(a1);
- A &a3 = const_cast<A &>(*a1);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &a3 = const_cast<A &>(*a1);
-}
-
-typedef unsigned char xmlChar;
-#define BAD_CAST (xmlChar *)
-
-#define XMLCHAR_CAST(x) (xmlChar *)(x)
-
-#define CAST_IN_MACRO(x) \
- do { \
- xmlChar *s = (xmlChar *)(x); \
- } while (false);
-// CHECK-FIXES: xmlChar *s = (xmlChar *)(x);
-
-void f_cstyle_cast() {
- auto *a = new A();
- C *c1 = (C *)a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto c1 = (C *)a;
-
- C &c2 = (C &)*a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &c2 = (C &)*a;
-
- xmlChar *s = BAD_CAST "xml";
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto s = BAD_CAST "xml";
- xmlChar *t = XMLCHAR_CAST("xml");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto t = XMLCHAR_CAST("xml");
- CAST_IN_MACRO("xml");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
-}
-
-void f_functional_cast() {
- long l = 1;
- int i1 = int(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto i1 = int(l);
-
- B b;
- A a = A(b);
-}
-
-class StringRef
-{
-public:
- StringRef(const char *);
- const char *begin() const;
- const char *end() const;
-};
-
-template <typename T, typename U>
-T template_value_cast(const U &u);
-
-template <typename T, typename U>
-T *template_pointer_cast(U *u);
-
-template <typename T, typename U>
-T &template_reference_cast(U &u);
-
-template <typename T, typename U>
-const T *template_const_pointer_cast(const U *u);
-
-template <typename T, typename U>
-const T &template_const_reference_cast(const U &u);
-
-template <typename T>
-T template_value_get(StringRef s);
-
-struct S {
- template <typename T>
- const T *template_member_get();
-};
-
-template <typename T>
-T max(T t1, T t2);
-
-void f_template_cast()
-{
- double d = 0;
- int i1 = template_value_cast<int>(d);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto i1 = template_value_cast<int>(d);
-
- A *a = new B();
- B *b1 = template_value_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto b1 = template_value_cast<B *>(a);
- B &b2 = template_value_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b2 = template_value_cast<B &>(*a);
- B *b3 = template_pointer_cast<B>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto b3 = template_pointer_cast<B>(a);
- B &b4 = template_reference_cast<B>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b4 = template_reference_cast<B>(*a);
- const B *b5 = template_const_pointer_cast<B>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: const auto b5 = template_const_pointer_cast<B>(a);
- const B &b6 = template_const_reference_cast<B>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: const auto &b6 = template_const_reference_cast<B>(*a);
- B *b7 = template_value_get<B *>("foo");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto b7 = template_value_get<B *>("foo");
- B *b8 = template_value_get<B *>("foo"), *b9 = template_value_get<B *>("bar");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto b8 = template_value_get<B *>("foo"), b9 = template_value_get<B *>("bar");
-
- S s;
- const B *b10 = s.template_member_get<B>();
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: const auto b10 = s.template_member_get<B>();
-
- // Don't warn when auto is already being used.
- auto i2 = template_value_cast<int>(d);
- auto *i3 = template_value_cast<int *>(d);
- auto **i4 = template_value_cast<int **>(d);
- auto &i5 = template_reference_cast<int>(d);
-
- // Don't warn for implicit template arguments.
- int i6 = max(i1, i2);
-
- // Don't warn for mismatched var and initializer types.
- A *a1 = template_value_cast<B *>(a);
-
- // Don't warn for mismatched var types.
- B *b11 = template_value_get<B *>("foo"), b12 = template_value_get<B>("bar");
-
- // Don't warn for implicit variables.
- for (auto &c : template_reference_cast<StringRef>(*a)) {
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-cast.cpp (removed)
@@ -1,233 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-auto.MinTypeNameLength, value: '0'}]}" \
-// RUN: -- -I %S/Inputs/modernize-use-auto -frtti
-
-struct A {
- virtual ~A() {}
-};
-
-struct B : public A {};
-
-struct C {};
-
-void f_static_cast() {
- long l = 1;
- int i1 = static_cast<int>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto i1 = static_cast<int>(l);
-
- const int i2 = static_cast<int>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: const auto i2 = static_cast<int>(l);
-
- long long ll = static_cast<long long>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ll = static_cast<long long>(l);
- unsigned long long ull = static_cast<unsigned long long>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ull = static_cast<unsigned long long>(l);
- unsigned int ui = static_cast<unsigned int>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ui = static_cast<unsigned int>(l);
- long double ld = static_cast<long double>(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto ld = static_cast<long double>(l);
-
- A *a = new B();
- B *b1 = static_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *b1 = static_cast<B *>(a);
-
- B *const b2 = static_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *const b2 = static_cast<B *>(a);
-
- const B *b3 = static_cast<const B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: const auto *b3 = static_cast<const B *>(a);
-
- B &b4 = static_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b4 = static_cast<B &>(*a);
-
- const B &b5 = static_cast<const B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: const auto &b5 = static_cast<const B &>(*a);
-
- B &b6 = static_cast<B &>(*a), &b7 = static_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b6 = static_cast<B &>(*a), &b7 = static_cast<B &>(*a);
-
- // Don't warn when non-cast involved
- long double cast = static_cast<long double>(l), noncast = 5;
-
- // Don't warn when auto is already being used.
- auto i3 = static_cast<int>(l);
- auto *b8 = static_cast<B *>(a);
- auto &b9 = static_cast<B &>(*a);
-}
-
-void f_dynamic_cast() {
- A *a = new B();
- B *b1 = dynamic_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *b1 = dynamic_cast<B *>(a);
-
- B &b2 = dynamic_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b2 = dynamic_cast<B &>(*a);
-}
-
-void f_reinterpret_cast() {
- auto *a = new A();
- C *c1 = reinterpret_cast<C *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *c1 = reinterpret_cast<C *>(a);
-
- C &c2 = reinterpret_cast<C &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &c2 = reinterpret_cast<C &>(*a);
-}
-
-void f_const_cast() {
- const A *a1 = new A();
- A *a2 = const_cast<A *>(a1);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *a2 = const_cast<A *>(a1);
- A &a3 = const_cast<A &>(*a1);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &a3 = const_cast<A &>(*a1);
-}
-
-typedef unsigned char xmlChar;
-#define BAD_CAST (xmlChar *)
-
-#define XMLCHAR_CAST(x) (xmlChar *)(x)
-
-#define CAST_IN_MACRO(x) \
- do { \
- xmlChar *s = (xmlChar *)(x); \
- } while (false);
-// CHECK-FIXES: xmlChar *s = (xmlChar *)(x);
-
-void f_cstyle_cast() {
- auto *a = new A();
- C *c1 = (C *)a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *c1 = (C *)a;
-
- C &c2 = (C &)*a;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto &c2 = (C &)*a;
-
- xmlChar *s = BAD_CAST "xml";
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *s = BAD_CAST "xml";
- xmlChar *t = XMLCHAR_CAST("xml");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto *t = XMLCHAR_CAST("xml");
- CAST_IN_MACRO("xml");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
-}
-
-void f_functional_cast() {
- long l = 1;
- int i1 = int(l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a cast to avoid duplicating the type name
- // CHECK-FIXES: auto i1 = int(l);
-
- B b;
- A a = A(b);
-}
-
-class StringRef
-{
-public:
- StringRef(const char *);
- const char *begin() const;
- const char *end() const;
-};
-
-template <typename T, typename U>
-T template_value_cast(const U &u);
-
-template <typename T, typename U>
-T *template_pointer_cast(U *u);
-
-template <typename T, typename U>
-T &template_reference_cast(U &u);
-
-template <typename T, typename U>
-const T *template_const_pointer_cast(const U *u);
-
-template <typename T, typename U>
-const T &template_const_reference_cast(const U &u);
-
-template <typename T>
-T template_value_get(StringRef s);
-
-struct S {
- template <typename T>
- const T *template_member_get();
-};
-
-template <typename T>
-T max(T t1, T t2);
-
-void f_template_cast()
-{
- double d = 0;
- int i1 = template_value_cast<int>(d);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto i1 = template_value_cast<int>(d);
-
- A *a = new B();
- B *b1 = template_value_cast<B *>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto *b1 = template_value_cast<B *>(a);
- B &b2 = template_value_cast<B &>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b2 = template_value_cast<B &>(*a);
- B *b3 = template_pointer_cast<B>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto *b3 = template_pointer_cast<B>(a);
- B &b4 = template_reference_cast<B>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto &b4 = template_reference_cast<B>(*a);
- const B *b5 = template_const_pointer_cast<B>(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: const auto *b5 = template_const_pointer_cast<B>(a);
- const B &b6 = template_const_reference_cast<B>(*a);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: const auto &b6 = template_const_reference_cast<B>(*a);
- B *b7 = template_value_get<B *>("foo");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto *b7 = template_value_get<B *>("foo");
- B *b8 = template_value_get<B *>("foo"), *b9 = template_value_get<B *>("bar");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: auto *b8 = template_value_get<B *>("foo"), *b9 = template_value_get<B *>("bar");
-
- S s;
- const B *b10 = s.template_member_get<B>();
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use auto when initializing with a template cast to avoid duplicating the type name
- // CHECK-FIXES: const auto *b10 = s.template_member_get<B>();
-
- // Don't warn when auto is already being used.
- auto i2 = template_value_cast<int>(d);
- auto *i3 = template_value_cast<int *>(d);
- auto **i4 = template_value_cast<int **>(d);
- auto &i5 = template_reference_cast<int>(d);
-
- // Don't warn for implicit template arguments.
- int i6 = max(i1, i2);
-
- // Don't warn for mismatched var and initializer types.
- A *a1 = template_value_cast<B *>(a);
-
- // Don't warn for mismatched var types.
- B *b11 = template_value_get<B *>("foo"), b12 = template_value_get<B>("bar");
-
- // Don't warn for implicit variables.
- for (auto &c : template_reference_cast<StringRef>(*a)) {
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-iterator.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-iterator.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-iterator.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-iterator.cpp (removed)
@@ -1,320 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s modernize-use-auto %t -- -- -I %S/Inputs/modernize-use-auto
-// FIXME: Fix the checker to work in C++17 mode.
-
-#include "containers.h"
-
-void f_array() {
- std::array<int, 4> C;
- std::array<int, 4>::iterator ArrayI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators [modernize-use-auto]
- // CHECK-FIXES: auto ArrayI1 = C.begin();
-
- std::array<int, 5>::reverse_iterator ArrayI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto ArrayI2 = C.rbegin();
-
- const std::array<int, 3> D;
- std::array<int, 3>::const_iterator ArrayI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto ArrayI3 = D.begin();
-
- std::array<int, 5>::const_reverse_iterator ArrayI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto ArrayI4 = D.rbegin();
-}
-
-void f_deque() {
- std::deque<int> C;
- std::deque<int>::iterator DequeI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto DequeI1 = C.begin();
-
- std::deque<int>::reverse_iterator DequeI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto DequeI2 = C.rbegin();
-
- const std::deque<int> D;
- std::deque<int>::const_iterator DequeI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto DequeI3 = D.begin();
-
- std::deque<int>::const_reverse_iterator DequeI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto DequeI4 = D.rbegin();
-}
-
-void f_forward_list() {
- std::forward_list<int> C;
- std::forward_list<int>::iterator FListI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto FListI1 = C.begin();
-
- const std::forward_list<int> D;
- std::forward_list<int>::const_iterator FListI2 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto FListI2 = D.begin();
-}
-
-void f_list() {
- std::list<int> C;
- std::list<int>::iterator ListI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto ListI1 = C.begin();
- std::list<int>::reverse_iterator ListI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto ListI2 = C.rbegin();
-
- const std::list<int> D;
- std::list<int>::const_iterator ListI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto ListI3 = D.begin();
- std::list<int>::const_reverse_iterator ListI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto ListI4 = D.rbegin();
-}
-
-void f_vector() {
- std::vector<int> C;
- std::vector<int>::iterator VecI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto VecI1 = C.begin();
-
- std::vector<int>::reverse_iterator VecI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto VecI2 = C.rbegin();
-
- const std::vector<int> D;
- std::vector<int>::const_iterator VecI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto VecI3 = D.begin();
-
- std::vector<int>::const_reverse_iterator VecI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto VecI4 = D.rbegin();
-}
-
-void f_map() {
- std::map<int, int> C;
- std::map<int, int>::iterator MapI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MapI1 = C.begin();
-
- std::map<int, int>::reverse_iterator MapI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MapI2 = C.rbegin();
-
- const std::map<int, int> D;
- std::map<int, int>::const_iterator MapI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MapI3 = D.begin();
-
- std::map<int, int>::const_reverse_iterator MapI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MapI4 = D.rbegin();
-}
-
-void f_multimap() {
- std::multimap<int, int> C;
- std::multimap<int, int>::iterator MMapI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MMapI1 = C.begin();
-
- std::multimap<int, int>::reverse_iterator MMapI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MMapI2 = C.rbegin();
-
- const std::multimap<int, int> D;
- std::multimap<int, int>::const_iterator MMapI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MMapI3 = D.begin();
-
- std::multimap<int, int>::const_reverse_iterator MMapI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MMapI4 = D.rbegin();
-}
-
-void f_set() {
- std::set<int> C;
- std::set<int>::iterator SetI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto SetI1 = C.begin();
-
- std::set<int>::reverse_iterator SetI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto SetI2 = C.rbegin();
-
- const std::set<int> D;
- std::set<int>::const_iterator SetI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto SetI3 = D.begin();
-
- std::set<int>::const_reverse_iterator SetI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto SetI4 = D.rbegin();
-}
-
-void f_multiset() {
- std::multiset<int> C;
- std::multiset<int>::iterator MSetI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MSetI1 = C.begin();
-
- std::multiset<int>::reverse_iterator MSetI2 = C.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MSetI2 = C.rbegin();
-
- const std::multiset<int> D;
- std::multiset<int>::const_iterator MSetI3 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MSetI3 = D.begin();
-
- std::multiset<int>::const_reverse_iterator MSetI4 = D.rbegin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto MSetI4 = D.rbegin();
-}
-
-void f_unordered_map() {
- std::unordered_map<int, int> C;
- std::unordered_map<int, int>::iterator UMapI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto UMapI1 = C.begin();
-
- const std::unordered_map<int, int> D;
- std::unordered_map<int, int>::const_iterator UMapI2 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto UMapI2 = D.begin();
-}
-
-void f_unordered_multimap() {
- std::unordered_multimap<int, int> C;
- std::unordered_multimap<int, int>::iterator UMMapI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto UMMapI1 = C.begin();
-
- const std::unordered_multimap<int, int> D;
- std::unordered_multimap<int, int>::const_iterator UMMapI2 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto UMMapI2 = D.begin();
-}
-
-void f_unordered_set() {
- std::unordered_set<int> C;
- std::unordered_set<int>::iterator USetI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto USetI1 = C.begin();
-
- const std::unordered_set<int> D;
- std::unordered_set<int>::const_iterator USetI2 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto USetI2 = D.begin();
-}
-
-void f_unordered_multiset() {
- std::unordered_multiset<int> C;
- std::unordered_multiset<int>::iterator UMSetI1 = C.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto UMSetI1 = C.begin();
-
- const std::unordered_multiset<int> D;
- std::unordered_multiset<int>::const_iterator UMSetI2 = D.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto UMSetI2 = D.begin();
-}
-
-typedef std::vector<int>::iterator int_iterator;
-
-std::vector<int> Vec;
-std::unordered_map<int, int> Map;
-
-void sugar() {
- // Types with more sugar should work. Types with less should not.
- int_iterator more_sugar = Vec.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto more_sugar = Vec.begin();
-}
-
-void initializer_list() {
- // Initialization from initializer lists isn't allowed. Using 'auto' would
- // result in std::initializer_list being deduced for the type.
- std::unordered_map<int, int>::iterator I{Map.begin()};
- std::unordered_map<int, int>::iterator I2 = {Map.begin()};
-}
-
-void construction() {
- // Various forms of construction. Default constructors and constructors with
- // all-default parameters shouldn't get transformed. Construction from other
- // types is also not allowed.
-
- std::unordered_map<int, int>::iterator copy(Map.begin());
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto copy(Map.begin());
-
- std::unordered_map<int, int>::iterator def;
- std::unordered_map<int, int>::const_iterator constI;
-
- // Implicit conversion.
- std::unordered_map<int, int>::const_iterator constI2 = def;
- std::unordered_map<int, int>::const_iterator constI3(def);
-
- // Explicit conversion
- std::unordered_map<int, int>::const_iterator constI4
- = std::unordered_map<int, int>::const_iterator(def);
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto constI4
- // CHECK-FIXES-NEXT: = std::unordered_map<int, int>::const_iterator(def);
-}
-
-void pointer_to_iterator() {
- int_iterator I = Vec.begin();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto I = Vec.begin();
-
- // Pointers and references to iterators are not transformed.
- int_iterator *IPtr = &I;
- int_iterator &IRef = I;
-}
-
-void loop() {
- for (std::vector<int>::iterator I = Vec.begin(); I != Vec.end(); ++I) {
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use auto when declaring iterators
- // CHECK-FIXES: for (auto I = Vec.begin(); I != Vec.end(); ++I)
- }
-
- for (int_iterator I = Vec.begin(), E = Vec.end(); I != E; ++I) {
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use auto when declaring iterators
- // CHECK-FIXES: for (auto I = Vec.begin(), E = Vec.end(); I != E; ++I)
- }
-
- std::vector<std::vector<int>::iterator> IterVec;
- for (std::vector<int>::iterator I : IterVec) {
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use auto when declaring iterators
- // CHECK-FIXES: for (auto I : IterVec)
- }
-}
-
-void cv_qualifiers() {
- // Make sure references and cv qualifiers don't get removed (i.e. replaced
- // with just 'auto').
- const auto & I = Vec.begin();
- auto && I2 = Vec.begin();
-}
-
-void cleanup() {
- // Passing a string as an argument to introduce a temporary object that will
- // create an expression with cleanups.
- std::map<std::string, int> MapFind;
- std::map<std::string, int>::iterator I = MapFind.find("foo");
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto I = MapFind.find("foo");
-}
-
-void declaration_lists() {
- // Declaration lists that match the declaration type with written no-list
- // initializer are transformed.
- std::vector<int>::iterator I = Vec.begin(), E = Vec.end();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when declaring iterators
- // CHECK-FIXES: auto I = Vec.begin(), E = Vec.end();
-
- // Declaration lists with non-initialized variables should not be transformed.
- std::vector<int>::iterator J = Vec.begin(), K;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-min-type-name-length.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-min-type-name-length.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-min-type-name-length.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-min-type-name-length.cpp (removed)
@@ -1,85 +0,0 @@
-// RUN: %check_clang_tidy -check-suffix=0-0 %s modernize-use-auto %t -- -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: 0}, {key: modernize-use-auto.MinTypeNameLength, value: 0}]}" -- -frtti
-// RUN: %check_clang_tidy -check-suffix=0-8 %s modernize-use-auto %t -- -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: 0}, {key: modernize-use-auto.MinTypeNameLength, value: 8}]}" -- -frtti
-// RUN: %check_clang_tidy -check-suffix=1-0 %s modernize-use-auto %t -- -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: 1}, {key: modernize-use-auto.MinTypeNameLength, value: 0}]}" -- -frtti
-// RUN: %check_clang_tidy -check-suffix=1-8 %s modernize-use-auto %t -- -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: 1}, {key: modernize-use-auto.MinTypeNameLength, value: 8}]}" -- -frtti
-
-template <class T> extern T foo();
-template <class T> struct P { explicit P(T t) : t_(t) {} T t_;};
-template <class T> P<T> *foo_ptr();
-template <class T> P<T> &foo_ref();
-
-int bar() {
- {
- // Lenth(long) = 4
- long i = static_cast<long>(foo<long>());
- // CHECK-FIXES-0-0: auto i = {{.*}}
- // CHECK-FIXES-0-8: long i = {{.*}}
- // CHECK-FIXES-1-0: auto i = {{.*}}
- // CHECK-FIXES-1-8: long i = {{.*}}
- const long ci = static_cast<long>(foo<const long>());
- // CHECK-FIXES-0-0: auto ci = {{.*}}
- // CHECK-FIXES-0-8: long ci = {{.*}}
- // CHECK-FIXES-1-0: auto ci = {{.*}}
- // CHECK-FIXES-1-8: long ci = {{.*}}
- long *pi = static_cast<long *>(foo<long *>());
- // CHECK-FIXES-0-0: auto *pi = {{.*}}
- // CHECK-FIXES-0-8: long *pi = {{.*}}
- // CHECK-FIXES-1-0: auto pi = {{.*}}
- // CHECK-FIXES-1-8: long *pi = {{.*}}
-
- // Length(long *) is still 5
- long * pi2 = static_cast<long *>(foo<long *>());
- // CHECK-FIXES-0-0: auto * pi2 = {{.*}}
- // CHECK-FIXES-0-8: long * pi2 = {{.*}}
- // CHECK-FIXES-1-0: auto pi2 = {{.*}}
- // CHECK-FIXES-1-8: long * pi2 = {{.*}}
-
- // Length(long **) = 6
- long **ppi = static_cast<long **>(foo<long **>());
- // CHECK-FIXES-0-0: auto **ppi = {{.*}}
- // CHECK-FIXES-0-8: long **ppi = {{.*}}
- // CHECK-FIXES-1-0: auto ppi = {{.*}}
- // CHECK-FIXES-1-8: long **ppi = {{.*}}
- }
-
- {
- // Lenth(long int) = 4 + 1 + 3 = 8
- // Lenth(long int) is still 8
- long int i = static_cast<long int>(foo<long int>());
- // CHECK-FIXES-0-0: auto i = {{.*}}
- // CHECK-FIXES-0-8: auto i = {{.*}}
- // CHECK-FIXES-1-0: auto i = {{.*}}
- // CHECK-FIXES-1-8: auto i = {{.*}}
-
- long int *pi = static_cast<long int *>(foo<long int *>());
- // CHECK-FIXES-0-0: auto *pi = {{.*}}
- // CHECK-FIXES-0-8: auto *pi = {{.*}}
- // CHECK-FIXES-1-0: auto pi = {{.*}}
- // CHECK-FIXES-1-8: auto pi = {{.*}}
- }
-
- // Templates
- {
- // Length(P<long>) = 7
- P<long>& i = static_cast<P<long>&>(foo_ref<long>());
- // CHECK-FIXES-0-0: auto& i = {{.*}}
- // CHECK-FIXES-0-8: P<long>& i = {{.*}}
- // CHECK-FIXES-1-0: auto & i = {{.*}}
- // CHECK-FIXES-1-8: P<long>& i = {{.*}}
-
- // Length(P<long*>) = 8
- P<long*>& pi = static_cast<P<long*> &>(foo_ref<long*>());
- // CHECK-FIXES-0-0: auto& pi = {{.*}}
- // CHECK-FIXES-0-8: auto& pi = {{.*}}
- // CHECK-FIXES-1-0: auto & pi = {{.*}}
- // CHECK-FIXES-1-8: auto & pi = {{.*}}
-
- P<long>* pi2 = static_cast<P<long>*>(foo_ptr<long>());
- // CHECK-FIXES-0-0: auto* pi2 = {{.*}}
- // CHECK-FIXES-0-8: P<long>* pi2 = {{.*}}
- // CHECK-FIXES-1-0: auto pi2 = {{.*}}
- // CHECK-FIXES-1-8: auto pi2 = {{.*}}
- }
-
- return 1;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new-remove-stars.cpp (removed)
@@ -1,105 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-auto.RemoveStars, value: '1'}, {key: modernize-use-auto.MinTypeNameLength, value: '0'}]}"
-
-class MyType {};
-
-class MyDerivedType : public MyType {};
-
-// FIXME: the replacement sometimes results in two consecutive spaces after
-// the word 'auto' (due to the presence of spaces at both sides of '*').
-void auto_new() {
- MyType *a_new = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto a_new = new MyType();
-
- static MyType *a_static = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
- // CHECK-FIXES: static auto a_static = new MyType();
-
- MyType *derived = new MyDerivedType();
-
- void *vd = new MyType();
-
- // CV-qualifier tests.
- //
- // NOTE : the form "type const" is expected here because of a deficiency in
- // TypeLoc where CV qualifiers are not considered part of the type location
- // info. That is, all that is being replaced in each case is "MyType *" and
- // not "MyType * const".
- static MyType * const d_static = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
- // CHECK-FIXES: static auto const d_static = new MyType();
-
- MyType * const a_const = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto const a_const = new MyType();
-
- MyType * volatile vol = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto volatile vol = new MyType();
-
- struct SType {} *stype = new SType;
-
- int (**func)(int, int) = new (int(*[5])(int,int));
-
- int *array = new int[5];
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto array = new int[5];
-
- MyType *ptr(new MyType);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto ptr(new MyType);
-
- MyType *ptr2{new MyType};
-
- {
- // Test for declaration lists.
- MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto a = new MyType(), b = new MyType(), c = new MyType();
-
- // Non-initialized declaration should not be transformed.
- MyType *d = new MyType(), *e;
-
- MyType **f = new MyType*(), **g = new MyType*();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto f = new MyType*(), g = new MyType*();
-
- // Mismatching types in declaration lists should not be transformed.
- MyType *h = new MyType(), **i = new MyType*();
-
- // '*' shouldn't be removed in case of mismatching types with multiple
- // declarations.
- MyType *j = new MyType(), *k = new MyType(), **l = new MyType*();
- }
-
- {
- // Test for typedefs.
- typedef int * int_p;
- // CHECK-FIXES: typedef int * int_p;
-
- int_p a = new int;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto a = new int;
- int_p *b = new int*;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto b = new int*;
-
- // Test for typedefs in declarations lists.
- int_p c = new int, d = new int;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto c = new int, d = new int;
-
- // Different types should not be transformed.
- int_p e = new int, *f = new int_p;
-
- int_p *g = new int*, *h = new int_p;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto g = new int*, h = new int_p;
- }
-
- // Don't warn when 'auto' is already being used.
- auto aut = new MyType();
- auto *paut = new MyType();
- const auto *pcaut = new MyType();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-auto-new.cpp (removed)
@@ -1,110 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-auto %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-auto.MinTypeNameLength, value: '0'}]}" \
-// RUN: -- -frtti
-
-class MyType {};
-
-class MyDerivedType : public MyType {};
-
-// FIXME: the replacement sometimes results in two consecutive spaces after
-// the word 'auto' (due to the presence of spaces at both sides of '*').
-void auto_new() {
- MyType *a_new = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto *a_new = new MyType();
-
- static MyType *a_static = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
- // CHECK-FIXES: static auto *a_static = new MyType();
-
- long long *ll = new long long();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto *ll = new long long();
-
- MyType *derived = new MyDerivedType();
-
- void *vd = new MyType();
-
- // CV-qualifier tests.
- //
- // NOTE : the form "type const" is expected here because of a deficiency in
- // TypeLoc where CV qualifiers are not considered part of the type location
- // info. That is, all that is being replaced in each case is "MyType *" and
- // not "MyType * const".
- static MyType * const d_static = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use auto when initializing with new
- // CHECK-FIXES: static auto * const d_static = new MyType();
-
- MyType * const a_const = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto * const a_const = new MyType();
-
- MyType * volatile vol = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto * volatile vol = new MyType();
-
- struct SType {} *stype = new SType;
-
- int (**func)(int, int) = new (int(*[5])(int,int));
-
- int *array = new int[5];
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto *array = new int[5];
-
- MyType *ptr(new MyType);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use auto when initializing with new
- // CHECK-FIXES: auto *ptr(new MyType);
-
- MyType *ptr2{new MyType};
-
- {
- // Test for declaration lists.
- MyType *a = new MyType(), *b = new MyType(), *c = new MyType();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto *a = new MyType(), *b = new MyType(), *c = new MyType();
-
- // Non-initialized declaration should not be transformed.
- MyType *d = new MyType(), *e;
-
- MyType **f = new MyType*(), **g = new MyType*();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto **f = new MyType*(), **g = new MyType*();
-
- // Mismatching types in declaration lists should not be transformed.
- MyType *h = new MyType(), **i = new MyType*();
-
- // '*' shouldn't be removed in case of mismatching types with multiple
- // declarations.
- MyType *j = new MyType(), *k = new MyType(), **l = new MyType*();
- }
-
- {
- // Test for typedefs.
- typedef int * int_p;
- // CHECK-FIXES: typedef int * int_p;
-
- int_p a = new int;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto a = new int;
- int_p *b = new int*;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto *b = new int*;
-
- // Test for typedefs in declarations lists.
- int_p c = new int, d = new int;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto c = new int, d = new int;
-
- // Different types should not be transformed.
- int_p e = new int, *f = new int_p;
-
- int_p *g = new int*, *h = new int_p;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use auto when initializing with new
- // CHECK-FIXES: auto *g = new int*, *h = new int_p;
- }
-
- // Don't warn when 'auto' is already being used.
- auto aut = new MyType();
- auto *paut = new MyType();
- const auto *pcaut = new MyType();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals-ignore-macros.cpp (removed)
@@ -1,147 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-bool-literals %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: modernize-use-bool-literals.IgnoreMacros, \
-// RUN: value: 1}]}"
-
-bool IntToTrue = 1;
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
-// CHECK-FIXES: {{^}}bool IntToTrue = true;{{$}}
-
-bool IntToFalse(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool IntToFalse(false);{{$}}
-
-bool LongLongToTrue{0x1LL};
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool LongLongToTrue{true};{{$}}
-
-bool ExplicitCStyleIntToFalse = (bool)0;
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool ExplicitCStyleIntToFalse = false;{{$}}
-
-bool ExplicitFunctionalIntToFalse = bool(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool ExplicitFunctionalIntToFalse = false;{{$}}
-
-bool ExplicitStaticIntToFalse = static_cast<bool>(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool ExplicitStaticIntToFalse = false;{{$}}
-
-#define TRUE_MACRO 1
-// CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
-
-bool MacroIntToTrue = TRUE_MACRO;
-// CHECK-FIXES: {{^}}bool MacroIntToTrue = TRUE_MACRO;{{$}}
-
-#define FALSE_MACRO bool(0)
-// CHECK-FIXES: {{^}}#define FALSE_MACRO bool(0){{$}}
-
-bool TrueBool = true; // OK
-
-bool FalseBool = bool(FALSE_MACRO);
-// CHECK-FIXES: {{^}}bool FalseBool = bool(FALSE_MACRO);{{$}}
-
-void boolFunction(bool bar) {
-
-}
-
-char Character = 0; // OK
-
-unsigned long long LongInteger = 1; // OK
-
-#define MACRO_DEPENDENT_CAST(x) static_cast<bool>(x)
-// CHECK-FIXES: {{^}}#define MACRO_DEPENDENT_CAST(x) static_cast<bool>(x){{$}}
-
-bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);
-// CHECK-FIXES: {{^}}bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);{{$}}
-
-bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);
-// CHECK-FIXES: {{^}}bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);{{$}}
-
-class FooClass {
- public:
- FooClass() : JustBool(0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}FooClass() : JustBool(false) {}{{$}}
- FooClass(int) : JustBool{0} {}
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}FooClass(int) : JustBool{false} {}{{$}}
- private:
- bool JustBool;
- bool BoolWithBraces{0};
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool BoolWithBraces{false};{{$}}
- bool BoolFromInt = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool BoolFromInt = false;{{$}}
- bool SimpleBool = true; // OK
-};
-
-template<typename type>
-void templateFunction(type) {
- type TemplateType = 0;
- // CHECK-FIXES: {{^ *}}type TemplateType = 0;{{$}}
-}
-
-template<int c>
-void valueDependentTemplateFunction() {
- bool Boolean = c;
- // CHECK-FIXES: {{^ *}}bool Boolean = c;{{$}}
-}
-
-template<typename type>
-void anotherTemplateFunction(type) {
- bool JustBool = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool JustBool = false;{{$}}
-}
-
-int main() {
- boolFunction(1);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}boolFunction(true);{{$}}
-
- boolFunction(false);
-
- templateFunction(0);
-
- templateFunction(false);
-
- valueDependentTemplateFunction<1>();
-
- anotherTemplateFunction(1);
-
- IntToTrue = 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}}
-}
-
-static int Value = 1;
-
-bool Function1() {
- bool Result = Value == 1 ? 1 : 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: converting integer literal to bool
- // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool Result = Value == 1 ? true : false;{{$}}
- return Result;
-}
-
-bool Function2() {
- return Value == 1 ? 1 : 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
- // CHECK-MESSAGES: :[[@LINE-2]]:27: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}return Value == 1 ? true : false;{{$}}
-}
-
-void foo() {
- bool Result;
- Result = Value == 1 ? true : 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}Result = Value == 1 ? true : false;{{$}}
- Result = Value == 1 ? false : bool(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
- Result = Value == 1 ? (bool)0 : false;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-bool-literals.cpp (removed)
@@ -1,151 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-bool-literals %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: modernize-use-bool-literals.IgnoreMacros, \
-// RUN: value: 0}]}"
-
-bool IntToTrue = 1;
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
-// CHECK-FIXES: {{^}}bool IntToTrue = true;{{$}}
-
-bool IntToFalse(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool IntToFalse(false);{{$}}
-
-bool LongLongToTrue{0x1LL};
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool LongLongToTrue{true};{{$}}
-
-bool ExplicitCStyleIntToFalse = (bool)0;
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool ExplicitCStyleIntToFalse = false;{{$}}
-
-bool ExplicitFunctionalIntToFalse = bool(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool ExplicitFunctionalIntToFalse = false;{{$}}
-
-bool ExplicitStaticIntToFalse = static_cast<bool>(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool ExplicitStaticIntToFalse = false;{{$}}
-
-#define TRUE_MACRO 1
-// CHECK-FIXES: {{^}}#define TRUE_MACRO 1{{$}}
-
-bool MacroIntToTrue = TRUE_MACRO;
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool MacroIntToTrue = TRUE_MACRO;{{$}}
-
-#define FALSE_MACRO bool(0)
-// CHECK-FIXES: {{^}}#define FALSE_MACRO bool(0){{$}}
-
-bool TrueBool = true; // OK
-
-bool FalseBool = bool(FALSE_MACRO);
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool FalseBool = bool(FALSE_MACRO);{{$}}
-
-void boolFunction(bool bar) {
-
-}
-
-char Character = 0; // OK
-
-unsigned long long LongInteger = 1; // OK
-
-#define MACRO_DEPENDENT_CAST(x) static_cast<bool>(x)
-// CHECK-FIXES: {{^}}#define MACRO_DEPENDENT_CAST(x) static_cast<bool>(x){{$}}
-
-bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool MacroDependentBool = MACRO_DEPENDENT_CAST(0);{{$}}
-
-bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);
-// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: converting integer literal to bool
-// CHECK-FIXES: {{^}}bool ManyMacrosDependent = MACRO_DEPENDENT_CAST(FALSE_MACRO);{{$}}
-
-class FooClass {
- public:
- FooClass() : JustBool(0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}FooClass() : JustBool(false) {}{{$}}
- FooClass(int) : JustBool{0} {}
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}FooClass(int) : JustBool{false} {}{{$}}
- private:
- bool JustBool;
- bool BoolWithBraces{0};
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool BoolWithBraces{false};{{$}}
- bool BoolFromInt = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool BoolFromInt = false;{{$}}
- bool SimpleBool = true; // OK
-};
-
-template<typename type>
-void templateFunction(type) {
- type TemplateType = 0;
- // CHECK-FIXES: {{^ *}}type TemplateType = 0;{{$}}
-}
-
-template<int c>
-void valueDependentTemplateFunction() {
- bool Boolean = c;
- // CHECK-FIXES: {{^ *}}bool Boolean = c;{{$}}
-}
-
-template<typename type>
-void anotherTemplateFunction(type) {
- bool JustBool = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool JustBool = false;{{$}}
-}
-
-int main() {
- boolFunction(1);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}boolFunction(true);{{$}}
-
- boolFunction(false);
-
- templateFunction(0);
-
- templateFunction(false);
-
- valueDependentTemplateFunction<1>();
-
- anotherTemplateFunction(1);
-
- IntToTrue = 1;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}IntToTrue = true;{{$}}
-}
-
-static int Value = 1;
-
-bool Function1() {
- bool Result = Value == 1 ? 1 : 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: converting integer literal to bool
- // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}bool Result = Value == 1 ? true : false;{{$}}
- return Result;
-}
-
-bool Function2() {
- return Value == 1 ? 1 : 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: converting integer literal to bool
- // CHECK-MESSAGES: :[[@LINE-2]]:27: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}return Value == 1 ? true : false;{{$}}
-}
-
-void foo() {
- bool Result;
- Result = Value == 1 ? true : 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}Result = Value == 1 ? true : false;{{$}}
- Result = Value == 1 ? false : bool(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
- Result = Value == 1 ? (bool)0 : false;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: converting integer literal to bool
- // CHECK-FIXES: {{^ *}}Result = Value == 1 ? false : false;{{$}}
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-assignment.cpp (removed)
@@ -1,192 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: 1}]}"
-
-struct S {
-};
-
-struct PositiveValueChar {
- PositiveValueChar() : c0(), c1()/*, c2(), c3()*/ {}
- // CHECK-FIXES: PositiveValueChar() {}
- const char c0;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer for 'c0' [modernize-use-default-member-init]
- // CHECK-FIXES: const char c0 = '\0';
- wchar_t c1;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer for 'c1'
- // CHECK-FIXES: wchar_t c1 = L'\0';
- // FIXME: char16_t c2;
- // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c2'
- // C HECK-FIXES: char16_t c2 = u'\0';
- // FIXME: char32_t c3;
- // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c3'
- // C HECK-FIXES: char32_t c3 = U'\0';
-};
-
-struct PositiveChar {
- PositiveChar() : d('a') {}
- // CHECK-FIXES: PositiveChar() {}
- char d;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'd'
- // CHECK-FIXES: char d = 'a';
-};
-
-struct PositiveValueInt {
- PositiveValueInt() : i() {}
- // CHECK-FIXES: PositiveValueInt() {}
- const int i;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i'
- // CHECK-FIXES: const int i = 0;
-};
-
-struct PositiveInt {
- PositiveInt() : j(1) {}
- // CHECK-FIXES: PositiveInt() {}
- int j;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
- // CHECK-FIXES: int j = 1;
-};
-
-struct PositiveUnaryMinusInt {
- PositiveUnaryMinusInt() : j(-1) {}
- // CHECK-FIXES: PositiveUnaryMinusInt() {}
- int j;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
- // CHECK-FIXES: int j = -1;
-};
-
-struct PositiveUnaryPlusInt {
- PositiveUnaryPlusInt() : j(+1) {}
- // CHECK-FIXES: PositiveUnaryPlusInt() {}
- int j;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
- // CHECK-FIXES: int j = +1;
-};
-
-struct PositiveValueComplexInt {
- PositiveValueComplexInt() : i() {}
- // CHECK-FIXES: PositiveValueComplexInt() {}
- _Complex int i;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use default member initializer for 'i'
- // CHECK-FIXES: _Complex int i = 0;
-};
-
-struct PositiveValueFloat {
- PositiveValueFloat() : f() {}
- // CHECK-FIXES: PositiveValueFloat() {}
- float f;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 'f'
- // CHECK-FIXES: float f = 0.0f;
-};
-
-struct PositiveValueDouble {
- PositiveValueDouble() : d() {}
- // CHECK-FIXES: PositiveValueDouble() {}
- double d;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd'
- // CHECK-FIXES: double d = 0.0;
-};
-
-struct PositiveDouble {
- PositiveDouble() : f(2.5463e43) {}
- // CHECK-FIXES: PositiveDouble() {}
- double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
- // CHECK-FIXES: double f = 2.5463e43;
-};
-
-struct PositiveValueComplexFloat {
- PositiveValueComplexFloat() : f() {}
- // CHECK-FIXES: PositiveValueComplexFloat() {}
- _Complex float f;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use default member initializer for 'f'
- // CHECK-FIXES: _Complex float f = 0.0f;
-};
-
-struct PositiveValueComplexDouble {
- PositiveValueComplexDouble() : f() {}
- // CHECK-FIXES: PositiveValueComplexDouble() {}
- _Complex double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use default member initializer for 'f'
- // CHECK-FIXES: _Complex double f = 0.0;
-};
-
-struct PositiveUnaryMinusDouble {
- PositiveUnaryMinusDouble() : f(-2.5463e43) {}
- // CHECK-FIXES: PositiveUnaryMinusDouble() {}
- double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
- // CHECK-FIXES: double f = -2.5463e43;
-};
-
-struct PositiveUnaryPlusDouble {
- PositiveUnaryPlusDouble() : f(+2.5463e43) {}
- // CHECK-FIXES: PositiveUnaryPlusDouble() {}
- double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
- // CHECK-FIXES: double f = +2.5463e43;
-};
-
-struct PositiveValueBool {
- PositiveValueBool() : b() {}
- // CHECK-FIXES: PositiveValueBool() {}
- bool b;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b'
- // CHECK-FIXES: bool b = false;
-};
-
-struct PositiveBool {
- PositiveBool() : a(true) {}
- // CHECK-FIXES: PositiveBool() {}
- bool a;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a'
- // CHECK-FIXES: bool a = true;
-};
-
-struct PositiveValuePointer {
- PositiveValuePointer() : p() {}
- // CHECK-FIXES: PositiveValuePointer() {}
- int *p;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p'
- // CHECK-FIXES: int *p = nullptr;
-};
-
-struct PositiveNullPointer {
- PositiveNullPointer() : q(nullptr) {}
- // CHECK-FIXES: PositiveNullPointer() {}
- int *q;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q'
- // CHECK-FIXES: int *q = nullptr;
-};
-
-enum Enum { Foo };
-struct PositiveEnum {
- PositiveEnum() : e(Foo) {}
- // CHECK-FIXES: PositiveEnum() {}
- Enum e;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e'
- // CHECK-FIXES: Enum e = Foo;
-};
-
-struct PositiveValueEnum {
- PositiveValueEnum() : e() {}
- // CHECK-FIXES: PositiveValueEnum() {}
- Enum e;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e'
- // CHECK-FIXES: Enum e{};
-};
-
-struct PositiveString {
- PositiveString() : s("foo") {}
- // CHECK-FIXES: PositiveString() {}
- const char *s;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use default member initializer for 's'
- // CHECK-FIXES: const char *s = "foo";
-};
-
-template <typename T>
-struct NegativeTemplate {
- NegativeTemplate() : t() {}
- T t;
-};
-
-NegativeTemplate<int> nti;
-NegativeTemplate<double> ntd;
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-bitfield.cpp (removed)
@@ -1,10 +0,0 @@
-// RUN: %check_clang_tidy -std=c++2a-or-later %s modernize-use-default-member-init %t
-
-struct PositiveBitField
-{
- PositiveBitField() : i(6) {}
- // CHECK-FIXES: PositiveBitField() {}
- int i : 5;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'i' [modernize-use-default-member-init]
- // CHECK-FIXES: int i : 5{6};
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init-macros.cpp (removed)
@@ -1,17 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-default-member-init %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-default-member-init.IgnoreMacros, value: 0}]}"
-
-#define MACRO() \
- struct S { \
- void *P; \
- S() : P(nullptr) {} \
- };
-
-MACRO();
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use default member initializer for 'P'
-
-struct S2 {
- void *P;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 'P'
- S2() : P(nullptr) {}
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-default-member-init.cpp (removed)
@@ -1,420 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s modernize-use-default-member-init %t
-// FIXME: Fix the checker to work in C++2a mode.
-
-struct S {
-};
-
-struct PositiveValueChar {
- PositiveValueChar() : c0(), c1()/*, c2(), c3()*/ {}
- // CHECK-FIXES: PositiveValueChar() {}
- const char c0;
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use default member initializer for 'c0' [modernize-use-default-member-init]
- // CHECK-FIXES: const char c0{};
- wchar_t c1;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use default member initializer for 'c1'
- // CHECK-FIXES: wchar_t c1{};
- // FIXME: char16_t c2;
- // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c2'
- // C HECK-FIXES: char16_t c2{};
- // FIXME: char32_t c3;
- // C HECK-MESSAGES: :[[@LINE-1]]:12: warning: use default member initializer for 'c3'
- // C HECK-FIXES: char32_t c3{};
-};
-
-struct PositiveChar {
- PositiveChar() : d('a') {}
- // CHECK-FIXES: PositiveChar() {}
- char d;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'd'
- // CHECK-FIXES: char d{'a'};
-};
-
-struct PositiveValueInt {
- PositiveValueInt() : i() {}
- // CHECK-FIXES: PositiveValueInt() {}
- const int i;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use default member initializer for 'i'
- // CHECK-FIXES: const int i{};
-};
-
-struct PositiveInt {
- PositiveInt() : j(1) {}
- // CHECK-FIXES: PositiveInt() {}
- int j;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
- // CHECK-FIXES: int j{1};
-};
-
-struct PositiveUnaryMinusInt {
- PositiveUnaryMinusInt() : j(-1) {}
- // CHECK-FIXES: PositiveUnaryMinusInt() {}
- int j;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
- // CHECK-FIXES: int j{-1};
-};
-
-struct PositiveUnaryPlusInt {
- PositiveUnaryPlusInt() : j(+1) {}
- // CHECK-FIXES: PositiveUnaryPlusInt() {}
- int j;
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use default member initializer for 'j'
- // CHECK-FIXES: int j{+1};
-};
-
-struct PositiveValueComplexInt {
- PositiveValueComplexInt() : i() {}
- // CHECK-FIXES: PositiveValueComplexInt() {}
- _Complex int i;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use default member initializer for 'i'
- // CHECK-FIXES: _Complex int i{};
-};
-
-struct PositiveValueFloat {
- PositiveValueFloat() : f() {}
- // CHECK-FIXES: PositiveValueFloat() {}
- float f;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 'f'
- // CHECK-FIXES: float f{};
-};
-
-struct PositiveValueDouble {
- PositiveValueDouble() : d() {}
- // CHECK-FIXES: PositiveValueDouble() {}
- double d;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'd'
- // CHECK-FIXES: double d{};
-};
-
-struct PositiveDouble {
- PositiveDouble() : f(2.5463e43) {}
- // CHECK-FIXES: PositiveDouble() {}
- double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
- // CHECK-FIXES: double f{2.5463e43};
-};
-
-struct PositiveValueComplexFloat {
- PositiveValueComplexFloat() : f() {}
- // CHECK-FIXES: PositiveValueComplexFloat() {}
- _Complex float f;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use default member initializer for 'f'
- // CHECK-FIXES: _Complex float f{};
-};
-
-struct PositiveValueComplexDouble {
- PositiveValueComplexDouble() : f() {}
- // CHECK-FIXES: PositiveValueComplexDouble() {}
- _Complex double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use default member initializer for 'f'
- // CHECK-FIXES: _Complex double f{};
-};
-
-struct PositiveUnaryMinusDouble {
- PositiveUnaryMinusDouble() : f(-2.5463e43) {}
- // CHECK-FIXES: PositiveUnaryMinusDouble() {}
- double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
- // CHECK-FIXES: double f{-2.5463e43};
-};
-
-struct PositiveUnaryPlusDouble {
- PositiveUnaryPlusDouble() : f(+2.5463e43) {}
- // CHECK-FIXES: PositiveUnaryPlusDouble() {}
- double f;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use default member initializer for 'f'
- // CHECK-FIXES: double f{+2.5463e43};
-};
-
-struct PositiveValueBool {
- PositiveValueBool() : b() {}
- // CHECK-FIXES: PositiveValueBool() {}
- bool b;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'b'
- // CHECK-FIXES: bool b{};
-};
-
-struct PositiveBool {
- PositiveBool() : a(true) {}
- // CHECK-FIXES: PositiveBool() {}
- bool a;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'a'
- // CHECK-FIXES: bool a{true};
-};
-
-struct PositiveValuePointer {
- PositiveValuePointer() : p() {}
- // CHECK-FIXES: PositiveValuePointer() {}
- int *p;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'p'
- // CHECK-FIXES: int *p{};
-};
-
-struct PositiveNullPointer {
- PositiveNullPointer() : q(nullptr) {}
- // CHECK-FIXES: PositiveNullPointer() {}
- int *q;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'q'
- // CHECK-FIXES: int *q{nullptr};
-};
-
-enum Enum { Foo, Bar };
-struct PositiveEnum {
- PositiveEnum() : e(Foo) {}
- // CHECK-FIXES: PositiveEnum() {}
- Enum e;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e'
- // CHECK-FIXES: Enum e{Foo};
-};
-
-struct PositiveValueEnum {
- PositiveValueEnum() : e() {}
- // CHECK-FIXES: PositiveValueEnum() {}
- Enum e;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use default member initializer for 'e'
- // CHECK-FIXES: Enum e{};
-};
-
-struct PositiveString {
- PositiveString() : s("foo") {}
- // CHECK-FIXES: PositiveString() {}
- const char *s;
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use default member initializer for 's'
- // CHECK-FIXES: const char *s{"foo"};
-};
-
-struct PositiveStruct {
- PositiveStruct() : s(7) {}
- // CHECK-FIXES: PositiveStruct() {}
- struct {
- int s;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use default member initializer for 's'
- // CHECK-FIXES: int s{7};
- };
-};
-
-template <typename T>
-struct NegativeTemplate {
- NegativeTemplate() : t() {}
- T t;
-};
-
-NegativeTemplate<int> nti;
-NegativeTemplate<double> ntd;
-
-struct NegativeDefaultMember {
- NegativeDefaultMember() {}
- int i = 2;
-};
-
-struct NegativeClass : S {
- NegativeClass() : s() {}
- S s;
-};
-
-struct NegativeBase : S {
- NegativeBase() : S() {}
-};
-
-struct NegativeDefaultOtherMember{
- NegativeDefaultOtherMember() : i(3) {}
- int i = 4;
-};
-
-struct NegativeUnion {
- NegativeUnion() : d(5.0) {}
- union {
- int i;
- double d;
- };
-};
-
-struct NegativeBitField
-{
- NegativeBitField() : i(6) {}
- int i : 5;
-};
-
-struct NegativeNotDefaultInt
-{
- NegativeNotDefaultInt(int) : i(7) {}
- int i;
-};
-
-struct NegativeDefaultArg
-{
- NegativeDefaultArg(int i = 4) : i(i) {}
- int i;
-};
-
-struct ExistingChar {
- ExistingChar(short) : e1(), e2(), e3(), e4() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
- // CHECK-MESSAGES: :[[@LINE-2]]:31: warning: member initializer for 'e2' is redundant
- // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingChar(short) : e4() {}
- ExistingChar(int) : e1(0), e2(0), e3(0), e4(0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant
- // CHECK-MESSAGES: :[[@LINE-3]]:37: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingChar(int) : e4(0) {}
- ExistingChar(long) : e1('\0'), e2('\0'), e3('\0'), e4('\0') {}
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is redundant
- // CHECK-MESSAGES: :[[@LINE-3]]:44: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingChar(long) : e4('\0') {}
- ExistingChar(char) : e1('a'), e2('a'), e3('a'), e4('a') {}
- // CHECK-MESSAGES: :[[@LINE-1]]:51: warning: member initializer for 'e4' is redundant
- // CHECK-FIXES: ExistingChar(char) : e1('a'), e2('a'), e3('a') {}
- char e1{};
- char e2 = 0;
- char e3 = '\0';
- char e4 = 'a';
-};
-
-struct ExistingInt {
- ExistingInt(short) : e1(), e2(), e3(), e4(), e5(), e6() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
- // CHECK-MESSAGES: :[[@LINE-2]]:30: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingInt(short) : e3(), e4(), e5(), e6() {}
- ExistingInt(int) : e1(0), e2(0), e3(0), e4(0), e5(0), e6(0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:29: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingInt(int) : e3(0), e4(0), e5(0), e6(0) {}
- ExistingInt(long) : e1(5), e2(5), e3(5), e4(5), e5(5), e6(5) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:37: warning: member initializer for 'e3' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: member initializer for 'e4' is redundant
- // CHECK-MESSAGES: :[[@LINE-3]]:58: warning: member initializer for 'e6' is redundant
- // CHECK-FIXES: ExistingInt(long) : e1(5), e2(5), e5(5) {}
- ExistingInt(char) : e1(-5), e2(-5), e3(-5), e4(-5), e5(-5), e6(-5) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:55: warning: member initializer for 'e5' is redundant
- // CHECK-FIXES: ExistingInt(char) : e1(-5), e2(-5), e3(-5), e4(-5), e6(-5) {}
- int e1{};
- int e2 = 0;
- int e3 = {5};
- int e4 = 5;
- int e5 = -5;
- int e6 = +5;
-};
-
-struct ExistingDouble {
- ExistingDouble(short) : e1(), e2(), e3(), e4(), e5() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingDouble(short) : e3(), e4(), e5() {}
- ExistingDouble(int) : e1(0.0), e2(0.0), e3(0.0), e4(0.0), e5(0.0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingDouble(int) : e3(0.0), e4(0.0), e5(0.0) {}
- ExistingDouble(long) : e1(5.0), e2(5.0), e3(5.0), e4(5.0), e5(5.0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: member initializer for 'e3' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:62: warning: member initializer for 'e5' is redundant
- // CHECK-FIXES: ExistingDouble(long) : e1(5.0), e2(5.0), e4(5.0) {}
- ExistingDouble(char) : e1(-5.0), e2(-5.0), e3(-5.0), e4(-5.0), e5(-5.0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:56: warning: member initializer for 'e4' is redundant
- // CHECK-FIXES: ExistingDouble(char) : e1(-5.0), e2(-5.0), e3(-5.0), e5(-5.0) {}
- double e1{};
- double e2 = 0.0;
- double e3 = 5.0;
- double e4 = -5.0;
- double e5 = +5.0;
-};
-
-struct ExistingBool {
- ExistingBool(short) : e1(), e2(), e3() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:31: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingBool(short) : e3() {}
- ExistingBool(int) : e1(false), e2(false), e3(false) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingBool(int) : e3(false) {}
- ExistingBool(long) : e1(true), e2(true), e3(true) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingBool(long) : e1(true), e2(true) {}
- bool e1{};
- bool e2 = false;
- bool e3 = true;
-};
-
-struct ExistingEnum {
- ExistingEnum(short) : e1(Foo), e2(Foo) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant
- // CHECK-FIXES: ExistingEnum(short) : e2(Foo) {}
- ExistingEnum(int) : e1(Bar), e2(Bar) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingEnum(int) : e1(Bar) {}
- Enum e1 = Foo;
- Enum e2{Bar};
-};
-
-struct ExistingPointer {
- ExistingPointer(short) : e1(), e2(), e3(), e4() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: member initializer for 'e2' is redundant
- // CHECK-MESSAGES: :[[@LINE-3]]:40: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingPointer(short) : e4() {}
- ExistingPointer(int) : e1(0), e2(0), e3(0), e4(&e1) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: member initializer for 'e2' is redundant
- // CHECK-MESSAGES: :[[@LINE-3]]:40: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingPointer(int) : e4(&e1) {}
- ExistingPointer(long) : e1(nullptr), e2(nullptr), e3(nullptr), e4(&e2) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:40: warning: member initializer for 'e2' is redundant
- // CHECK-MESSAGES: :[[@LINE-3]]:53: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingPointer(long) : e4(&e2) {}
- int *e1{};
- int *e2 = 0;
- int *e3 = nullptr;
- int **e4 = &e1;
-};
-
-struct ExistingString {
- ExistingString(short) : e1(), e2(), e3(), e4() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: member initializer for 'e1' is redundant [modernize-use-default-member-init]
- // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingString(short) : e3(), e4() {}
- ExistingString(int) : e1(0), e2(0), e3(0), e4(0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:32: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingString(int) : e3(0), e4(0) {}
- ExistingString(long) : e1(nullptr), e2(nullptr), e3(nullptr), e4(nullptr) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: member initializer for 'e1' is redundant
- // CHECK-MESSAGES: :[[@LINE-2]]:39: warning: member initializer for 'e2' is redundant
- // CHECK-FIXES: ExistingString(long) : e3(nullptr), e4(nullptr) {}
- ExistingString(char) : e1("foo"), e2("foo"), e3("foo"), e4("foo") {}
- // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: member initializer for 'e3' is redundant
- // CHECK-FIXES: ExistingString(char) : e1("foo"), e2("foo"), e4("foo") {}
- const char *e1{};
- const char *e2 = nullptr;
- const char *e3 = "foo";
- const char *e4 = "bar";
-};
-
-struct UnionExisting {
- UnionExisting() : e(5.0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: member initializer for 'e' is redundant
- // CHECK-FIXES: UnionExisting() {}
- union {
- int i;
- double e = 5.0;
- };
-};
-
-template <typename T>
-struct NegativeTemplateExisting {
- NegativeTemplateExisting(int) : t(0) {}
- T t{};
-};
-
-NegativeTemplateExisting<int> ntei(0);
-NegativeTemplateExisting<double> nted(0);
-
-// This resulted in a warning by default.
-#define MACRO() \
- struct MacroS { \
- void *P; \
- MacroS() : P(nullptr) {} \
- };
-
-MACRO();
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace-ignore-implicit-constructors.cpp (removed)
@@ -1,123 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-emplace %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: modernize-use-emplace.IgnoreImplicitConstructors, \
-// RUN: value: 1}] \
-// RUN: }"
-
-namespace std {
-template <typename>
-class initializer_list
-{
-public:
- initializer_list() noexcept {}
-};
-
-template <typename T>
-class vector {
-public:
- vector() = default;
- vector(initializer_list<T>) {}
-
- void push_back(const T &) {}
- void push_back(T &&) {}
-
- template <typename... Args>
- void emplace_back(Args &&... args){};
- ~vector();
-};
-
-} // namespace std
-
-void testInts() {
- std::vector<int> v;
- v.push_back(42);
- v.push_back(int(42));
- v.push_back(int{42});
- v.push_back(42.0);
- int z;
- v.push_back(z);
-}
-
-struct Something {
- Something(int a, int b = 41) {}
- Something() {}
- void push_back(Something);
- int getInt() { return 42; }
-};
-
-struct Convertable {
- operator Something() { return Something{}; }
-};
-
-struct Zoz {
- Zoz(Something, int = 42) {}
-};
-
-Zoz getZoz(Something s) { return Zoz(s); }
-
-void test_Something() {
- std::vector<Something> v;
-
- v.push_back(Something(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
- // CHECK-FIXES: v.emplace_back(1, 2);
-
- v.push_back(Something{1, 2});
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, 2);
-
- v.push_back(Something());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back();
-
- v.push_back(Something{});
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back();
-
- Something Different;
- v.push_back(Something(Different.getInt(), 42));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(Different.getInt(), 42);
-
- v.push_back(Different.getInt());
- v.push_back(42);
-
- Something temporary(42, 42);
- temporary.push_back(temporary);
- v.push_back(temporary);
-
- v.push_back(Convertable());
- v.push_back(Convertable{});
- Convertable s;
- v.push_back(s);
-}
-
-template <typename ElemType>
-void dependOnElem() {
- std::vector<ElemType> v;
- v.push_back(ElemType(42));
-}
-
-template <typename ContainerType>
-void dependOnContainer() {
- ContainerType v;
- v.push_back(Something(42));
-}
-
-void callDependent() {
- dependOnElem<Something>();
- dependOnContainer<std::vector<Something>>();
-}
-
-void test2() {
- std::vector<Zoz> v;
- v.push_back(Zoz(Something(21, 37)));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(Something(21, 37));
-
- v.push_back(Zoz(Something(21, 37), 42));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(Something(21, 37), 42);
-
- v.push_back(getZoz(Something(1, 2)));
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-emplace.cpp (removed)
@@ -1,607 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-emplace %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: modernize-use-emplace.ContainersWithPushBack, \
-// RUN: value: '::std::vector; ::std::list; ::std::deque; llvm::LikeASmallVector'}, \
-// RUN: {key: modernize-use-emplace.TupleTypes, \
-// RUN: value: '::std::pair; std::tuple; ::test::Single'}, \
-// RUN: {key: modernize-use-emplace.TupleMakeFunctions, \
-// RUN: value: '::std::make_pair; ::std::make_tuple; ::test::MakeSingle'}] \
-// RUN: }"
-
-namespace std {
-template <typename>
-class initializer_list
-{
-public:
- initializer_list() noexcept {}
-};
-
-template <typename T>
-class vector {
-public:
- vector() = default;
- vector(initializer_list<T>) {}
-
- void push_back(const T &) {}
- void push_back(T &&) {}
-
- template <typename... Args>
- void emplace_back(Args &&... args){};
- ~vector();
-};
-template <typename T>
-class list {
-public:
- void push_back(const T &) {}
- void push_back(T &&) {}
-
- template <typename... Args>
- void emplace_back(Args &&... args){};
- ~list();
-};
-
-template <typename T>
-class deque {
-public:
- void push_back(const T &) {}
- void push_back(T &&) {}
-
- template <typename... Args>
- void emplace_back(Args &&... args){};
- ~deque();
-};
-
-template <typename T> struct remove_reference { using type = T; };
-template <typename T> struct remove_reference<T &> { using type = T; };
-template <typename T> struct remove_reference<T &&> { using type = T; };
-
-template <typename T1, typename T2> class pair {
-public:
- pair() = default;
- pair(const pair &) = default;
- pair(pair &&) = default;
-
- pair(const T1 &, const T2 &) {}
- pair(T1 &&, T2 &&) {}
-
- template <typename U1, typename U2> pair(const pair<U1, U2> &){};
- template <typename U1, typename U2> pair(pair<U1, U2> &&){};
-};
-
-template <typename T1, typename T2>
-pair<typename remove_reference<T1>::type, typename remove_reference<T2>::type>
-make_pair(T1 &&, T2 &&) {
- return {};
-};
-
-template <typename... Ts> class tuple {
-public:
- tuple() = default;
- tuple(const tuple &) = default;
- tuple(tuple &&) = default;
-
- tuple(const Ts &...) {}
- tuple(Ts &&...) {}
-
- template <typename... Us> tuple(const tuple<Us...> &){};
- template <typename... Us> tuple(tuple<Us...> &&) {}
-
- template <typename U1, typename U2> tuple(const pair<U1, U2> &) {
- static_assert(sizeof...(Ts) == 2, "Wrong tuple size");
- };
- template <typename U1, typename U2> tuple(pair<U1, U2> &&) {
- static_assert(sizeof...(Ts) == 2, "Wrong tuple size");
- };
-};
-
-template <typename... Ts>
-tuple<typename remove_reference<Ts>::type...> make_tuple(Ts &&...) {
- return {};
-}
-
-template <typename T>
-class unique_ptr {
-public:
- explicit unique_ptr(T *) {}
- ~unique_ptr();
-};
-} // namespace std
-
-namespace llvm {
-template <typename T>
-class LikeASmallVector {
-public:
- void push_back(const T &) {}
- void push_back(T &&) {}
-
- template <typename... Args>
- void emplace_back(Args &&... args){};
-};
-
-} // llvm
-
-void testInts() {
- std::vector<int> v;
- v.push_back(42);
- v.push_back(int(42));
- v.push_back(int{42});
- v.push_back(42.0);
- int z;
- v.push_back(z);
-}
-
-struct Something {
- Something(int a, int b = 41) {}
- Something() {}
- void push_back(Something);
- int getInt() { return 42; }
-};
-
-struct Convertable {
- operator Something() { return Something{}; }
-};
-
-struct Zoz {
- Zoz(Something, int = 42) {}
-};
-
-Zoz getZoz(Something s) { return Zoz(s); }
-
-void test_Something() {
- std::vector<Something> v;
-
- v.push_back(Something(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back instead of push_back [modernize-use-emplace]
- // CHECK-FIXES: v.emplace_back(1, 2);
-
- v.push_back(Something{1, 2});
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, 2);
-
- v.push_back(Something());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back();
-
- v.push_back(Something{});
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back();
-
- Something Different;
- v.push_back(Something(Different.getInt(), 42));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(Different.getInt(), 42);
-
- v.push_back(Different.getInt());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(Different.getInt());
-
- v.push_back(42);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(42);
-
- Something temporary(42, 42);
- temporary.push_back(temporary);
- v.push_back(temporary);
-
- v.push_back(Convertable());
- v.push_back(Convertable{});
- Convertable s;
- v.push_back(s);
-}
-
-template <typename ElemType>
-void dependOnElem() {
- std::vector<ElemType> v;
- v.push_back(ElemType(42));
-}
-
-template <typename ContainerType>
-void dependOnContainer() {
- ContainerType v;
- v.push_back(Something(42));
-}
-
-void callDependent() {
- dependOnElem<Something>();
- dependOnContainer<std::vector<Something>>();
-}
-
-void test2() {
- std::vector<Zoz> v;
- v.push_back(Zoz(Something(21, 37)));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(Something(21, 37));
-
- v.push_back(Zoz(Something(21, 37), 42));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(Something(21, 37), 42);
-
- v.push_back(getZoz(Something(1, 2)));
-}
-
-struct GetPair {
- std::pair<int, long> getPair();
-};
-void testPair() {
- std::vector<std::pair<int, int>> v;
- v.push_back(std::pair<int, int>(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, 2);
-
- GetPair g;
- v.push_back(g.getPair());
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(g.getPair());
-
- std::vector<std::pair<Something, Zoz>> v2;
- v2.push_back(std::pair<Something, Zoz>(Something(42, 42), Zoz(Something(21, 37))));
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back
- // CHECK-FIXES: v2.emplace_back(Something(42, 42), Zoz(Something(21, 37)));
-}
-
-void testTuple() {
- std::vector<std::tuple<bool, char, int>> v;
- v.push_back(std::tuple<bool, char, int>(false, 'x', 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(false, 'x', 1);
-
- v.push_back(std::tuple<bool, char, int>{false, 'y', 2});
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(false, 'y', 2);
-
- v.push_back({true, 'z', 3});
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(true, 'z', 3);
-
- std::vector<std::tuple<int, bool>> x;
- x.push_back(std::make_pair(1, false));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: x.emplace_back(1, false);
-
- x.push_back(std::make_pair(2LL, 1));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: x.emplace_back(2LL, 1);
-}
-
-struct Base {
- Base(int, int *, int = 42);
-};
-
-struct Derived : Base {
- Derived(int *, Something) : Base(42, nullptr) {}
-};
-
-void testDerived() {
- std::vector<Base> v;
- v.push_back(Derived(nullptr, Something{}));
-}
-
-void testNewExpr() {
- std::vector<Derived> v;
- v.push_back(Derived(new int, Something{}));
-}
-
-void testSpaces() {
- std::vector<Something> v;
-
- // clang-format off
-
- v.push_back(Something(1, //arg1
- 2 // arg2
- ) // Something
- );
- // CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, //arg1
- // CHECK-FIXES: 2 // arg2
- // CHECK-FIXES: // Something
- // CHECK-FIXES: );
-
- v.push_back( Something (1, 2) );
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, 2 );
-
- v.push_back( Something {1, 2} );
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, 2 );
-
- v.push_back( Something {} );
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back( );
-
- v.push_back(
- Something(1, 2) );
- // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, 2 );
-
- std::vector<Base> v2;
- v2.push_back(
- Base(42, nullptr));
- // CHECK-MESSAGES: :[[@LINE-2]]:6: warning: use emplace_back
- // CHECK-FIXES: v2.emplace_back(42, nullptr);
-
- // clang-format on
-}
-
-void testPointers() {
- std::vector<int *> v;
- v.push_back(new int(5));
-
- std::vector<std::unique_ptr<int>> v2;
- v2.push_back(std::unique_ptr<int>(new int(42)));
- // This call can't be replaced with emplace_back.
- // If emplacement will fail (not enough memory to add to vector)
- // we will have leak of int because unique_ptr won't be constructed
- // (and destructed) as in push_back case.
-
- auto *ptr = new int;
- v2.push_back(std::unique_ptr<int>(ptr));
- // Same here
-}
-
-void testMakePair() {
- std::vector<std::pair<int, int>> v;
- v.push_back(std::make_pair(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, 2);
-
- v.push_back(std::make_pair(42LL, 13));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(42LL, 13);
-
- v.push_back(std::make_pair<char, char>(0, 3));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(std::make_pair<char, char>(0, 3));
- //
- // Even though the call above could be turned into v.emplace_back(0, 3),
- // we don't eliminate the make_pair call here, because of the explicit
- // template parameters provided. make_pair's arguments can be convertible
- // to its explicitly provided template parameter, but not to the pair's
- // element type. The examples below illustrate the problem.
- struct D {
- D(...) {}
- operator char() const { return 0; }
- };
- v.push_back(std::make_pair<D, int>(Something(), 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(std::make_pair<D, int>(Something(), 2));
-
- struct X {
- X(std::pair<int, int>) {}
- };
- std::vector<X> x;
- x.push_back(std::make_pair(1, 2));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: x.emplace_back(std::make_pair(1, 2));
- // make_pair cannot be removed here, as X is not constructible with two ints.
-
- struct Y {
- Y(std::pair<int, int>&&) {}
- };
- std::vector<Y> y;
- y.push_back(std::make_pair(2, 3));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: y.emplace_back(std::make_pair(2, 3));
- // make_pair cannot be removed here, as Y is not constructible with two ints.
-}
-
-void testMakeTuple() {
- std::vector<std::tuple<int, bool, char>> v;
- v.push_back(std::make_tuple(1, true, 'v'));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1, true, 'v');
-
- v.push_back(std::make_tuple(2ULL, 1, 0));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(2ULL, 1, 0);
-
- v.push_back(std::make_tuple<long long, int, int>(3LL, 1, 0));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(std::make_tuple<long long, int, int>(3LL, 1, 0));
- // make_tuple is not removed when there are explicit template
- // arguments provided.
-}
-
-namespace test {
-template <typename T> struct Single {
- Single() = default;
- Single(const Single &) = default;
- Single(Single &&) = default;
-
- Single(const T &) {}
- Single(T &&) {}
-
- template <typename U> Single(const Single<U> &) {}
- template <typename U> Single(Single<U> &&) {}
-
- template <typename U> Single(const std::tuple<U> &) {}
- template <typename U> Single(std::tuple<U> &&) {}
-};
-
-template <typename T>
-Single<typename std::remove_reference<T>::type> MakeSingle(T &&) {
- return {};
-}
-} // namespace test
-
-void testOtherTuples() {
- std::vector<test::Single<int>> v;
- v.push_back(test::Single<int>(1));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(1);
-
- v.push_back({2});
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(2);
-
- v.push_back(test::MakeSingle(3));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(3);
-
- v.push_back(test::MakeSingle<long long>(4));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(test::MakeSingle<long long>(4));
- // We don't remove make functions with explicit template parameters.
-
- v.push_back(test::MakeSingle(5LL));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(5LL);
-
- v.push_back(std::make_tuple(6));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(6);
-
- v.push_back(std::make_tuple(7LL));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(7LL);
-}
-
-void testOtherContainers() {
- std::list<Something> l;
- l.push_back(Something(42, 41));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: l.emplace_back(42, 41);
-
- std::deque<Something> d;
- d.push_back(Something(42));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: d.emplace_back(42);
-
- llvm::LikeASmallVector<Something> ls;
- ls.push_back(Something(42));
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use emplace_back
- // CHECK-FIXES: ls.emplace_back(42);
-}
-
-class IntWrapper {
-public:
- IntWrapper(int x) : value(x) {}
- IntWrapper operator+(const IntWrapper other) const {
- return IntWrapper(value + other.value);
- }
-
-private:
- int value;
-};
-
-void testMultipleOpsInPushBack() {
- std::vector<IntWrapper> v;
- v.push_back(IntWrapper(42) + IntWrapper(27));
-}
-
-// Macro tests.
-#define PUSH_BACK_WHOLE(c, x) c.push_back(x)
-#define PUSH_BACK_NAME push_back
-#define PUSH_BACK_ARG(x) (x)
-#define SOME_OBJ Something(10)
-#define MILLION 3
-#define SOME_WEIRD_PUSH(v) v.push_back(Something(
-#define OPEN (
-#define CLOSE )
-void macroTest() {
- std::vector<Something> v;
- Something s;
-
- PUSH_BACK_WHOLE(v, Something(5, 6));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use emplace_back
-
- v.PUSH_BACK_NAME(Something(5));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
-
- v.push_back PUSH_BACK_ARG(Something(5, 6));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
-
- v.push_back(SOME_OBJ);
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
-
- v.push_back(Something(MILLION));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(MILLION);
-
- // clang-format off
- v.push_back( Something OPEN 3 CLOSE );
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // clang-format on
- PUSH_BACK_WHOLE(s, Something(1));
-}
-
-struct A {
- int value1, value2;
-};
-
-struct B {
- B(A) {}
-};
-
-struct C {
- int value1, value2, value3;
-};
-
-void testAggregation() {
- // This should not be noticed or fixed; after the correction, the code won't
- // compile.
-
- std::vector<A> v;
- v.push_back(A({1, 2}));
-
- std::vector<B> vb;
- vb.push_back(B({10, 42}));
-}
-
-struct Bitfield {
- unsigned bitfield : 1;
- unsigned notBitfield;
-};
-
-void testBitfields() {
- std::vector<Something> v;
- Bitfield b;
- v.push_back(Something(42, b.bitfield));
- v.push_back(Something(b.bitfield));
-
- v.push_back(Something(42, b.notBitfield));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(42, b.notBitfield);
- int var;
- v.push_back(Something(42, var));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(42, var);
-}
-
-class PrivateCtor {
- PrivateCtor(int z);
-
-public:
- void doStuff() {
- std::vector<PrivateCtor> v;
- // This should not change it because emplace back doesn't have permission.
- // Check currently doesn't support friend declarations because pretty much
- // nobody would want to be friend with std::vector :(.
- v.push_back(PrivateCtor(42));
- }
-};
-
-struct WithDtor {
- WithDtor(int) {}
- ~WithDtor();
-};
-
-void testWithDtor() {
- std::vector<WithDtor> v;
-
- v.push_back(WithDtor(42));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use emplace_back
- // CHECK-FIXES: v.emplace_back(42);
-}
-
-void testInitializerList() {
- std::vector<std::vector<int>> v;
- v.push_back(std::vector<int>({1}));
- // Test against the bug reported in PR32896.
-
- v.push_back({{2}});
-
- using PairIntVector = std::pair<int, std::vector<int>>;
- std::vector<PairIntVector> x;
- x.push_back(PairIntVector(3, {4}));
- x.push_back({5, {6}});
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-copy.cpp (removed)
@@ -1,507 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-equals-default.IgnoreMacros, value: 0}]}" \
-// RUN: -- -fno-delayed-template-parsing -fexceptions
-
-// Out of line definition.
-struct OL {
- OL(const OL &);
- OL &operator=(const OL &);
- int Field;
-};
-OL::OL(const OL &Other) : Field(Other.Field) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
-// CHECK-FIXES: OL::OL(const OL &Other) = default;
-OL &OL::operator=(const OL &Other) {
- Field = Other.Field;
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default]
-// CHECK-FIXES: OL &OL::operator=(const OL &Other) = default;
-
-// Inline.
-struct IL {
- IL(const IL &Other) : Field(Other.Field) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: IL(const IL &Other) = default;
- IL &operator=(const IL &Other) {
- Field = Other.Field;
- return *this;
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:7: warning: use '= default'
- // CHECK-FIXES: IL &operator=(const IL &Other) = default;
- int Field;
-};
-
-// Wrong type.
-struct WT {
- WT(const IL &Other) {}
- WT &operator=(const IL &);
-};
-WT &WT::operator=(const IL &Other) { return *this; }
-
-// Qualifiers.
-struct Qual {
- Qual(const Qual &Other) : Field(Other.Field), Volatile(Other.Volatile),
- Mutable(Other.Mutable), Reference(Other.Reference),
- Const(Other.Const) {}
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default'
- // CHECK-FIXES: Qual(const Qual &Other)
- // CHECK-FIXES: = default;
-
- int Field;
- volatile char Volatile;
- mutable bool Mutable;
- const OL &Reference; // This makes this class non-assignable.
- const IL Const; // This also makes this class non-assignable.
- static int Static;
-};
-
-// Wrong init arguments.
-struct WI {
- WI(const WI &Other) : Field1(Other.Field1), Field2(Other.Field1) {}
- WI &operator=(const WI &);
- int Field1, Field2;
-};
-WI &WI::operator=(const WI &Other) {
- Field1 = Other.Field1;
- Field2 = Other.Field1;
- return *this;
-}
-
-// Missing field.
-struct MF {
- MF(const MF &Other) : Field1(Other.Field1), Field2(Other.Field2) {}
- MF &operator=(const MF &);
- int Field1, Field2, Field3;
-};
-MF &MF::operator=(const MF &Other) {
- Field1 = Other.Field1;
- Field2 = Other.Field2;
- return *this;
-}
-
-struct Comments {
- Comments(const Comments &Other)
- /* don't delete */ : /* this comment */ Field(Other.Field) {}
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default'
- // CHECK-FIXES: /* don't delete */ = default;
- int Field;
-};
-
-struct MoreComments {
- MoreComments(const MoreComments &Other) /* this comment is OK */
- : Field(Other.Field) {}
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default'
- // CHECK-FIXES: MoreComments(const MoreComments &Other) /* this comment is OK */
- // CHECK-FIXES-NEXT: = default;
- int Field;
-};
-
-struct ColonInComment {
- ColonInComment(const ColonInComment &Other) /* : */ : Field(Other.Field) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: ColonInComment(const ColonInComment &Other) /* : */ = default;
- int Field;
-};
-
-// No members or bases (in particular, no colon).
-struct Empty {
- Empty(const Empty &Other) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: Empty(const Empty &Other) = default;
- Empty &operator=(const Empty &);
-};
-Empty &Empty::operator=(const Empty &Other) { return *this; }
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use '= default'
-// CHECK-FIXES: Empty &Empty::operator=(const Empty &Other) = default;
-
-// Bit fields.
-struct BF {
- BF() = default;
- BF(const BF &Other) : Field1(Other.Field1), Field2(Other.Field2), Field3(Other.Field3),
- Field4(Other.Field4) {}
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default'
- // CHECK-FIXES: BF(const BF &Other) {{$}}
- // CHECK-FIXES: = default;
- BF &operator=(const BF &);
-
- unsigned Field1 : 3;
- int : 7;
- char Field2 : 6;
- int : 0;
- int Field3 : 24;
- unsigned char Field4;
-};
-BF &BF::operator=(const BF &Other) {
- Field1 = Other.Field1;
- Field2 = Other.Field2;
- Field3 = Other.Field3;
- Field4 = Other.Field4;
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-7]]:9: warning: use '= default'
-// CHECK-FIXES: BF &BF::operator=(const BF &Other) = default;
-
-// Base classes.
-struct BC : IL, OL, BF {
- BC(const BC &Other) : IL(Other), OL(Other), BF(Other) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: BC(const BC &Other) = default;
- BC &operator=(const BC &Other);
-};
-BC &BC::operator=(const BC &Other) {
- IL::operator=(Other);
- OL::operator=(Other);
- BF::operator=(Other);
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-6]]:9: warning: use '= default'
-// CHECK-FIXES: BC &BC::operator=(const BC &Other) = default;
-
-// Base classes with member.
-struct BCWM : IL, OL {
- BCWM(const BCWM &Other) : IL(Other), OL(Other), Bf(Other.Bf) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: BCWM(const BCWM &Other) = default;
- BCWM &operator=(const BCWM &);
- BF Bf;
-};
-BCWM &BCWM::operator=(const BCWM &Other) {
- IL::operator=(Other);
- OL::operator=(Other);
- Bf = Other.Bf;
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-6]]:13: warning: use '= default'
-// CHECK-FIXES: BCWM &BCWM::operator=(const BCWM &Other) = default;
-
-// Missing base class.
-struct MBC : IL, OL, BF {
- MBC(const MBC &Other) : IL(Other), OL(Other) {}
- MBC &operator=(const MBC &);
-};
-MBC &MBC::operator=(const MBC &Other) {
- IL::operator=(Other);
- OL::operator=(Other);
- return *this;
-}
-
-// Base classes, incorrect parameter.
-struct BCIP : BCWM, BF {
- BCIP(const BCIP &Other) : BCWM(Other), BF(Other.Bf) {}
- BCIP &operator=(const BCIP &);
-};
-BCIP &BCIP::operator=(const BCIP &Other) {
- BCWM::operator=(Other);
- BF::operator=(Other.Bf);
- return *this;
-}
-
-// Virtual base classes.
-struct VA : virtual OL {};
-struct VB : virtual OL {};
-struct VBC : VA, VB, virtual OL {
- // OL is the first thing that is going to be initialized, despite the fact
- // that it is the last in the list of bases, because it is virtual and there
- // is a virtual OL at the beginning of VA (which is the same).
- VBC(const VBC &Other) : OL(Other), VA(Other), VB(Other) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: VBC(const VBC &Other) = default;
- VBC &operator=(const VBC &Other);
-};
-VBC &VBC::operator=(const VBC &Other) {
- OL::operator=(Other);
- VA::operator=(Other);
- VB::operator=(Other);
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-6]]:11: warning: use '= default'
-// CHECK-FIXES: VBC &VBC::operator=(const VBC &Other) = default;
-
-// Indirect base.
-struct IB : VBC {
- IB(const IB &Other) : OL(Other), VBC(Other) {}
- IB &operator=(const IB &);
-};
-IB &IB::operator=(const IB &Other) {
- OL::operator=(Other);
- VBC::operator=(Other);
- return *this;
-}
-
-// Class template.
-template <class T>
-struct Template {
- Template() = default;
- Template(const Template &Other) : Field(Other.Field) {}
- Template &operator=(const Template &Other);
- void foo(const T &t);
- int Field;
-};
-template <class T>
-Template<T> &Template<T>::operator=(const Template<T> &Other) {
- Field = Other.Field;
- return *this;
-}
-Template<int> T1;
-
-// Dependent types.
-template <class T>
-struct DT1 {
- DT1() = default;
- DT1(const DT1 &Other) : Field(Other.Field) {}
- DT1 &operator=(const DT1 &);
- T Field;
-};
-template <class T>
-DT1<T> &DT1<T>::operator=(const DT1<T> &Other) {
- Field = Other.Field;
- return *this;
-}
-DT1<int> Dt1;
-
-template <class T>
-struct DT2 {
- DT2() = default;
- DT2(const DT2 &Other) : Field(Other.Field), Dependent(Other.Dependent) {}
- DT2 &operator=(const DT2 &);
- T Field;
- typename T::TT Dependent;
-};
-template <class T>
-DT2<T> &DT2<T>::operator=(const DT2<T> &Other) {
- Field = Other.Field;
- Dependent = Other.Dependent;
- return *this;
-}
-struct T {
- typedef int TT;
-};
-DT2<T> Dt2;
-
-// Default arguments.
-struct DA {
- DA(int Int);
- DA(const DA &Other = DA(0)) : Field1(Other.Field1), Field2(Other.Field2) {}
- DA &operator=(const DA &);
- int Field1;
- char Field2;
-};
-// Overloaded operator= cannot have a default argument.
-DA &DA::operator=(const DA &Other) {
- Field1 = Other.Field1;
- Field2 = Other.Field2;
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-5]]:9: warning: use '= default'
-// CHECK-FIXES: DA &DA::operator=(const DA &Other) = default;
-
-struct DA2 {
- // Can be used as copy-constructor but cannot be explicitly defaulted.
- DA2(const DA &Other, int Def = 0) {}
-};
-
-// Default initialization.
-struct DI {
- DI(const DI &Other) : Field1(Other.Field1), Field2(Other.Field2) {}
- int Field1;
- int Field2 = 0;
- int Fiedl3;
-};
-
-// Statement inside body.
-void foo();
-struct SIB {
- SIB(const SIB &Other) : Field(Other.Field) { foo(); }
- SIB &operator=(const SIB &);
- int Field;
-};
-SIB &SIB::operator=(const SIB &Other) {
- Field = Other.Field;
- foo();
- return *this;
-}
-
-// Comment inside body.
-struct CIB {
- CIB(const CIB &Other) : Field(Other.Field) { /* Don't erase this */
- }
- // CHECK-MESSAGES: :[[@LINE-2]]:3: warning: use '= default'
- CIB &operator=(const CIB &);
- int Field;
-};
-CIB &CIB::operator=(const CIB &Other) {
- Field = Other.Field;
- // FIXME: don't erase this comment.
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-5]]:11: warning: use '= default'
-// CHECK-FIXES: CIB &CIB::operator=(const CIB &Other) = default;
-
-// Take non-const reference as argument.
-struct NCRef {
- NCRef(NCRef &Other) : Field1(Other.Field1), Field2(Other.Field2) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: NCRef(NCRef &Other) = default;
- NCRef &operator=(NCRef &);
- int Field1, Field2;
-};
-NCRef &NCRef::operator=(NCRef &Other) {
- Field1 = Other.Field1;
- Field2 = Other.Field2;
- return *this;
-}
-// CHECK-MESSAGES: :[[@LINE-5]]:15: warning: use '= default'
-// CHECK-FIXES: NCRef &NCRef::operator=(NCRef &Other) = default;
-
-// Already defaulted.
-struct IAD {
- IAD(const IAD &Other) = default;
- IAD &operator=(const IAD &Other) = default;
-};
-
-struct OAD {
- OAD(const OAD &Other);
- OAD &operator=(const OAD &);
-};
-OAD::OAD(const OAD &Other) = default;
-OAD &OAD::operator=(const OAD &Other) = default;
-
-// Deleted.
-struct ID {
- ID(const ID &Other) = delete;
- ID &operator=(const ID &Other) = delete;
-};
-
-// Non-reference parameter.
-struct NRef {
- NRef &operator=(NRef Other);
- int Field1;
-};
-NRef &NRef::operator=(NRef Other) {
- Field1 = Other.Field1;
- return *this;
-}
-
-// RValue reference parameter.
-struct RVR {
- RVR(RVR &&Other) {}
- RVR &operator=(RVR &&);
-};
-RVR &RVR::operator=(RVR &&Other) { return *this; }
-
-// Similar function.
-struct SF {
- SF &foo(const SF &);
- int Field1;
-};
-SF &SF::foo(const SF &Other) {
- Field1 = Other.Field1;
- return *this;
-}
-
-// No return.
-struct NR {
- NR &operator=(const NR &);
-};
-NR &NR::operator=(const NR &Other) {}
-
-// Return misplaced.
-struct RM {
- RM &operator=(const RM &);
- int Field;
-};
-RM &RM::operator=(const RM &Other) {
- return *this;
- Field = Other.Field;
-}
-
-// Wrong return value.
-struct WRV {
- WRV &operator=(WRV &);
-};
-WRV &WRV::operator=(WRV &Other) {
- return Other;
-}
-
-// Wrong return type.
-struct WRT : IL {
- IL &operator=(const WRT &);
-};
-IL &WRT::operator=(const WRT &Other) {
- return *this;
-}
-
-// Try-catch.
-struct ITC {
- ITC(const ITC &Other)
- try : Field(Other.Field) {
- } catch (...) {
- }
- ITC &operator=(const ITC &Other) try {
- Field = Other.Field;
- } catch (...) {
- }
- int Field;
-};
-
-struct OTC {
- OTC(const OTC &);
- OTC &operator=(const OTC &);
- int Field;
-};
-OTC::OTC(const OTC &Other) try : Field(Other.Field) {
-} catch (...) {
-}
-OTC &OTC::operator=(const OTC &Other) try {
- Field = Other.Field;
-} catch (...) {
-}
-
-// FIXME: the check is not able to detect exception specification.
-// noexcept(true).
-struct NET {
- // This is the default.
- //NET(const NET &Other) noexcept {}
- NET &operator=(const NET &Other) noexcept;
-};
-//NET &NET::operator=(const NET &Other) noexcept { return *this; }
-
-// noexcept(false).
-struct NEF {
- // This is the default.
- //NEF(const NEF &Other) noexcept(false) {}
- NEF &operator=(const NEF &Other) noexcept(false);
-};
-//NEF &NEF::operator=(const NEF &Other) noexcept(false) { return *this; }
-
-#define STRUCT_WITH_COPY_CONSTRUCT(_base, _type) \
- struct _type { \
- _type(const _type &v) : value(v.value) {} \
- _base value; \
- };
-
-STRUCT_WITH_COPY_CONSTRUCT(unsigned char, Hex8CopyConstruct)
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy constructor
-// CHECK-MESSAGES: :[[@LINE-6]]:44: note:
-
-#define STRUCT_WITH_COPY_ASSIGN(_base, _type) \
- struct _type { \
- _type &operator=(const _type &rhs) { \
- value = rhs.value; \
- return *this; \
- } \
- _base value; \
- };
-
-STRUCT_WITH_COPY_ASSIGN(unsigned char, Hex8CopyAssign)
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial copy-assignment operator
-// CHECK-MESSAGES: :[[@LINE-9]]:40: note:
-
-// Use of braces
-struct UOB{
- UOB(const UOB &Other):j{Other.j}{}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
- // CHECK-FIXES: UOB(const UOB &Other)= default;
- int j;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-delayed.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: clang-tidy %s -checks=-*,modernize-use-equals-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
-// Note: this test expects no diagnostics, but FileCheck cannot handle that,
-// hence the use of | count 0.
-// FIXME: Make the test work in all language modes.
-
-template <typename Ty>
-struct S {
- S<Ty>& operator=(const S<Ty>&) { return *this; }
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-macros.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-macros.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default-macros.cpp (removed)
@@ -1,12 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-equals-default.IgnoreMacros, value: 0}]}"
-
-#define STRUCT_WITH_DEFAULT(_base, _type) \
- struct _type { \
- _type() {} \
- _base value; \
- };
-
-STRUCT_WITH_DEFAULT(unsigned char, InMacro)
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use '= default' to define a trivial default constructor
-// CHECK-MESSAGES: :[[@LINE-6]]:13: note:
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-default.cpp (removed)
@@ -1,207 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -fno-delayed-template-parsing -fexceptions
-
-// Out of line definition.
-class OL {
-public:
- OL();
- ~OL();
-};
-
-OL::OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
-// CHECK-FIXES: OL::OL() = default;
-OL::~OL() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
-// CHECK-FIXES: OL::~OL() = default;
-
-// Inline definitions.
-class IL {
-public:
- IL() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: IL() = default;
- ~IL() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: ~IL() = default;
-};
-
-// Non-empty body.
-void f();
-class NE {
-public:
- NE() { f(); }
- ~NE() { f(); }
-};
-
-// Initializer or arguments.
-class IA {
-public:
- // Constructor with initializer.
- IA() : Field(5) {}
- // Constructor with arguments.
- IA(int Arg1, int Arg2) {}
- int Field;
-};
-
-// Default member initializer
-class DMI {
-public:
- DMI() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: DMI() = default;
- int Field = 5;
-};
-
-// Class member
-class CM {
-public:
- CM() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: CM() = default;
- OL o;
-};
-
-// Private constructor/destructor.
-class Priv {
- Priv() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: Priv() = default;
- ~Priv() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: ~Priv() = default;
-};
-
-// struct.
-struct ST {
- ST() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: ST() = default;
- ~ST() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: ST() = default;
-};
-
-// Deleted constructor/destructor.
-class Del {
-public:
- Del() = delete;
- ~Del() = delete;
-};
-
-// Do not remove other keywords.
-class KW {
-public:
- explicit KW() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use '= default'
- // CHECK-FIXES: explicit KW() = default;
- virtual ~KW() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use '= default'
- // CHECK-FIXES: virtual ~KW() = default;
-};
-
-// Nested class.
-struct N {
- struct NN {
- NN() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default'
- // CHECK-FIXES: NN() = default;
- ~NN() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default'
- // CHECK-FIXES: ~NN() = default;
- };
- int Int;
-};
-
-// Class template.
-template <class T>
-class Temp {
-public:
- Temp() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: Temp() = default;
- ~Temp() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: ~Temp() = default;
-};
-
-// Class template out of line with explicit instantiation.
-template <class T>
-class TempODef {
-public:
- TempODef();
- ~TempODef();
-};
-
-template <class T>
-TempODef<T>::TempODef() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use '= default'
-// CHECK-FIXES: TempODef<T>::TempODef() = default;
-template <class T>
-TempODef<T>::~TempODef() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use '= default'
-// CHECK-FIXES: TempODef<T>::~TempODef() = default;
-
-template class TempODef<int>;
-template class TempODef<double>;
-
-// Non user-provided constructor/destructor.
-struct Imp {
- int Int;
-};
-void g() {
- Imp *PtrImp = new Imp();
- PtrImp->~Imp();
- delete PtrImp;
-}
-
-// Already using default.
-struct IDef {
- IDef() = default;
- ~IDef() = default;
-};
-struct ODef {
- ODef();
- ~ODef();
-};
-ODef::ODef() = default;
-ODef::~ODef() = default;
-
-// Delegating constructor and overriden destructor.
-struct DC : KW {
- DC() : KW() {}
- ~DC() override {}
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= default'
- // CHECK-FIXES: ~DC() override = default;
-};
-
-struct Comments {
- Comments() {
- // Don't erase comments inside the body.
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default'
- ~Comments() {
- // Don't erase comments inside the body.
- }
- // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: use '= default'
-};
-
-// Try-catch.
-struct ITC {
- ITC() try {} catch(...) {}
- ~ITC() try {} catch(...) {}
-};
-
-struct OTC {
- OTC();
- ~OTC();
-};
-OTC::OTC() try {} catch(...) {}
-OTC::~OTC() try {} catch(...) {}
-
-#define STRUCT_WITH_DEFAULT(_base, _type) \
- struct _type { \
- _type() {} \
- _base value; \
- };
-
-STRUCT_WITH_DEFAULT(unsigned char, InMacro)
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete-macros.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-equals-delete %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-equals-delete.IgnoreMacros, value: 0}]}"
-
-#define MACRO(type) void operator=(type const &)
-class C {
-private:
- MACRO(C);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-equals-delete.cpp (removed)
@@ -1,193 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-equals-delete %t
-
-struct PositivePrivate {
-private:
- PositivePrivate();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivate() = delete;
- PositivePrivate(const PositivePrivate &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivate(const PositivePrivate &) = delete;
- PositivePrivate &operator=(const PositivePrivate &);
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivate &operator=(const PositivePrivate &) = delete;
- PositivePrivate(PositivePrivate &&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivate(PositivePrivate &&) = delete;
- PositivePrivate &operator=(PositivePrivate &&);
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivate &operator=(PositivePrivate &&) = delete;
- ~PositivePrivate();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: ~PositivePrivate() = delete;
-};
-
-template<typename T>
-struct PositivePrivateTemplate {
-private:
- PositivePrivateTemplate();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivateTemplate() = delete;
- PositivePrivateTemplate(const PositivePrivateTemplate &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivateTemplate(const PositivePrivateTemplate &) = delete;
- PositivePrivateTemplate &operator=(const PositivePrivateTemplate &);
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivateTemplate &operator=(const PositivePrivateTemplate &) = delete;
- PositivePrivateTemplate(PositivePrivateTemplate &&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivateTemplate(PositivePrivateTemplate &&) = delete;
- PositivePrivateTemplate &operator=(PositivePrivateTemplate &&);
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositivePrivateTemplate &operator=(PositivePrivateTemplate &&) = delete;
- ~PositivePrivateTemplate();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: ~PositivePrivateTemplate() = delete;
-};
-
-template struct PositivePrivateTemplate<int>;
-template struct PositivePrivateTemplate<char>;
-
-struct NegativePublic {
- NegativePublic(const NegativePublic &);
-};
-
-struct NegativeProtected {
-protected:
- NegativeProtected(const NegativeProtected &);
-};
-
-struct PositiveInlineMember {
- int foo() { return 0; }
-
-private:
- PositiveInlineMember(const PositiveInlineMember &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositiveInlineMember(const PositiveInlineMember &) = delete;
-};
-
-struct PositiveOutOfLineMember {
- int foo();
-
-private:
- PositiveOutOfLineMember(const PositiveOutOfLineMember &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositiveOutOfLineMember(const PositiveOutOfLineMember &) = delete;
-};
-
-int PositiveOutOfLineMember::foo() { return 0; }
-
-struct PositiveAbstractMember {
- virtual int foo() = 0;
-
-private:
- PositiveAbstractMember(const PositiveAbstractMember &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositiveAbstractMember(const PositiveAbstractMember &) = delete;
-};
-
-struct NegativeMemberNotImpl {
- int foo();
-
-private:
- NegativeMemberNotImpl(const NegativeMemberNotImpl &);
-};
-
-struct NegativeStaticMemberNotImpl {
- static int foo();
-
-private:
- NegativeStaticMemberNotImpl(const NegativeStaticMemberNotImpl &);
-};
-
-struct NegativeInline {
-private:
- NegativeInline(const NegativeInline &) {}
-};
-
-struct NegativeOutOfLine {
-private:
- NegativeOutOfLine(const NegativeOutOfLine &);
-};
-
-NegativeOutOfLine::NegativeOutOfLine(const NegativeOutOfLine &) {}
-
-struct NegativeConstructNotImpl {
- NegativeConstructNotImpl();
-
-private:
- NegativeConstructNotImpl(const NegativeConstructNotImpl &);
-};
-
-struct PositiveDefaultedConstruct {
- PositiveDefaultedConstruct() = default;
-
-private:
- PositiveDefaultedConstruct(const PositiveDefaultedConstruct &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositiveDefaultedConstruct(const PositiveDefaultedConstruct &) = delete;
-};
-
-struct PositiveDeletedConstruct {
- PositiveDeletedConstruct() = delete;
-
-private:
- PositiveDeletedConstruct(const PositiveDeletedConstruct &);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use '= delete' to prohibit calling of a special member function [modernize-use-equals-delete]
- // CHECK-FIXES: PositiveDeletedConstruct(const PositiveDeletedConstruct &) = delete;
-};
-
-struct NegativeDefaulted {
-private:
- NegativeDefaulted(const NegativeDefaulted &) = default;
-};
-
-struct PrivateDeleted {
-private:
- PrivateDeleted(const PrivateDeleted &) = delete;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: deleted member function should be public [modernize-use-equals-delete]
-};
-
-struct ProtectedDeleted {
-protected:
- ProtectedDeleted(const ProtectedDeleted &) = delete;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: deleted member function should be public [modernize-use-equals-delete]
-};
-
-struct PublicDeleted {
-public:
- PublicDeleted(const PublicDeleted &) = delete;
-};
-
-#define M1 \
- struct PrivateDeletedMacro { \
- private: \
- PrivateDeletedMacro(const PrivateDeletedMacro &) = delete; \
- }; \
- struct ProtectedDeletedMacro { \
- protected: \
- ProtectedDeletedMacro(const ProtectedDeletedMacro &) = delete; \
- }
-
-M1;
-
-#define DISALLOW_COPY_AND_ASSIGN(name) \
- name(const name &) = delete; \
- void operator=(const name &) = delete
-
-struct PrivateDeletedMacro2 {
-private:
- DISALLOW_COPY_AND_ASSIGN(PrivateDeletedMacro2);
-};
-
-struct ProtectedDeletedMacro2 {
-protected:
- DISALLOW_COPY_AND_ASSIGN(ProtectedDeletedMacro2);
-};
-
-// This resulted in a warning by default.
-#define MACRO(type) void operator=(type const &)
-class C {
-private:
- MACRO(C);
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp (removed)
@@ -1,24 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: '[[clang::warn_unused_result]]'}]}"
-
-class Foo
-{
-public:
- bool f1() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked {{\[\[clang::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[clang::warn_unused_result\]\]}} bool f1() const;
-
- bool f2(int) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked {{\[\[clang::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[clang::warn_unused_result\]\]}} bool f2(int) const;
-
- bool f3(const int &) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked {{\[\[clang::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[clang::warn_unused_result\]\]}} bool f3(const int &) const;
-
- bool f4(void) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked {{\[\[clang::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[clang::warn_unused_result\]\]}} bool f4(void) const;
-
-};
-
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp (removed)
@@ -1,23 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: '__attribute__((warn_unused_result))'}]}"
-
-class Foo
-{
-public:
- bool f1() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked __attribute__((warn_unused_result)) [modernize-use-nodiscard]
- // CHECK-FIXES: __attribute__((warn_unused_result)) bool f1() const;
-
- bool f2(int) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked __attribute__((warn_unused_result)) [modernize-use-nodiscard]
- // CHECK-FIXES: __attribute__((warn_unused_result)) bool f2(int) const;
-
- bool f3(const int &) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked __attribute__((warn_unused_result)) [modernize-use-nodiscard]
- // CHECK-FIXES: __attribute__((warn_unused_result)) bool f3(const int &) const;
-
- bool f4(void) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked __attribute__((warn_unused_result)) [modernize-use-nodiscard]
- // CHECK-FIXES: __attribute__((warn_unused_result)) bool f4(void) const;
-};
-
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp (removed)
@@ -1,24 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: '[[gcc::warn_unused_result]]'}]}"
-
-class Foo
-{
-public:
- bool f1() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f1() const;
-
- bool f2(int) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f2(int) const;
-
- bool f3(const int &) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f3(const int &) const;
-
- bool f4(void) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked {{\[\[gcc::warn_unused_result\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[gcc::warn_unused_result\]\]}} bool f4(void) const;
-
-};
-
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp (removed)
@@ -1,13 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'CUSTOM_NO_DISCARD'}]}"
-
-// As if the macro was not defined.
-// #define CUSTOM_NO_DISCARD __attribute_((warn_unused_result))
-
-class Foo
-{
-public:
- bool f1() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked CUSTOM_NO_DISCARD [modernize-use-nodiscard]
-};
-
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro.cpp (removed)
@@ -1,22 +0,0 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-use-nodiscard %t
-
-class Foo
-{
-public:
- bool f1() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked {{\[\[nodiscard\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[nodiscard\]\]}} bool f1() const;
-
- bool f2(int) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked {{\[\[nodiscard\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[nodiscard\]\]}} bool f2(int) const;
-
- bool f3(const int &) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked {{\[\[nodiscard\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[nodiscard\]\]}} bool f3(const int &) const;
-
- bool f4(void) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked {{\[\[nodiscard\]\]}} [modernize-use-nodiscard]
- // CHECK-FIXES: {{\[\[nodiscard\]\]}} bool f4(void) const;
-
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp (removed)
@@ -1,262 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
-// RUN: -- -std=c++17
-
-namespace std {
-template <class>
-class function;
-class string {};
-}
-
-namespace boost {
-template <class>
-class function;
-}
-
-#define MUST_USE_RESULT __attribute__((warn_unused_result))
-#define NO_DISCARD [[nodiscard]]
-#define NO_RETURN [[noreturn]]
-
-#define BOOLEAN_FUNC bool f23() const
-
-typedef unsigned my_unsigned;
-typedef unsigned &my_unsigned_reference;
-typedef const unsigned &my_unsigned_const_reference;
-
-class Foo {
-public:
- using size_type = unsigned;
-
- bool f1() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f1' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f1() const;
-
- bool f2(int) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f2' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f2(int) const;
-
- bool f3(const int &) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f3' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f3(const int &) const;
-
- bool f4(void) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f4' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f4(void) const;
-
- // negative tests
-
- void f5() const;
-
- bool f6();
-
- bool f7(int &);
-
- bool f8(int &) const;
-
- bool f9(int *) const;
-
- bool f10(const int &, int &) const;
-
- NO_DISCARD bool f12() const;
-
- MUST_USE_RESULT bool f13() const;
-
- [[nodiscard]] bool f11() const;
-
- [[clang::warn_unused_result]] bool f11a() const;
-
- [[gnu::warn_unused_result]] bool f11b() const;
-
- bool _f20() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function '_f20' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool _f20() const;
-
- NO_RETURN bool f21() const;
-
- ~Foo();
-
- bool operator+=(int) const;
-
- // extra keywords (virtual,inline,const) on return type
-
- virtual bool f14() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f14' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD virtual bool f14() const;
-
- const bool f15() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f15' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD const bool f15() const;
-
- inline const bool f16() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f16' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD inline const bool f16() const;
-
- inline const std::string &f45() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f45' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD inline const std::string &f45() const;
-
- inline virtual const bool f17() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f17' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD inline virtual const bool f17() const;
-
- // inline with body
- bool f18() const
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f18' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f18() const
- {
- return true;
- }
-
- bool f19() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f19' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f19() const;
-
- BOOLEAN_FUNC;
-
- bool f24(size_type) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f24' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f24(size_type) const;
-
- bool f28(my_unsigned) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f28' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f28(my_unsigned) const;
-
- bool f29(my_unsigned_reference) const;
-
- bool f30(my_unsigned_const_reference) const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'f30' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool f30(my_unsigned_const_reference) const;
-
- template <class F>
- F f37(F a, F b) const;
-
- template <class F>
- bool f38(F a) const;
-
- bool f39(const std::function<bool()> &predicate) const;
-
- bool f39a(std::function<bool()> predicate) const;
-
- bool f39b(const std::function<bool()> predicate) const;
-
- bool f45(const boost::function<bool()> &predicate) const;
-
- bool f45a(boost::function<bool()> predicate) const;
-
- bool f45b(const boost::function<bool()> predicate) const;
-
- // Do not add ``[[nodiscard]]`` to parameter packs.
- template <class... Args>
- bool ParameterPack(Args... args) const;
-
- template <typename... Targs>
- bool ParameterPack2(Targs... Fargs) const;
-
- // Do not add ``[[nodiscard]]`` to variadic functions.
- bool VariadicFunctionTest(const int &, ...) const;
-
- // Do not add ``[[nodiscard]]`` to non constant static functions.
- static bool not_empty();
-
- // Do not add ``[[nodiscard]]`` to conversion functions.
- // explicit operator bool() const { return true; }
-};
-
-// Do not add ``[[nodiscard]]`` to Lambda.
-const auto nonConstReferenceType = [] {
- return true;
-};
-
-auto lambda1 = [](int a, int b) { return a < b; };
-auto lambda1a = [](int a) { return a; };
-auto lambda1b = []() { return true;};
-
-auto get_functor = [](bool check) {
- return [&](const std::string& sr)->std::string {
- if(check){
- return std::string();
- }
- return std::string();
- };
-};
-
-// Do not add ``[[nodiscard]]`` to function definition.
-bool Foo::f19() const {
- return true;
-}
-
-template <class T>
-class Bar {
-public:
- using value_type = T;
- using reference = value_type &;
- using const_reference = const value_type &;
-
- // Do not add ``[[nodiscard]]`` to non explicit conversion functions.
- operator bool() const { return true; }
-
- bool empty() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: function 'empty' should be marked NO_DISCARD [modernize-use-nodiscard]
- // CHECK-FIXES: NO_DISCARD bool empty() const;
-
- // we cannot assume that the template parameter isn't a pointer
- bool f25(value_type) const;
-
- bool f27(reference) const;
-
- typename T::value_type f35() const;
-
- T f34() const;
-
- bool f31(T) const;
-
- bool f33(T &) const;
-
- bool f26(const_reference) const;
-
- bool f32(const T &) const;
-};
-
-template <typename _Tp, int cn>
-class Vec {
-public:
- Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor
-
- Vec cross(const Vec &v) const;
-
- template <typename T2>
- operator Vec<T2, cn>() const;
-};
-
-template <class T>
-class Bar2 {
-public:
- typedef T value_type;
- typedef value_type &reference;
- typedef const value_type &const_reference;
-
- // we cannot assume that the template parameter isn't a pointer
- bool f40(value_type) const;
-
- bool f41(reference) const;
-
- value_type f42() const;
-
- typename T::value_type f43() const;
-
- bool f44(const_reference) const;
-};
-
-template <class T>
-bool Bar<T>::empty() const {
- return true;
-}
-
-// don't mark typical ``[[nodiscard]]`` candidates if the class
-// has mutable member variables
-class MutableExample {
- mutable bool m_isempty;
-
-public:
- bool empty() const;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-macro.cpp (removed)
@@ -1,38 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s modernize-use-noexcept %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-noexcept.ReplacementString, value: 'NOEXCEPT'}]}" \
-// RUN: -- -fexceptions
-// This test is not run in C++17 or later because dynamic exception
-// specifications were removed in C++17.
-
-// Example definition of NOEXCEPT -- simplified test to see if noexcept is supported.
-#if (__has_feature(cxx_noexcept))
-#define NOEXCEPT noexcept
-#else
-#define NOEXCEPT throw()
-#endif
-
-void bar() throw() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'NOEXCEPT' instead [modernize-use-noexcept]
-// CHECK-FIXES: void bar() NOEXCEPT {}
-
-// Should not trigger a FixItHint, since macros only support noexcept, and this
-// case throws.
-class A {};
-class B {};
-void foobar() throw(A, B);
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
-
-// Should not trigger a replacement.
-void foo() noexcept(true);
-
-struct Z {
- void operator delete(void *ptr) throw();
- void operator delete[](void *ptr) throw(int);
- ~Z() throw(int) {}
-};
-// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'NOEXCEPT' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void operator delete(void *ptr) NOEXCEPT;
-// CHECK-FIXES: void operator delete[](void *ptr) throw(int);
-// CHECK-FIXES: ~Z() throw(int) {}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept-opt.cpp (removed)
@@ -1,90 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s modernize-use-noexcept %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-noexcept.UseNoexceptFalse, value: 0}]}" \
-// RUN: -- -fexceptions
-// This test is not run in C++17 or later because dynamic exception
-// specifications were removed in C++17.
-
-class A {};
-class B {};
-
-void foo() throw();
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void foo() noexcept;
-
-void bar() throw(...);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void bar() ;
-
-void k() throw(int(int));
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void k() ;
-
-void foobar() throw(A, B)
-{}
-// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void foobar()
-
-void baz(int = (throw A(), 0)) throw(A, B) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void baz(int = (throw A(), 0)) {}
-
-void g(void (*fp)(void) throw());
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void g(void (*fp)(void) noexcept);
-
-void f(void (*fp)(void) throw(int)) throw(char);
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void f(void (*fp)(void) ) ;
-
-#define THROW throw
-void h(void (*fp)(void) THROW(int)) THROW(char);
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void h(void (*fp)(void) ) ;
-
-void j() throw(int(int) throw(void(void) throw(int)));
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider removing it instead [modernize-use-noexcept]
-// CHECK-FIXES: void j() ;
-
-class Y {
- Y() throw() = default;
-};
-// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: Y() noexcept = default;
-
-struct Z {
- void operator delete(void *ptr) throw();
- void operator delete[](void *ptr) throw(int);
- ~Z() throw(int) {}
-};
-// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void operator delete(void *ptr) noexcept;
-// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);
-// CHECK-FIXES: ~Z() noexcept(false) {}
-
-struct S {
- void f() throw();
-};
-void f(void (S::*)() throw());
-// CHECK-MESSAGES: :[[@LINE-3]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-2]]:22: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void f() noexcept;
-// CHECK-FIXES: void f(void (S::*)() noexcept);
-
-typedef void (*fp)(void (*fp2)(int) throw());
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: typedef void (*fp)(void (*fp2)(int) noexcept);
-
-// Should not trigger a replacement.
-void titi() noexcept {}
-void toto() noexcept(true) {}
-
-// Should not trigger a replacement.
-void bad()
-#if !__has_feature(cxx_noexcept)
- throw()
-#endif
- ;
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-noexcept.cpp (removed)
@@ -1,105 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s modernize-use-noexcept %t -- -- -fexceptions
-// This test is not run in C++17 or later because dynamic exception
-// specifications were removed in C++17.
-
-class A {};
-class B {};
-
-void foo() throw();
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void foo() noexcept;
-
-template <typename T>
-void foo() throw();
-void footest() { foo<int>(); foo<double>(); }
-// CHECK-MESSAGES: :[[@LINE-2]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void foo() noexcept;
-
-void bar() throw(...);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: dynamic exception specification 'throw(...)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void bar() noexcept(false);
-
-void k() throw(int(int));
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void k() noexcept(false);
-
-void foobar() throw(A, B)
-{}
-// CHECK-MESSAGES: :[[@LINE-2]]:15: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void foobar() noexcept(false)
-
-void baz(int = (throw A(), 0)) throw(A, B) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:32: warning: dynamic exception specification 'throw(A, B)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void baz(int = (throw A(), 0)) noexcept(false) {}
-
-void g(void (*fp)(void) throw());
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void g(void (*fp)(void) noexcept);
-
-void f(void (*fp)(void) throw(int)) throw(char);
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'throw(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void f(void (*fp)(void) noexcept(false)) noexcept(false);
-
-#define THROW throw
-void h(void (*fp)(void) THROW(int)) THROW(char);
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: dynamic exception specification 'THROW(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-2]]:37: warning: dynamic exception specification 'THROW(char)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void h(void (*fp)(void) noexcept(false)) noexcept(false);
-
-void j() throw(int(int) throw(void(void) throw(int)));
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: dynamic exception specification 'throw(int(int) throw(void(void) throw(int)))' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void j() noexcept(false);
-
-class Y {
- Y() throw() = default;
-};
-// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: Y() noexcept = default;
-
-struct Z {
- void operator delete(void *ptr) throw();
- void operator delete[](void *ptr) throw(int);
- ~Z() throw(int) {}
-};
-// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-4]]:37: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-4]]:8: warning: dynamic exception specification 'throw(int)' is deprecated; consider using 'noexcept(false)' instead [modernize-use-noexcept]
-// CHECK-FIXES: void operator delete(void *ptr) noexcept;
-// CHECK-FIXES: void operator delete[](void *ptr) noexcept(false);
-// CHECK-FIXES: ~Z() noexcept(false) {}
-
-struct S {
- void f() throw();
-};
-void f(void (S::*)() throw());
-// CHECK-MESSAGES: :[[@LINE-3]]:12: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-2]]:22: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void f() noexcept;
-// CHECK-FIXES: void f(void (S::*)() noexcept);
-
-template <typename T>
-struct ST {
- void foo() throw();
-};
-template <typename T>
-void ft(void (ST<T>::*)() throw());
-// CHECK-MESSAGES: :[[@LINE-4]]:14: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-MESSAGES: :[[@LINE-2]]:27: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: void foo() noexcept;
-// CHECK-FIXES: void ft(void (ST<T>::*)() noexcept);
-
-typedef void (*fp)(void (*fp2)(int) throw());
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: dynamic exception specification 'throw()' is deprecated; consider using 'noexcept' instead [modernize-use-noexcept]
-// CHECK-FIXES: typedef void (*fp)(void (*fp2)(int) noexcept);
-
-// Should not trigger a replacement.
-void titi() noexcept {}
-void toto() noexcept(true) {}
-
-// Should not trigger a replacement.
-void bad()
-#if !__has_feature(cxx_noexcept)
- throw()
-#endif
- ;
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr-basic.cpp (removed)
@@ -1,362 +0,0 @@
-// RUN: %check_clang_tidy -std=c++98 %s modernize-use-nullptr %t -- -- -Wno-non-literal-null-conversion
-//
-// Some parts of the test (e.g. assignment of `const int` to `int *`) fail in
-// C++11, so we need to run the test in C++98 mode.
-//
-// FIXME: Make the test work in all language modes.
-
-const unsigned int g_null = 0;
-#define NULL 0
-
-void test_assignment() {
- int *p1 = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr [modernize-use-nullptr]
- // CHECK-FIXES: int *p1 = nullptr;
- p1 = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use nullptr
- // CHECK-FIXES: p1 = nullptr;
-
- int *p2 = NULL;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
- // CHECK-FIXES: int *p2 = nullptr;
-
- p2 = p1;
- // CHECK-FIXES: p2 = p1;
-
- const int null = 0;
- int *p3 = null;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
- // CHECK-FIXES: int *p3 = nullptr;
-
- p3 = NULL;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use nullptr
- // CHECK-FIXES: p3 = nullptr;
-
- int *p4 = p3;
- // CHECK-FIXES: int *p4 = p3;
-
- p4 = null;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use nullptr
- // CHECK-FIXES: p4 = nullptr;
-
- int i1 = 0;
-
- int i2 = NULL;
-
- int i3 = null;
-
- int *p5, *p6, *p7;
- p5 = p6 = p7 = NULL;
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr
- // CHECK-FIXES: p5 = p6 = p7 = nullptr;
-}
-
-struct Foo {
- Foo(int *p = NULL) : m_p1(p) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
- // CHECK-FIXES: Foo(int *p = nullptr) : m_p1(p) {}
-
- void bar(int *p = 0) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use nullptr
- // CHECK-FIXES: void bar(int *p = nullptr) {}
-
- void baz(int i = 0) {}
-
- int *m_p1;
- static int *m_p2;
-};
-
-int *Foo::m_p2 = NULL;
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr
-// CHECK-FIXES: int *Foo::m_p2 = nullptr;
-
-template <typename T>
-struct Bar {
- Bar(T *p) : m_p(p) {
- m_p = static_cast<T*>(NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
- // CHECK-FIXES: m_p = static_cast<T*>(nullptr);
-
- m_p = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
- // CHECK-FIXES: m_p = static_cast<T*>(nullptr);
-
- m_p = static_cast<T*>(p ? p : static_cast<void*>(g_null));
- // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: use nullptr
- // CHECK-FIXES: m_p = static_cast<T*>(p ? p : static_cast<void*>(nullptr));
-
- T *p2 = static_cast<T*>(reinterpret_cast<int*>((void*)NULL));
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
- // CHECK-FIXES: T *p2 = static_cast<T*>(nullptr);
-
- m_p = NULL;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use nullptr
- // CHECK-FIXES: m_p = nullptr;
-
- int i = static_cast<int>(0.f);
- T *i2 = static_cast<int>(0.f);
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
- // CHECK-FIXES: T *i2 = nullptr;
- }
-
- T *m_p;
-};
-
-struct Baz {
- Baz() : i(0) {}
- int i;
-};
-
-void test_cxx_cases() {
- Foo f(g_null);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
- // CHECK-FIXES: Foo f(nullptr);
-
- f.bar(NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
- // CHECK-FIXES: f.bar(nullptr);
-
- f.baz(g_null);
-
- f.m_p1 = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr
- // CHECK-FIXES: f.m_p1 = nullptr;
-
- Bar<int> b(g_null);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use nullptr
- // CHECK-FIXES: Bar<int> b(nullptr);
-
- Baz b2;
- int Baz::*memptr(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr
- // CHECK-FIXES: int Baz::*memptr(nullptr);
-
- memptr = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr
- // CHECK-FIXES: memptr = nullptr;
-}
-
-void test_function_default_param1(void *p = 0);
-// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: use nullptr
-// CHECK-FIXES: void test_function_default_param1(void *p = nullptr);
-
-void test_function_default_param2(void *p = NULL);
-// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: use nullptr
-// CHECK-FIXES: void test_function_default_param2(void *p = nullptr);
-
-void test_function_default_param3(void *p = g_null);
-// CHECK-MESSAGES: :[[@LINE-1]]:45: warning: use nullptr
-// CHECK-FIXES: void test_function_default_param3(void *p = nullptr);
-
-void test_function(int *p) {}
-
-void test_function_no_ptr_param(int i) {}
-
-void test_function_call() {
- test_function(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use nullptr
- // CHECK-FIXES: test_function(nullptr);
-
- test_function(NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use nullptr
- // CHECK-FIXES: test_function(nullptr);
-
- test_function(g_null);
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use nullptr
- // CHECK-FIXES: test_function(nullptr);
-
- test_function_no_ptr_param(0);
-}
-
-char *test_function_return1() {
- return 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
- // CHECK-FIXES: return nullptr;
-}
-
-void *test_function_return2() {
- return NULL;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
- // CHECK-FIXES: return nullptr;
-}
-
-long *test_function_return3() {
- return g_null;
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
- // CHECK-FIXES: return nullptr;
-}
-
-int test_function_return4() {
- return 0;
-}
-
-int test_function_return5() {
- return NULL;
-}
-
-int test_function_return6() {
- return g_null;
-}
-
-int *test_function_return_cast1() {
- return(int)0;
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
- // CHECK-FIXES: return nullptr;
-}
-
-int *test_function_return_cast2() {
-#define RET return
- RET(int)0;
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use nullptr
- // CHECK-FIXES: RET nullptr;
-#undef RET
-}
-
-// Test parentheses expressions resulting in a nullptr.
-int *test_parentheses_expression1() {
- return(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
- // CHECK-FIXES: return(nullptr);
-}
-
-int *test_parentheses_expression2() {
- return(int(0.f));
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use nullptr
- // CHECK-FIXES: return(nullptr);
-}
-
-int *test_nested_parentheses_expression() {
- return((((0))));
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
- // CHECK-FIXES: return((((nullptr))));
-}
-
-void *test_parentheses_explicit_cast() {
- return(static_cast<void*>(0));
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
- // CHECK-FIXES: return(static_cast<void*>(nullptr));
-}
-
-void *test_parentheses_explicit_cast_sequence1() {
- return(static_cast<void*>(static_cast<int*>((void*)NULL)));
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
- // CHECK-FIXES: return(static_cast<void*>(nullptr));
-}
-
-void *test_parentheses_explicit_cast_sequence2() {
- return(static_cast<void*>(reinterpret_cast<int*>((float*)int(0.f))));
- // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: use nullptr
- // CHECK-FIXES: return(static_cast<void*>(nullptr));
-}
-
-// Test explicit cast expressions resulting in nullptr.
-struct Bam {
- Bam(int *a) {}
- Bam(float *a) {}
- Bam operator=(int *a) { return Bam(a); }
- Bam operator=(float *a) { return Bam(a); }
-};
-
-void ambiguous_function(int *a) {}
-void ambiguous_function(float *a) {}
-void const_ambiguous_function(const int *p) {}
-void const_ambiguous_function(const float *p) {}
-
-void test_explicit_cast_ambiguous1() {
- ambiguous_function((int*)0);
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use nullptr
- // CHECK-FIXES: ambiguous_function((int*)nullptr);
-}
-
-void test_explicit_cast_ambiguous2() {
- ambiguous_function((int*)(0));
- // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use nullptr
- // CHECK-FIXES: ambiguous_function((int*)nullptr);
-}
-
-void test_explicit_cast_ambiguous3() {
- ambiguous_function(static_cast<int*>(reinterpret_cast<int*>((float*)0)));
- // CHECK-MESSAGES: :[[@LINE-1]]:40: warning: use nullptr
- // CHECK-FIXES: ambiguous_function(static_cast<int*>(nullptr));
-}
-
-Bam test_explicit_cast_ambiguous4() {
- return(((int*)(0)));
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use nullptr
- // CHECK-FIXES: return(((int*)nullptr));
-}
-
-void test_explicit_cast_ambiguous5() {
- // Test for ambiguous overloaded constructors.
- Bam k((int*)(0));
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
- // CHECK-FIXES: Bam k((int*)nullptr);
-
- // Test for ambiguous overloaded operators.
- k = (int*)0;
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use nullptr
- // CHECK-FIXES: k = (int*)nullptr;
-}
-
-void test_const_pointers_abiguous() {
- const_ambiguous_function((int*)0);
- // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: use nullptr
- // CHECK-FIXES: const_ambiguous_function((int*)nullptr);
-}
-
-// Test where the implicit cast to null is surrounded by another implict cast
-// with possible explict casts in-between.
-void test_const_pointers() {
- const int *const_p1 = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use nullptr
- // CHECK-FIXES: const int *const_p1 = nullptr;
- const int *const_p2 = NULL;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use nullptr
- // CHECK-FIXES: const int *const_p2 = nullptr;
- const int *const_p3 = (int)0;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use nullptr
- // CHECK-FIXES: const int *const_p3 = nullptr;
- const int *const_p4 = (int)0.0f;
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use nullptr
- // CHECK-FIXES: const int *const_p4 = nullptr;
- const int *const_p5 = (int*)0;
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: use nullptr
- // CHECK-FIXES: const int *const_p5 = (int*)nullptr;
- int *t;
- const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(0));
- // CHECK-MESSAGES: :[[@LINE-1]]:69: warning: use nullptr
- // CHECK-FIXES: const int *const_p6 = static_cast<int*>(t ? t : static_cast<int*>(nullptr));
-}
-
-void test_nested_implicit_cast_expr() {
- int func0(void*, void*);
- int func1(int, void*, void*);
-
- (double)func1(0, 0, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use nullptr
- // CHECK-MESSAGES: :[[@LINE-2]]:23: warning: use nullptr
- // CHECK-FIXES: (double)func1(0, nullptr, nullptr);
- (double)func1(func0(0, 0), 0, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use nullptr
- // CHECK-MESSAGES: :[[@LINE-2]]:26: warning: use nullptr
- // CHECK-MESSAGES: :[[@LINE-3]]:30: warning: use nullptr
- // CHECK-MESSAGES: :[[@LINE-4]]:33: warning: use nullptr
- // CHECK-FIXES: (double)func1(func0(nullptr, nullptr), nullptr, nullptr);
-}
-
-// FIXME: currently, the check doesn't work as it should with templates.
-template<typename T>
-class A {
- public:
- A(T *p = NULL) {}
-
- void f() {
- Ptr = NULL;
- }
- T *Ptr;
-};
-
-template<typename T>
-T *f2(T *a = NULL) {
- return a ? a : NULL;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.c (removed)
@@ -1,10 +0,0 @@
-// RUN: clang-tidy %s -checks=-*,modernize-use-nullptr -- | count 0
-
-// Note: this test expects no diagnostics, but FileCheck cannot handle that,
-// hence the use of | count 0.
-
-#define NULL 0
-void f(void) {
- char *str = NULL; // ok
- (void)str;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nullptr.cpp (removed)
@@ -1,304 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-nullptr %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-nullptr.NullMacros, value: 'MY_NULL,NULL'}]}"
-
-#define NULL 0
-
-namespace std {
-
-typedef decltype(nullptr) nullptr_t;
-
-} // namespace std
-
-// Just to make sure make_null() could have side effects.
-void external();
-
-std::nullptr_t make_null() {
- external();
- return nullptr;
-}
-
-void func() {
- void *CallTest = make_null();
-
- int var = 1;
- void *CommaTest = (var+=2, make_null());
-
- int *CastTest = static_cast<int*>(make_null());
-}
-
-void dummy(int*) {}
-void side_effect() {}
-
-#define MACRO_EXPANSION_HAS_NULL \
- void foo() { \
- dummy(0); \
- dummy(NULL); \
- side_effect(); \
- }
-
-MACRO_EXPANSION_HAS_NULL;
-#undef MACRO_EXPANSION_HAS_NULL
-
-
-void test_macro_expansion1() {
-#define MACRO_EXPANSION_HAS_NULL \
- dummy(NULL); \
- side_effect();
-
- MACRO_EXPANSION_HAS_NULL;
-
-#undef MACRO_EXPANSION_HAS_NULL
-}
-
-// Test macro expansion with cast sequence, PR15572.
-void test_macro_expansion2() {
-#define MACRO_EXPANSION_HAS_NULL \
- dummy((int*)0); \
- side_effect();
-
- MACRO_EXPANSION_HAS_NULL;
-
-#undef MACRO_EXPANSION_HAS_NULL
-}
-
-void test_macro_expansion3() {
-#define MACRO_EXPANSION_HAS_NULL \
- dummy(NULL); \
- side_effect();
-
-#define OUTER_MACRO \
- MACRO_EXPANSION_HAS_NULL; \
- side_effect();
-
- OUTER_MACRO;
-
-#undef OUTER_MACRO
-#undef MACRO_EXPANSION_HAS_NULL
-}
-
-void test_macro_expansion4() {
-#define MY_NULL NULL
- int *p = MY_NULL;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr [modernize-use-nullptr]
- // CHECK-FIXES: int *p = nullptr;
-#undef MY_NULL
-}
-
-#define IS_EQ(x, y) if (x != y) return;
-void test_macro_args() {
- int i = 0;
- int *Ptr;
-
- IS_EQ(static_cast<int*>(0), Ptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use nullptr
- // CHECK-FIXES: IS_EQ(static_cast<int*>(nullptr), Ptr);
-
- IS_EQ(0, Ptr); // literal
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
- // CHECK-FIXES: IS_EQ(nullptr, Ptr);
-
- IS_EQ(NULL, Ptr); // macro
- // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use nullptr
- // CHECK-FIXES: IS_EQ(nullptr, Ptr);
-
- // These are ok since the null literal is not spelled within a macro.
-#define myassert(x) if (!(x)) return;
- myassert(0 == Ptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr
- // CHECK-FIXES: myassert(nullptr == Ptr);
-
- myassert(NULL == Ptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use nullptr
- // CHECK-FIXES: myassert(nullptr == Ptr);
-
- // These are bad as the null literal is buried in a macro.
-#define BLAH(X) myassert(0 == (X));
-#define BLAH2(X) myassert(NULL == (X));
- BLAH(Ptr);
- BLAH2(Ptr);
-
- // Same as above but testing extra macro expansion.
-#define EXPECT_NULL(X) IS_EQ(0, X);
-#define EXPECT_NULL2(X) IS_EQ(NULL, X);
- EXPECT_NULL(Ptr);
- EXPECT_NULL2(Ptr);
-
- // Almost the same as above but now null literal is not in a macro so ok
- // to transform.
-#define EQUALS_PTR(X) IS_EQ(X, Ptr);
- EQUALS_PTR(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use nullptr
- // CHECK-FIXES: EQUALS_PTR(nullptr);
- EQUALS_PTR(NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use nullptr
- // CHECK-FIXES: EQUALS_PTR(nullptr);
-
- // Same as above but testing extra macro expansion.
-#define EQUALS_PTR_I(X) EQUALS_PTR(X)
- EQUALS_PTR_I(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
- // CHECK-FIXES: EQUALS_PTR_I(nullptr);
- EQUALS_PTR_I(NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
- // CHECK-FIXES: EQUALS_PTR_I(nullptr);
-
- // Ok since null literal not within macro. However, now testing macro
- // used as arg to another macro.
-#define decorate(EXPR) side_effect(); EXPR;
- decorate(IS_EQ(NULL, Ptr));
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr
- // CHECK-FIXES: decorate(IS_EQ(nullptr, Ptr));
- decorate(IS_EQ(0, Ptr));
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use nullptr
- // CHECK-FIXES: decorate(IS_EQ(nullptr, Ptr));
-
- // This macro causes a NullToPointer cast to happen where 0 is assigned to z
- // but the 0 literal cannot be replaced because it is also used as an
- // integer in the comparison.
-#define INT_AND_PTR_USE(X) do { int *z = X; if (X == 4) break; } while(false)
- INT_AND_PTR_USE(0);
-
- // Both uses of X in this case result in NullToPointer casts so replacement
- // is possible.
-#define PTR_AND_PTR_USE(X) do { int *z = X; if (X != z) break; } while(false)
- PTR_AND_PTR_USE(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
- // CHECK-FIXES: PTR_AND_PTR_USE(nullptr);
- PTR_AND_PTR_USE(NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
- // CHECK-FIXES: PTR_AND_PTR_USE(nullptr);
-
-#define OPTIONAL_CODE(...) __VA_ARGS__
-#define NOT_NULL dummy(0)
-#define CALL(X) X
- OPTIONAL_CODE(NOT_NULL);
- CALL(NOT_NULL);
-
-#define ENTRY(X) {X}
- struct A {
- int *Ptr;
- } a[2] = {ENTRY(0), {0}};
- // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
- // CHECK-MESSAGES: :[[@LINE-2]]:24: warning: use nullptr
- // CHECK-FIXES: a[2] = {ENTRY(nullptr), {nullptr}};
-#undef ENTRY
-
-#define assert1(expr) (expr) ? 0 : 1
-#define assert2 assert1
- int *p;
- assert2(p == 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
- // CHECK-FIXES: assert2(p == nullptr);
- assert2(p == NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
- // CHECK-FIXES: assert2(p == nullptr);
-#undef assert2
-#undef assert1
-
-#define ASSERT_EQ(a, b) a == b
-#define ASSERT_NULL(x) ASSERT_EQ(static_cast<void *>(NULL), x)
- int *pp;
- ASSERT_NULL(pp);
- ASSERT_NULL(NULL);
- // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use nullptr
- // CHECK-FIXES: ASSERT_NULL(nullptr);
-#undef ASSERT_NULL
-#undef ASSERT_EQ
-}
-
-// One of the ancestor of the cast is a NestedNameSpecifierLoc.
-class NoDef;
-char function(NoDef *p);
-#define F(x) (sizeof(function(x)) == 1)
-template<class T, T t>
-class C {};
-C<bool, F(0)> c;
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use nullptr
-// CHECK-FIXES: C<bool, F(nullptr)> c;
-#undef F
-
-// Test default argument expression.
-struct D {
- explicit D(void *t, int *c = NULL) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use nullptr
- // CHECK-FIXES: explicit D(void *t, int *c = nullptr) {}
-};
-
-void test_default_argument() {
- D(nullptr);
-}
-
-// Test on two neighbour CXXDefaultArgExprs nodes.
-typedef unsigned long long uint64;
-struct ZZ {
- explicit ZZ(uint64, const uint64* = NULL) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: use nullptr
-// CHECK-FIXES: explicit ZZ(uint64, const uint64* = nullptr) {}
- operator bool() { return true; }
-};
-
-uint64 Hash(uint64 seed = 0) { return 0; }
-
-void f() {
- bool a;
- a = ZZ(Hash());
-}
-
-// Test on ignoring substituted template types.
-template<typename T>
-class TemplateClass {
- public:
- explicit TemplateClass(int a, T default_value = 0) {}
-
- void h(T *default_value = 0) {}
-
- void f(int* p = 0) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use nullptr
-// CHECK-FIXES: void f(int* p = nullptr) {}
-};
-
-void IgnoreSubstTemplateType() {
- TemplateClass<int*> a(1);
-}
-
-// Test on casting nullptr.
-struct G {
- explicit G(bool, const char * = NULL) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use nullptr
- // CHECK-FIXES: explicit G(bool, const char * = nullptr) {}
-};
-bool g(const char*);
-void test_cast_nullptr() {
- G(g(nullptr));
- G(g((nullptr)));
- G(g(static_cast<char*>(nullptr)));
- G(g(static_cast<const char*>(nullptr)));
-}
-
-// Test on recognizing multiple NULLs.
-class H {
-public:
- H(bool);
-};
-
-#define T(expression) H(expression);
-bool h(int *, int *, int * = nullptr);
-void test_multiple_nulls() {
- T(h(NULL, NULL));
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
-// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
-// CHECK-FIXES: T(h(nullptr, nullptr));
- T(h(NULL, nullptr));
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
-// CHECK-FIXES: T(h(nullptr, nullptr));
- T(h(nullptr, NULL));
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use nullptr
-// CHECK-FIXES: T(h(nullptr, nullptr));
- T(h(nullptr, nullptr));
- T(h(NULL, NULL, NULL));
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use nullptr
-// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: use nullptr
-// CHECK-MESSAGES: :[[@LINE-3]]:19: warning: use nullptr
-// CHECK-FIXES: T(h(nullptr, nullptr, nullptr));
-}
-#undef T
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp (removed)
@@ -1,19 +0,0 @@
-// RUN: %check_clang_tidy -std=c++98 %s modernize-use-override %t
-
-struct Base {
- virtual ~Base() {}
- virtual void a();
- virtual void b();
-};
-
-struct SimpleCases : public Base {
-public:
- virtual ~SimpleCases();
- // CHECK-FIXES: {{^}} virtual ~SimpleCases();
-
- void a();
- // CHECK-FIXES: {{^}} void a();
-
- virtual void b();
- // CHECK-FIXES: {{^}} virtual void b();
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-ms.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-ms.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-ms.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-ms.cpp (removed)
@@ -1,25 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-override %t -- -- -fms-extensions
-
-// This test is designed to test ms-extension __declspec(dllexport) attributes.
-#define EXPORT __declspec(dllexport)
-
-class Base {
- virtual EXPORT void a();
-};
-
-class EXPORT InheritedBase {
- virtual void a();
-};
-
-class Derived : public Base {
- virtual EXPORT void a();
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
- // CHECK-FIXES: {{^}} EXPORT void a() override;
-};
-
-class EXPORT InheritedDerived : public InheritedBase {
- virtual void a();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
- // CHECK-FIXES: {{^}} void a() override;
-};
-
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-no-destructors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-no-destructors.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-no-destructors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-no-destructors.cpp (removed)
@@ -1,15 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-override %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-override.IgnoreDestructors, value: 1}]}"
-
-struct Base {
- virtual ~Base();
- virtual void f();
-};
-
-struct Simple : public Base {
- virtual ~Simple();
- // CHECK-MESSAGES-NOT: warning:
- virtual void f();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void f() override;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-macro.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-macro.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-macro.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-macro.cpp (removed)
@@ -1,69 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-override %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-override.OverrideSpelling, value: 'OVERRIDE'},{key: modernize-use-override.FinalSpelling, value: 'FINAL'}]}"
-
-#define ABSTRACT = 0
-
-#define OVERRIDE override
-#define FINAL final
-#define VIRTUAL virtual
-#define NOT_VIRTUAL
-#define NOT_OVERRIDE
-
-#define MUST_USE_RESULT __attribute__((warn_unused_result))
-#define UNUSED __attribute__((unused))
-
-struct Base {
- virtual ~Base() {}
- virtual void a();
- virtual void b();
- virtual void c();
- virtual void e() = 0;
- virtual void f2() const = 0;
- virtual void g() = 0;
- virtual void j() const;
- virtual void k() = 0;
- virtual void l() const;
-};
-
-struct SimpleCases : public Base {
-public:
- virtual ~SimpleCases();
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'OVERRIDE' or (rarely) 'FINAL' instead of 'virtual' [modernize-use-override]
- // CHECK-FIXES: {{^}} ~SimpleCases() OVERRIDE;
-
- void a();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this function with 'OVERRIDE' or (rarely) 'FINAL' [modernize-use-override]
- // CHECK-FIXES: {{^}} void a() OVERRIDE;
-
- virtual void b();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'OVERRIDE' or (rarely) 'FINAL' instead of 'virtual' [modernize-use-override]
- // CHECK-FIXES: {{^}} void b() OVERRIDE;
-
- virtual void c();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void c() OVERRIDE;
-
- virtual void e() = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void e() OVERRIDE = 0;
-
- virtual void f2() const = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void f2() const OVERRIDE = 0;
-
- virtual void g() ABSTRACT;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void g() OVERRIDE ABSTRACT;
-
- virtual void j() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void j() const OVERRIDE;
-
- virtual void k() OVERRIDE;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'OVERRIDE' [modernize-use-override]
- // CHECK-FIXES: {{^}} void k() OVERRIDE;
-
- virtual void l() const OVERRIDE;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'OVERRIDE' [modernize-use-override]
- // CHECK-FIXES: {{^}} void l() const OVERRIDE;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-with-no-macro-inscope.cpp (removed)
@@ -1,27 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-override %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-override.OverrideSpelling, value: 'CUSTOM_OVERRIDE'},{key: modernize-use-override.FinalSpelling, value: 'CUSTOM_FINAL'}]}"
-
-// As if the macro was not defined.
-//#define CUSTOM_OVERRIDE override
-//#define CUSTOM_FINAL override
-
-struct Base {
- virtual ~Base() {}
- virtual void a();
- virtual void b();
-};
-
-struct SimpleCases : public Base {
-public:
- virtual ~SimpleCases();
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'CUSTOM_OVERRIDE' or (rarely) 'CUSTOM_FINAL' instead of 'virtual' [modernize-use-override]
- // CHECK-FIXES: {{^}} virtual ~SimpleCases();
-
- void a();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this function with 'CUSTOM_OVERRIDE' or (rarely) 'CUSTOM_FINAL' [modernize-use-override]
- // CHECK-FIXES: {{^}} void a();
-
- virtual void b();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using 'CUSTOM_OVERRIDE' or (rarely) 'CUSTOM_FINAL' instead of 'virtual' [modernize-use-override]
- // CHECK-FIXES: {{^}} virtual void b();
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp (removed)
@@ -1,318 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-override %t -- -- -fexceptions
-
-#define ABSTRACT = 0
-
-#define OVERRIDE override
-#define VIRTUAL virtual
-#define NOT_VIRTUAL
-#define NOT_OVERRIDE
-
-#define MUST_USE_RESULT __attribute__((warn_unused_result))
-#define UNUSED __attribute__((unused))
-
-struct MUST_USE_RESULT MustUseResultObject {};
-
-struct IntPair {
- int First, Second;
-};
-
-struct Base {
- virtual ~Base() {}
- virtual void a();
- virtual void b();
- virtual void c();
- virtual void d();
- virtual void d2();
- virtual void e() = 0;
- virtual void f() = 0;
- virtual void f2() const = 0;
- virtual void g() = 0;
-
- virtual void j() const;
- virtual MustUseResultObject k();
- virtual bool l() MUST_USE_RESULT UNUSED;
- virtual bool n() MUST_USE_RESULT UNUSED;
-
- virtual void m();
- virtual void m2();
- virtual void o() __attribute__((unused));
-
- virtual void r() &;
- virtual void rr() &&;
-
- virtual void cv() const volatile;
- virtual void cv2() const volatile;
-
- virtual void ne() noexcept(false);
- virtual void t() throw();
-
- virtual void il(IntPair);
-};
-
-struct SimpleCases : public Base {
-public:
- virtual ~SimpleCases();
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
- // CHECK-FIXES: {{^}} ~SimpleCases() override;
-
- void a();
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
- // CHECK-FIXES: {{^}} void a() override;
-
- void b() override;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^}} void b() override;
-
- virtual void c();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void c() override;
-
- virtual void d() override;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'override'
- // CHECK-FIXES: {{^}} void d() override;
-
- virtual void d2() final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'final'
- // CHECK-FIXES: {{^}} void d2() final;
-
- virtual void e() = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void e() override = 0;
-
- virtual void f()=0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void f() override =0;
-
- virtual void f2() const=0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void f2() const override =0;
-
- virtual void g() ABSTRACT;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void g() override ABSTRACT;
-
- virtual void j() const;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void j() const override;
-
- virtual MustUseResultObject k(); // Has an implicit attribute.
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
- // CHECK-FIXES: {{^}} MustUseResultObject k() override;
-
- virtual bool l() MUST_USE_RESULT UNUSED;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} bool l() override MUST_USE_RESULT UNUSED;
-
- virtual bool n() UNUSED MUST_USE_RESULT;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} bool n() override UNUSED MUST_USE_RESULT;
-
- void m() override final;
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'override' is redundant since the function is already declared 'final'
- // CHECK-FIXES: {{^}} void m() final;
-
- virtual void m2() override final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' and 'override' are redundant since the function is already declared 'final'
- // CHECK-FIXES: {{^}} void m2() final;
-
- virtual void o() __attribute__((unused));
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void o() override __attribute__((unused));
-
- virtual void ne() noexcept(false);
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void ne() noexcept(false) override;
-
- virtual void t() throw();
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void t() throw() override;
-};
-
-// CHECK-MESSAGES-NOT: warning:
-
-void SimpleCases::c() {}
-// CHECK-FIXES: {{^}}void SimpleCases::c() {}
-
-SimpleCases::~SimpleCases() {}
-// CHECK-FIXES: {{^}}SimpleCases::~SimpleCases() {}
-
-struct DefaultedDestructor : public Base {
- DefaultedDestructor() {}
- virtual ~DefaultedDestructor() = default;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
- // CHECK-FIXES: {{^}} ~DefaultedDestructor() override = default;
-};
-
-struct FinalSpecified : public Base {
-public:
- virtual ~FinalSpecified() final;
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 'virtual' is redundant since the function is already declared 'final'
- // CHECK-FIXES: {{^}} ~FinalSpecified() final;
-
- void b() final;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^}} void b() final;
-
- virtual void d() final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
- // CHECK-FIXES: {{^}} void d() final;
-
- virtual void e() final = 0;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
- // CHECK-FIXES: {{^}} void e() final = 0;
-
- virtual void j() const final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
- // CHECK-FIXES: {{^}} void j() const final;
-
- virtual bool l() final MUST_USE_RESULT UNUSED;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
- // CHECK-FIXES: {{^}} bool l() final MUST_USE_RESULT UNUSED;
-};
-
-struct InlineDefinitions : public Base {
-public:
- virtual ~InlineDefinitions() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
- // CHECK-FIXES: {{^}} ~InlineDefinitions() override {}
-
- void a() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
- // CHECK-FIXES: {{^}} void a() override {}
-
- void b() override {}
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^}} void b() override {}
-
- virtual void c()
- {}
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void c() override
-
- virtual void d() override {}
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
- // CHECK-FIXES: {{^}} void d() override {}
-
- virtual void j() const
- {}
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void j() const override
-
- virtual MustUseResultObject k() {} // Has an implicit attribute.
- // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
- // CHECK-FIXES: {{^}} MustUseResultObject k() override {}
-
- virtual bool l() MUST_USE_RESULT UNUSED {}
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} bool l() override MUST_USE_RESULT UNUSED {}
-
- virtual void r() &
- {}
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void r() & override
-
- virtual void rr() &&
- {}
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void rr() && override
-
- virtual void cv() const volatile
- {}
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void cv() const volatile override
-
- virtual void cv2() const volatile // some comment
- {}
- // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void cv2() const volatile override // some comment
-};
-
-struct DefaultArguments : public Base {
- // Tests for default arguments (with initializer lists).
- // Make sure the override fix is placed after the argument list.
- void il(IntPair p = {1, (2 + (3))}) {}
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
- // CHECK-FIXES: {{^}} void il(IntPair p = {1, (2 + (3))}) override {}
-};
-
-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-MESSAGES: :[[@LINE-1]]:20: warning: annotate this
- // CHECK-FIXES: {{^}} NOT_VIRTUAL void a() override NOT_OVERRIDE;
-
- VIRTUAL void b() NOT_OVERRIDE;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} VIRTUAL void b() override NOT_OVERRIDE;
-
- NOT_VIRTUAL void c() OVERRIDE;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^}} NOT_VIRTUAL void c() OVERRIDE;
-
- VIRTUAL void d() OVERRIDE;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
- // CHECK-FIXES: {{^}} VIRTUAL void d() OVERRIDE;
-
-#define FUNC(return_type, name) return_type name()
- FUNC(void, e);
- // CHECK-FIXES: {{^}} FUNC(void, e);
-
-#define F virtual void f();
- F
- // CHECK-FIXES: {{^}} F
-
- VIRTUAL void g() OVERRIDE final;
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' and 'override' are redundant
- // CHECK-FIXES: {{^}} VIRTUAL void g() final;
-};
-
-// Tests for templates.
-template <typename T> struct TemplateBase {
- virtual void f(T t);
-};
-
-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); }
-
-template <class C>
-struct UnusedMemberInstantiation : public C {
- virtual ~UnusedMemberInstantiation() {}
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
- // CHECK-FIXES: {{^}} ~UnusedMemberInstantiation() override {}
-};
-struct IntantiateWithoutUse : public UnusedMemberInstantiation<Base> {};
-
-struct Base2 {
- virtual ~Base2() {}
- virtual void a();
-};
-
-// The OverrideAttr isn't propagated to specializations in all cases. Make sure
-// we don't add "override" a second time.
-template <int I>
-struct MembersOfSpecializations : public Base2 {
- void a() override;
- // CHECK-MESSAGES-NOT: warning:
- // CHECK-FIXES: {{^}} void a() override;
-};
-template <> void MembersOfSpecializations<3>::a() {}
-void ff() { MembersOfSpecializations<3>().a(); };
-
-// In case try statement is used as a method body,
-// make sure that override fix is placed before try keyword.
-struct TryStmtAsBody : public Base {
- void a() try
- // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
- // CHECK-FIXES: {{^}} void a() override try
- { b(); } catch(...) { c(); }
-
- virtual void d() try
- // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
- // CHECK-FIXES: {{^}} void d() override try
- { e(); } catch(...) { f(); }
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-trailing-return-type.cpp (removed)
@@ -1,565 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14,c++17 %s modernize-use-trailing-return-type %t -- -- -fdeclspec -fexceptions
-// FIXME: Fix the checker to work in C++2a mode, it is performing a
-// use-of-uninitialized-value.
-
-namespace std {
- template <typename T>
- class vector;
-
- template <typename T, int N>
- class array;
-
- class string;
-
- template <typename T>
- auto declval() -> T;
-}
-
-//
-// Functions
-//
-
-int f();
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto f() -> int;{{$}}
-int ((f))();
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto ((f))() -> int;{{$}}
-int f(int);
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto f(int) -> int;{{$}}
-int f(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto f(int arg) -> int;{{$}}
-int f(int arg1, int arg2, int arg3);
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3) -> int;{{$}}
-int f(int arg1, int arg2, int arg3, ...);
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3, ...) -> int;{{$}}
-template <typename T> int f(T t);
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}template <typename T> auto f(T t) -> int;{{$}}
-
-//
-// Functions with formatting
-//
-
-int a1() { return 42; }
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto a1() -> int { return 42; }{{$}}
-int a2() {
- return 42;
-}
-// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto a2() -> int {{{$}}
-int a3()
-{
- return 42;
-}
-// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto a3() -> int{{$}}
-int a4(int arg ) ;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto a4(int arg ) -> int ;{{$}}
-int a5
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto a5{{$}}
-(int arg);
-// CHECK-FIXES: {{^}}(int arg) -> int;{{$}}
-const
-int
-*
-a7
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-()
-// CHECK-FIXES: {{^}}() -> const{{$}}
-// CHECK-FIXES: {{^}}int{{$}}
-// CHECK-FIXES: {{^}}*{{$}}
-;
-
-int*a7(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto a7(int arg) -> int*;{{$}}
-template<template <typename> class C>
-C<int>a8(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto a8(int arg) -> C<int>;{{$}}
-
-
-//
-// Functions with qualifiers and specifiers
-//
-
-inline int d1(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}inline auto d1(int arg) -> int;{{$}}
-extern "C" int d2(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}extern "C" auto d2(int arg) -> int;{{$}}
-inline int d3(int arg) noexcept(true);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}inline auto d3(int arg) noexcept(true) -> int;{{$}}
-inline int d4(int arg) try { } catch(...) { }
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}inline auto d4(int arg) -> int try { } catch(...) { }{{$}}
-int d5(int arg) throw();
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto d5(int arg) throw() -> int;{{$}}
-static int d6(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static auto d6(int arg) -> int;{{$}}
-int static d6(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto static d6(int arg) -> int;{{$}}
-unsigned static int d7(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static auto d7(int arg) -> unsigned int;{{$}}
-const long static int volatile constexpr unsigned inline long d8(int arg);
-// CHECK-MESSAGES: :[[@LINE-1]]:63: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static constexpr inline auto d8(int arg) -> const long int volatile unsigned long;{{$}}
-int constexpr d9();
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto constexpr d9() -> int;{{$}}
-inline int constexpr d10();
-// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}inline auto constexpr d10() -> int;{{$}}
-unsigned constexpr int d11();
-// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}constexpr auto d11() -> unsigned int;{{$}}
-unsigned extern int d13();
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}extern auto d13() -> unsigned int;{{$}}
-int static& d14();
-// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static auto d14() -> int &;{{$}}
-class DDD {
- int friend unsigned m1();
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} friend auto m1() -> int unsigned;{{$}}
- int friend unsigned m1() { return 0; }
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} friend auto m1() -> int unsigned { return 0; }{{$}}
- const long int friend volatile constexpr unsigned inline long m2();
-// CHECK-MESSAGES: :[[@LINE-1]]:67: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} friend constexpr inline auto m2() -> const long int volatile unsigned long;{{$}}
- int virtual unsigned m3();
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto m3() -> int unsigned;{{$}}
- template <typename T>
- int friend unsigned m4();
-// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} friend auto m4() -> int unsigned;{{$}}
-};
-
-//
-// Functions in namespaces
-//
-
-namespace N {
- int e1();
-}
-// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto e1() -> int;{{$}}
-int N::e1() {}
-// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto N::e1() -> int {}{{$}}
-
-//
-// Functions with unsupported return types
-//
-int (*e3())(double);
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}int (*e3())(double);{{$}}
-struct A;
-int A::* e5();
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}int A::* e5();{{$}}
-int std::vector<std::string>::* e6();
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}int std::vector<std::string>::* e6();{{$}}
-int (std::vector<std::string>::*e7())(double);
-// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}int (std::vector<std::string>::*e7())(double);{{$}}
-
-//
-// Functions with complex return types
-//
-
-inline volatile const std::vector<std::string> e2();
-// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}inline auto e2() -> volatile const std::vector<std::string>;{{$}}
-inline const std::vector<std::string> volatile e2();
-// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}inline auto e2() -> const std::vector<std::string> volatile;{{$}}
-inline std::vector<std::string> const volatile e2();
-// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}inline auto e2() -> std::vector<std::string> const volatile;{{$}}
-int* e8();
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto e8() -> int*;{{$}}
-static const char* e9(void* user_data);
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static auto e9(void* user_data) -> const char*;{{$}}
-static const char* const e10(void* user_data);
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static auto e10(void* user_data) -> const char* const;{{$}}
-static const char** volatile * const & e11(void* user_data);
-// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static auto e11(void* user_data) -> const char** volatile * const &;{{$}}
-static const char* const * const * const e12(void* user_data);
-// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}static auto e12(void* user_data) -> const char* const * const * const;{{$}}
-struct A e13();
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto e13() -> struct A;{{$}}
-
-//
-// decltype (unsupported if top level expression)
-//
-
-decltype(1 + 2) dec1() { return 1 + 2; }
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// TODO: source range of DecltypeTypeLoc not yet implemented
-// _HECK-FIXES: {{^}}auto dec1() -> decltype(1 + 2) { return 1 + 2; }{{$}}
-template <typename F, typename T>
-decltype(std::declval<F>(std::declval<T>)) dec2(F f, T t) { return f(t); }
-// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// TODO: source range of DecltypeTypeLoc not yet implemented
-// _HECK-FIXES: {{^}}auto dec2(F f, T t) -> decltype(std::declval<F>(std::declval<T>)) { return f(t); }{{$}}
-template <typename T>
-typename decltype(std::declval<T>())::value_type dec3();
-// CHECK-MESSAGES: :[[@LINE-1]]:50: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto dec3() -> typename decltype(std::declval<T>())::value_type;{{$}}
-template <typename T>
-decltype(std::declval<T>())* dec4();
-// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto dec4() -> decltype(std::declval<T>())*;{{$}}
-
-//
-// Methods
-//
-
-struct B {
- B& operator=(const B&);
-// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto operator=(const B&) -> B&;{{$}}
-
- double base1(int, bool b);
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto base1(int, bool b) -> double;{{$}}
-
- virtual double base2(int, bool b) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto base2(int, bool b) -> double {}{{$}}
-
- virtual float base3() const = 0;
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto base3() const -> float = 0;{{$}}
-
- virtual float base4() volatile = 0;
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto base4() volatile -> float = 0;{{$}}
-
- double base5(int, bool b) &&;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto base5(int, bool b) && -> double;{{$}}
-
- double base6(int, bool b) const &&;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto base6(int, bool b) const && -> double;{{$}}
-
- double base7(int, bool b) const & = delete;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto base7(int, bool b) const & -> double = delete;{{$}}
-
- double base8(int, bool b) const volatile & = delete;
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto base8(int, bool b) const volatile & -> double = delete;{{$}}
-
- virtual const char * base9() const noexcept { return ""; }
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto base9() const noexcept -> const char * { return ""; }{{$}}
-};
-
-double B::base1(int, bool b) {}
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto B::base1(int, bool b) -> double {}{{$}}
-
-struct D : B {
- virtual double f1(int, bool b) final;
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto f1(int, bool b) -> double final;{{$}}
-
- virtual double base2(int, bool b) override;
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto base2(int, bool b) -> double override;{{$}}
-
- virtual float base3() const override final { }
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} virtual auto base3() const -> float override final { }{{$}}
-
- const char * base9() const noexcept override { return ""; }
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto base9() const noexcept -> const char * override { return ""; }{{$}}
-
- int f2() __restrict;
-// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto f2() __restrict -> int;{{$}}
-
- volatile int* __restrict f3() const __restrict noexcept;
-// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto f3() const __restrict noexcept -> volatile int* __restrict;{{$}}
-};
-
-//
-// Functions with attributes
-//
-
-int g1() [[asdf]];
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto g1() -> int {{[[][[]}}asdf{{[]][]]}};{{$}}
-[[noreturn]] int g2();
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}{{[[][[]}}noreturn{{[]][]]}} auto g2() -> int;{{$}}
-int g2 [[noreturn]] ();
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto g2 {{[[][[]}}noreturn{{[]][]]}} () -> int;{{$}}
-int unsigned g3() __attribute__((cdecl)); // FunctionTypeLoc is null.
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-int unsigned __attribute__((cdecl)) g3() ; // FunctionTypeLoc is null.
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-__attribute__((cdecl)) int unsigned g3() ; // FunctionTypeLoc is null.
-// CHECK-MESSAGES: :[[@LINE-1]]:37: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-
-//
-// Templates
-//
-template <typename Container>
-[[maybe_unused]] typename Container::value_type const volatile&& t1(Container& C) noexcept;
-// CHECK-MESSAGES: :[[@LINE-1]]:66: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}{{[[][[]}}maybe_unused{{[]][]]}} auto t1(Container& C) noexcept -> typename Container::value_type const volatile&&;{{$}}
-template <typename T>
-class BB {
- using type = int;
-
- template <typename U>
- typename BB<U>::type m1();
-// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto m1() -> typename BB<U>::type;{{$}}
-};
-
-//
-// Macros
-//
-
-#define DWORD unsigned int
-DWORD h1();
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h1() -> DWORD;{{$}}
-#define INT int
-#define UNSIGNED unsigned
-UNSIGNED INT h2();
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h2() -> UNSIGNED INT;{{$}}
-#define CONST const
-CONST int h3();
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h3() -> CONST int;{{$}}
-#define ALWAYS_INLINE inline
-#define DLL_EXPORT __declspec(dllexport)
-ALWAYS_INLINE DLL_EXPORT int h4();
-// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}ALWAYS_INLINE DLL_EXPORT auto h4() -> int;{{$}}
-#define DEPRECATED __attribute__((deprecated))
-int h5() DEPRECATED;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h5() -> int DEPRECATED;{{$}}
-int DEPRECATED h5();
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto DEPRECATED h5() -> int;{{$}}
-DEPRECATED int h5();
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}DEPRECATED auto h5() -> int;{{$}}
-[[noreturn]] [[nodiscard]] DEPRECATED DLL_EXPORT int h6 [[deprecated]] ();
-// CHECK-MESSAGES: :[[@LINE-1]]:54: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}{{[[][[]}}noreturn{{[]][]]}} {{[[][[]}}nodiscard{{[]][]]}} DEPRECATED DLL_EXPORT auto h6 {{[[][[]}}deprecated{{[]][]]}} () -> int;{{$}}
-#define FUNCTION_NAME(a, b) a##b
-int FUNCTION_NAME(foo, bar)();
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto FUNCTION_NAME(foo, bar)() -> int;{{$}}
-#define DEFINE_FUNCTION_1(a, b) int a##b()
-DEFINE_FUNCTION_1(foo, bar);
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-#define DEFINE_FUNCTION_2 int foo(int arg);
-DEFINE_FUNCTION_2
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-#define DLL_EXPORT_const __declspec(dllexport) const
-DLL_EXPORT_const int h7();
-// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-#define DLL_EXPORT_CONST __declspec(dllexport) CONST
-DLL_EXPORT_CONST int h7();
-// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-
-template <typename T>
-using Real = T;
-#define PRECISION float
-Real<PRECISION> h8() { return 0.; }
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h8() -> Real<PRECISION> { return 0.; }{{$}}
-
-#define MAYBE_UNUSED_MACRO [[maybe_unused]]
-template <typename Container>
-MAYBE_UNUSED_MACRO typename Container::value_type const volatile** const h9(Container& C) noexcept;
-// CHECK-MESSAGES: :[[@LINE-1]]:74: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}MAYBE_UNUSED_MACRO auto h9(Container& C) noexcept -> typename Container::value_type const volatile** const;{{$}}
-
-#define NOEXCEPT noexcept
-int h9(int arg) NOEXCEPT;
-// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h9(int arg) NOEXCEPT -> int;{{$}}
-#define STATIC_INT static int
-STATIC_INT h10();
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-#define UNSIGNED_STATIC_INT unsigned static int
-UNSIGNED_STATIC_INT h11();
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-#define STATIC static
-unsigned STATIC int h11();
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}STATIC auto h11() -> unsigned int;{{$}}
-#define STATIC_CONSTEXPR static constexpr
-unsigned STATIC_CONSTEXPR int h12();
-// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}STATIC_CONSTEXPR auto h12() -> unsigned int;{{$}}
-#define STATIC_CONSTEXPR_LONG static constexpr long
-unsigned STATIC_CONSTEXPR_LONG int h13();
-// CHECK-MESSAGES: :[[@LINE-1]]:36: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-DEPRECATED const int& h14();
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}DEPRECATED auto h14() -> const int&;{{$}}
-DEPRECATED const long static volatile unsigned& h15();
-// CHECK-MESSAGES: :[[@LINE-1]]:49: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}DEPRECATED static auto h15() -> const long volatile unsigned&;{{$}}
-#define WRAP(x) x
-WRAP(const) int& h16();
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-WRAP(CONST) int& h16();
-// CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-#define CONCAT(a, b) a##b
-CONCAT(con, st) int& h16();
-// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-DEPRECATED const UNSIGNED& h17();
-// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}DEPRECATED auto h17() -> const UNSIGNED&;{{$}}
-DEPRECATED CONST UNSIGNED STATIC& h18();
-// CHECK-MESSAGES: :[[@LINE-1]]:35: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}DEPRECATED STATIC auto h18() -> CONST UNSIGNED &;{{$}}
-#define CONST_CAT con##st
-CONST_CAT int& h19();
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h19() -> CONST_CAT int&;{{$}}
-#define CONST_F_MACRO WRAP(CONST_CAT)
-CONST_F_MACRO int& h19();
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto h19() -> CONST_F_MACRO int&;{{$}}
-
-//
-// Name collisions
-//
-struct Object { long long value; };
-
-Object j1(unsigned Object) { return {Object * 2}; }
-// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}Object j1(unsigned Object) { return {Object * 2}; }{{$}}
-::Object j1(unsigned Object);
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto j1(unsigned Object) -> ::Object;{{$}}
-const Object& j2(unsigned a, int b, char Object, long l);
-// CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}const Object& j2(unsigned a, int b, char Object, long l);{{$}}
-const struct Object& j2(unsigned a, int b, char Object, long l);
-// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto j2(unsigned a, int b, char Object, long l) -> const struct Object&;{{$}}
-std::vector<Object> j3(unsigned Object);
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}std::vector<Object> j3(unsigned Object);{{$}}
-std::vector<const Object> j7(unsigned Object);
-// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}std::vector<const Object> j7(unsigned Object);{{$}}
-std::vector<Object> j4(unsigned vector);
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto j4(unsigned vector) -> std::vector<Object>;{{$}}
-std::vector<::Object> j4(unsigned vector);
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto j4(unsigned vector) -> std::vector<::Object>;{{$}}
-std::vector<struct Object> j4(unsigned vector);
-// CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto j4(unsigned vector) -> std::vector<struct Object>;{{$}}
-std::vector<Object> j4(unsigned Vector);
-// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto j4(unsigned Vector) -> std::vector<Object>;{{$}}
-using std::vector;
-vector<Object> j5(unsigned vector);
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}vector<Object> j5(unsigned vector);{{$}}
-constexpr auto Size = 5;
-std::array<int, Size> j6(unsigned Size);
-// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}std::array<int, Size> j6(unsigned Size);{{$}}
-std::array<decltype(Size), (Size * 2) + 1> j8(unsigned Size);
-// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}std::array<decltype(Size), (Size * 2) + 1> j8(unsigned Size);{{$}}
-
-class CC {
- int Object;
- struct Object m();
-// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto m() -> struct Object;{{$}}
-};
-Object CC::m() { return {0}; }
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto CC::m() -> Object { return {0}; }{{$}}
-class DD : public CC {
- ::Object g();
-// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}} auto g() -> ::Object;{{$}}
-};
-Object DD::g() {
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return-type]
-// CHECK-FIXES: {{^}}auto DD::g() -> Object {{{$}}
- return {0};
-}
-
-
-//
-// Samples which do not trigger the check
-//
-
-auto f() -> int;
-auto f(int) -> int;
-auto f(int arg) -> int;
-auto f(int arg1, int arg2, int arg3) -> int;
-auto f(int arg1, int arg2, int arg3, ...) -> int;
-template <typename T> auto f(T t) -> int;
-
-auto ff();
-decltype(auto) fff();
-
-void c();
-void c(int arg);
-void c(int arg) { return; }
-
-struct D2 : B {
- D2();
- virtual ~D2();
-
- virtual auto f1(int, bool b) -> double final;
- virtual auto base2(int, bool b) -> double override;
- virtual auto base3() const -> float override final { }
-
- operator double();
-};
-
-auto l1 = [](int arg) {};
-auto l2 = [](int arg) -> double {};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-transparent-functors.cpp (removed)
@@ -1,110 +0,0 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-use-transparent-functors %t
-
-namespace std {
-template<class T>
-struct remove_reference;
-
-template <class T>
-constexpr T &&forward(typename std::remove_reference<T>::type &t);
-
-template <class T>
-constexpr T &&forward(typename std::remove_reference<T>::type &&t);
-
-template <typename T = void>
-struct plus {
- constexpr T operator()(const T &Lhs, const T &Rhs) const;
-};
-
-template <>
-struct plus<void> {
- template <typename T, typename U>
- constexpr auto operator()(T &&Lhs, U &&Rhs) const ->
- decltype(forward<T>(Lhs) + forward<U>(Rhs));
-};
-
-template <typename T = void>
-struct less {
- constexpr bool operator()(const T &Lhs, const T &Rhs) const;
-};
-
-template <>
-struct less<void> {
- template <typename T, typename U>
- constexpr bool operator()(T &&Lhs, U &&Rhs) const;
-};
-
-template <typename T = void>
-struct logical_not {
- constexpr bool operator()(const T &Arg) const;
-};
-
-template <>
-struct logical_not<void> {
- template <typename T>
- constexpr bool operator()(T &&Arg) const;
-};
-
-template <typename T>
-class allocator;
-
-template <
- class Key,
- class Compare = std::less<>,
- class Allocator = std::allocator<Key>>
-class set {};
-
-template <
- class Key,
- class Compare = std::less<Key>,
- class Allocator = std::allocator<Key>>
-class set2 {};
-
-template <class InputIt, class UnaryPredicate>
-InputIt find_if(InputIt first, InputIt last,
- UnaryPredicate p);
-
-template <class RandomIt, class Compare>
-void sort(RandomIt first, RandomIt last, Compare comp);
-
-class iterator {};
-class string {};
-}
-
-int main() {
- using std::set;
- using std::less;
- std::set<int, std::less<int>> s;
- // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer transparent functors 'less<>' [modernize-use-transparent-functors]
- // CHECK-FIXES: {{^}} std::set<int, std::less<>> s;{{$}}
- set<int, std::less<int>> s2;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
- // CHECK-FIXES: {{^}} set<int, std::less<>> s2;{{$}}
- set<int, less<int>> s3;
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: prefer transparent functors
- // CHECK-FIXES: {{^}} set<int, less<>> s3;{{$}}
- std::set<int, std::less<>> s4;
- std::set<char *, std::less<std::string>> s5;
- std::set<set<int, less<int>>, std::less<>> s6;
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: prefer transparent functors
- // CHECK-FIXES: {{^}} std::set<set<int, less<>>, std::less<>> s6;{{$}}
- std::iterator begin, end;
- sort(begin, end, std::less<int>());
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: prefer transparent functors
- std::sort(begin, end, std::less<>());
- find_if(begin, end, std::logical_not<bool>());
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
- std::find_if(begin, end, std::logical_not<>());
- using my_set = std::set<int, std::less<int>>;
- // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: prefer transparent functors
- // CHECK-FIXES: {{^}} using my_set = std::set<int, std::less<>>;{{$}}
- using my_set2 = std::set<char*, std::less<std::string>>;
- using my_less = std::less<std::string>;
- find_if(begin, end, my_less());
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: prefer transparent functors
- std::set2<int> control;
-}
-
-struct ImplicitTypeLoc : std::set2<std::less<int>> {
- // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: prefer transparent functors
- ImplicitTypeLoc() {}
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-uncaught-exceptions.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-uncaught-exceptions.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-uncaught-exceptions.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-uncaught-exceptions.cpp (removed)
@@ -1,80 +0,0 @@
-// RUN: %check_clang_tidy -std=c++17-or-later %s modernize-use-uncaught-exceptions %t
-
-#define MACRO std::uncaught_exception
-// CHECK-FIXES: #define MACRO std::uncaught_exception
-
-bool uncaught_exception() {
- return 0;
-}
-
-namespace std {
- bool uncaught_exception() {
- return false;
- }
-
- int uncaught_exceptions() {
- return 0;
- }
-}
-
-template <typename T>
-bool doSomething(T t) {
- return t();
- // CHECK-FIXES: return t();
-}
-
-template <bool (*T)()>
-bool doSomething2() {
- return T();
- // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: return T();
-}
-
-void no_warn() {
-
- uncaught_exception();
- // CHECK-FIXES: uncaught_exception();
-
- doSomething(uncaught_exception);
- // CHECK-FIXES: doSomething(uncaught_exception);
-}
-
-void warn() {
-
- std::uncaught_exception();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: std::uncaught_exceptions();
-
- using std::uncaught_exception;
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: using std::uncaught_exceptions;
-
- uncaught_exception();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: uncaught_exceptions();
-
- bool b{uncaught_exception()};
- // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: bool b{std::uncaught_exceptions() > 0};
-
- MACRO();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: MACRO();
-
- doSomething(std::uncaught_exception);
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: doSomething(std::uncaught_exception);
-
- doSomething(uncaught_exception);
- // CHECK-MESSAGES: [[@LINE-1]]:15: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: doSomething(uncaught_exception);
-
- bool (*foo)();
- foo = &uncaught_exception;
- // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: foo = &uncaught_exception;
-
- doSomething2<uncaught_exception>();
- // CHECK-MESSAGES: [[@LINE-1]]:16: warning: 'std::uncaught_exception' is deprecated, use 'std::uncaught_exceptions' instead
- // CHECK-FIXES: doSomething2<uncaught_exception>();
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-using-macros.cpp (removed)
@@ -1,22 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-using %t -- \
-// RUN: -config="{CheckOptions: [{key: modernize-use-using.IgnoreMacros, value: 0}]}"
-
-#define CODE typedef int INT
-
-CODE;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: #define CODE typedef int INT
-// CHECK-FIXES: CODE;
-
-struct Foo;
-#define Bar Baz
-typedef Foo Bar;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: #define Bar Baz
-// CHECK-FIXES: using Baz = Foo;
-
-#define TYPEDEF typedef
-TYPEDEF Foo Bak;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: #define TYPEDEF typedef
-// CHECK-FIXES: TYPEDEF Foo Bak;
Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-using.cpp (removed)
@@ -1,185 +0,0 @@
-// RUN: %check_clang_tidy %s modernize-use-using %t
-
-typedef int Type;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef' [modernize-use-using]
-// CHECK-FIXES: using Type = int;
-
-typedef long LL;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using LL = long;
-
-typedef int Bla;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Bla = int;
-
-typedef Bla Bla2;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Bla2 = Bla;
-
-typedef void (*type)(int, int);
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using type = void (*)(int, int);
-
-typedef void (*type2)();
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using type2 = void (*)();
-
-class Class {
- typedef long long Type;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
- // CHECK-FIXES: using Type = long long;
-};
-
-typedef void (Class::*MyPtrType)(Bla) const;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using MyPtrType = void (Class::*)(Bla)[[ATTR:( __attribute__\(\(thiscall\)\))?]] const;
-
-class Iterable {
-public:
- class Iterator {};
-};
-
-template <typename T>
-class Test {
- typedef typename T::iterator Iter;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
- // CHECK-FIXES: using Iter = typename T::iterator;
-};
-
-using balba = long long;
-
-union A {};
-
-typedef void (A::*PtrType)(int, int) const;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using PtrType = void (A::*)(int, int)[[ATTR]] const;
-
-typedef Class some_class;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using some_class = Class;
-
-typedef Class Cclass;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Cclass = Class;
-
-typedef Cclass cclass2;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using cclass2 = Cclass;
-
-class cclass {};
-
-typedef void (cclass::*MyPtrType3)(Bla);
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using MyPtrType3 = void (cclass::*)(Bla)[[ATTR]];
-
-using my_class = int;
-
-typedef Test<my_class *> another;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using another = Test<my_class *>;
-
-typedef int* PInt;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using PInt = int *;
-
-typedef int bla1, bla2, bla3;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef int bla1, bla2, bla3;
-
-#define CODE typedef int INT
-
-CODE;
-// CHECK-FIXES: #define CODE typedef int INT
-// CHECK-FIXES: CODE;
-
-struct Foo;
-#define Bar Baz
-typedef Foo Bar;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: #define Bar Baz
-// CHECK-FIXES: using Baz = Foo;
-
-#define TYPEDEF typedef
-TYPEDEF Foo Bak;
-// CHECK-FIXES: #define TYPEDEF typedef
-// CHECK-FIXES: TYPEDEF Foo Bak;
-
-#define FOO Foo
-typedef FOO Bam;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: #define FOO Foo
-// CHECK-FIXES: using Bam = Foo;
-
-typedef struct Foo Bap;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Bap = struct Foo;
-
-struct Foo typedef Bap2;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Bap2 = struct Foo;
-
-Foo typedef Bap3;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Bap3 = Foo;
-
-typedef struct Unknown Baq;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Baq = struct Unknown;
-
-struct Unknown2 typedef Baw;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Baw = struct Unknown2;
-
-int typedef Bax;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using Bax = int;
-
-typedef struct Q1 { int a; } S1;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef struct Q1 { int a; } S1;
-typedef struct { int b; } S2;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef struct { int b; } S2;
-struct Q2 { int c; } typedef S3;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: struct Q2 { int c; } typedef S3;
-struct { int d; } typedef S4;
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: struct { int d; } typedef S4;
-
-namespace my_space {
- class my_cclass {};
- typedef my_cclass FuncType;
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using FuncType = my_cclass;
-}
-
-#define lol 4
-typedef unsigned Map[lol];
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: typedef unsigned Map[lol];
-
-typedef void (*fun_type)();
-// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: use 'using' instead of 'typedef'
-// CHECK-FIXES: using fun_type = void (*)();
-
-namespace template_instantiations {
-template <typename T>
-class C {
- protected:
- typedef C<T> super;
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use 'using' instead of 'typedef'
- // CHECK-FIXES: using super = C<T>;
- virtual void f();
-
-public:
- virtual ~C();
-};
-
-class D : public C<D> {
- void f() override { super::f(); }
-};
-class E : public C<E> {
- void f() override { super::f(); }
-};
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/mpi-buffer-deref.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/mpi-buffer-deref.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/mpi-buffer-deref.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/mpi-buffer-deref.cpp (removed)
@@ -1,51 +0,0 @@
-// REQUIRES: static-analyzer
-// RUN: %check_clang_tidy %s mpi-buffer-deref %t -- -- -I %S/Inputs/mpi-type-mismatch
-
-#include "mpimock.h"
-
-void negativeTests() {
- char *buf;
- MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->pointer [mpi-buffer-deref]
-
- unsigned **buf2;
- MPI_Send(buf2, 1, MPI_UNSIGNED, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->pointer
-
- short buf3[1][1];
- MPI_Send(buf3, 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: array->array
-
- long double _Complex *buf4[1];
- MPI_Send(buf4, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->array
-
- std::complex<float> *buf5[1][1];
- MPI_Send(&buf5, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer is insufficiently dereferenced: pointer->array->array->pointer
-}
-
-void positiveTests() {
- char buf;
- MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
-
- unsigned *buf2;
- MPI_Send(buf2, 1, MPI_UNSIGNED, 0, 0, MPI_COMM_WORLD);
-
- short buf3[1][1];
- MPI_Send(buf3[0], 1, MPI_SHORT, 0, 0, MPI_COMM_WORLD);
-
- long double _Complex *buf4[1];
- MPI_Send(*buf4, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
- long double _Complex buf5[1];
- MPI_Send(buf5, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
- std::complex<float> *buf6[1][1];
- MPI_Send(*buf6[0], 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
- // Referencing an array with '&' is valid, as this also points to the
- // beginning of the array.
- long double _Complex buf7[1];
- MPI_Send(&buf7, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp (removed)
@@ -1,256 +0,0 @@
-// REQUIRES: static-analyzer
-// RUN: %check_clang_tidy %s mpi-type-mismatch %t -- -- -I %S/Inputs/mpi-type-mismatch
-
-#include "mpimock.h"
-
-void charNegativeTest() {
- int buf;
- MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int' does not match the MPI datatype 'MPI_CHAR'
-
- short buf2;
- MPI_Send(&buf2, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_CHAR'
-
- long buf3;
- MPI_Send(&buf3, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' does not match the MPI datatype 'MPI_CHAR'
-
- int8_t buf4;
- MPI_Send(&buf4, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not match the MPI datatype 'MPI_CHAR'
-
- uint16_t buf5;
- MPI_Send(&buf5, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_CHAR'
-
- long double _Complex buf6;
- MPI_Send(&buf6, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long double _Complex' does not match the MPI datatype 'MPI_CHAR'
-
- std::complex<float> buf7;
- MPI_Send(&buf7, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex<float>' does not match the MPI datatype 'MPI_CHAR'
-}
-
-void intNegativeTest() {
- unsigned char buf;
- MPI_Send(&buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned char' does not match the MPI datatype 'MPI_INT'
-
- unsigned buf2;
- MPI_Send(&buf2, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT'
-
- short buf3;
- MPI_Send(&buf3, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_INT'
-
- long buf4;
- MPI_Send(&buf4, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' does not match the MPI datatype 'MPI_INT'
-
- int8_t buf5;
- MPI_Send(&buf5, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not match the MPI datatype 'MPI_INT'
-
- uint16_t buf6;
- MPI_Send(&buf6, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_INT'
-
- long double _Complex buf7;
- MPI_Send(&buf7, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long double _Complex' does not match the MPI datatype 'MPI_INT'
-
- std::complex<float> buf8;
- MPI_Send(&buf8, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex<float>' does not match the MPI datatype 'MPI_INT'
-}
-
-void longNegativeTest() {
- char buf;
- MPI_Send(&buf, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'char' does not match the MPI datatype 'MPI_LONG'
-
- unsigned buf2;
- MPI_Send(&buf2, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_LONG'
-
- unsigned short buf3;
- MPI_Send(&buf3, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned short' does not match the MPI datatype 'MPI_LONG'
-
- unsigned long buf4;
- MPI_Send(&buf4, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned long' does not match the MPI datatype 'MPI_LONG'
-
- int8_t buf5;
- MPI_Send(&buf5, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not match the MPI datatype 'MPI_LONG'
-
- uint16_t buf6;
- MPI_Send(&buf6, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_LONG'
-
- long double _Complex buf7;
- MPI_Send(&buf7, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long double _Complex' does not match the MPI datatype 'MPI_LONG'
-
- std::complex<float> buf8;
- MPI_Send(&buf8, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex<float>' does not match the MPI datatype 'MPI_LONG'
-}
-
-void int8_tNegativeTest() {
- char buf;
- MPI_Send(&buf, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'char' does not match the MPI datatype 'MPI_INT8_T'
-
- unsigned buf2;
- MPI_Send(&buf2, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT8_T'
-
- short buf3;
- MPI_Send(&buf3, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_INT8_T'
-
- unsigned long buf4;
- MPI_Send(&buf4, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned long' does not match the MPI datatype 'MPI_INT8_T'
-
- uint8_t buf5;
- MPI_Send(&buf5, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint8_t' does not match the MPI datatype 'MPI_INT8_T'
-
- uint16_t buf6;
- MPI_Send(&buf6, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_INT8_T'
-
- long double _Complex buf7;
- MPI_Send(&buf7, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long double _Complex' does not match the MPI datatype 'MPI_INT8_T'
-
- std::complex<float> buf8;
- MPI_Send(&buf8, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex<float>' does not match the MPI datatype 'MPI_INT8_T'
-}
-
-void complex_c_long_double_complexNegativeTest() {
- char buf;
- MPI_Send(&buf, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'char' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-
- unsigned buf2;
- MPI_Send(&buf2, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-
- short buf3;
- MPI_Send(&buf3, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-
- unsigned long buf4;
- MPI_Send(&buf4, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned long' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-
- uint8_t buf5;
- MPI_Send(&buf5, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint8_t' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-
- uint16_t buf6;
- MPI_Send(&buf6, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-
- double _Complex buf7;
- MPI_Send(&buf7, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'double _Complex' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-
- std::complex<float> buf8;
- MPI_Send(&buf8, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex<float>' does not match the MPI datatype 'MPI_C_LONG_DOUBLE_COMPLEX'
-}
-
-void complex_cxx_float_complexNegativeTest() {
- char buf;
- MPI_Send(&buf, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'char' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-
- unsigned buf2;
- MPI_Send(&buf2, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-
- short buf3;
- MPI_Send(&buf3, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-
- unsigned long buf4;
- MPI_Send(&buf4, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned long' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-
- uint8_t buf5;
- MPI_Send(&buf5, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint8_t' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-
- uint16_t buf6;
- MPI_Send(&buf6, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-
- double _Complex buf7;
- MPI_Send(&buf7, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'double _Complex' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-
- std::complex<double> buf8;
- MPI_Send(&buf8, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex<double>' does not match the MPI datatype 'MPI_CXX_FLOAT_COMPLEX'
-}
-
-void skippedTypesTests() {
- // typedefs, user defined MPI and nullptr types are skipped
- typedef char CHAR;
- CHAR buf;
- MPI_Send(&buf, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
- typedef unsigned UNSIGNED;
- UNSIGNED buf2;
- MPI_Send(&buf2, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
-#define _MPI_LONG MPI_LONG
- int buf3;
- MPI_Send(&buf3, 1, _MPI_LONG, 0, 0, MPI_COMM_WORLD);
-
-#define _MPI_CXX_FLOAT_COMPLEX MPI_CXX_FLOAT_COMPLEX
- short buf4;
- MPI_Send(&buf4, 1, _MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
- MPI_Send(NULL, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
-}
-
-void positiveTests() {
- char buf;
- MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
-
- int buf2;
- MPI_Send(&buf2, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
-
- long buf3;
- MPI_Send(&buf3, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
-
- int8_t buf4;
- MPI_Send(&buf4, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
-
- long double _Complex buf5;
- MPI_Send(&buf5, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
- std::complex<float> buf6;
- MPI_Send(&buf6, 1, MPI_CXX_FLOAT_COMPLEX, 0, 0, MPI_COMM_WORLD);
-
- uint8_t buf7;
- MPI_Send(&buf7, 1, MPI_UINT8_T, 0, 0, MPI_COMM_WORLD);
-
- uint16_t buf8;
- MPI_Send(&buf8, 1, MPI_UINT16_T, 0, 0, MPI_COMM_WORLD);
-
- // On some systems like PPC or ARM, 'char' is unsigned by default which is why
- // distinct signedness for the buffer and MPI type is tolerated.
- unsigned char buf9;
- MPI_Send(&buf9, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/nolint-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/nolint-plugin.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/nolint-plugin.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/nolint-plugin.cpp (removed)
@@ -1,50 +0,0 @@
-// REQUIRES: static-analyzer
-// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult' -Wunused-variable -I%S/Inputs/nolint 2>&1 | FileCheck %s
-
-#include "trigger_warning.h"
-void I(int& Out) {
- int In;
- A1(In, Out);
-}
-// CHECK-NOT: trigger_warning.h:{{.*}} warning
-// CHECK-NOT: :[[@LINE-4]]:{{.*}} note
-
-class A { A(int i); };
-// CHECK-DAG: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-class B { B(int i); }; // NOLINT
-
-class C { C(int i); }; // NOLINT(for-some-other-check)
-// CHECK-DAG: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-class C1 { C1(int i); }; // NOLINT(*)
-
-class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
-
-class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
-
-class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
-
-class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
-
-void f() {
- int i;
-// CHECK-DAG: :[[@LINE-1]]:7: warning: unused variable 'i' [-Wunused-variable]
-// 31:7: warning: unused variable 'i' [-Wunused-variable]
-// int j; // NOLINT
-// int k; // NOLINT(clang-diagnostic-unused-variable)
-}
-
-#define MACRO(X) class X { X(int i); };
-MACRO(D)
-// CHECK-DAG: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
-MACRO(E) // NOLINT
-
-#define MACRO_NOARG class F { F(int i); };
-MACRO_NOARG // NOLINT
-
-#define MACRO_NOLINT class G { G(int i); }; // NOLINT
-MACRO_NOLINT
-
-#define DOUBLE_MACRO MACRO(H) // NOLINT
-DOUBLE_MACRO
Removed: clang-tools-extra/trunk/test/clang-tidy/nolint.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/nolint.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/nolint.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/nolint.cpp (removed)
@@ -1,51 +0,0 @@
-// REQUIRES: static-analyzer
-// RUN: %check_clang_tidy %s google-explicit-constructor,clang-diagnostic-unused-variable,clang-analyzer-core.UndefinedBinaryOperatorResult %t -- -extra-arg=-Wunused-variable -- -I%S/Inputs/nolint
-
-#include "trigger_warning.h"
-void I(int& Out) {
- int In;
- A1(In, Out);
-}
-// CHECK-MESSAGES-NOT: trigger_warning.h:{{.*}} warning
-// CHECK-MESSAGES-NOT: :[[@LINE-4]]:{{.*}} note
-
-class A { A(int i); };
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-class B { B(int i); }; // NOLINT
-
-class C { C(int i); }; // NOLINT(for-some-other-check)
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-class C1 { C1(int i); }; // NOLINT(*)
-
-class C2 { C2(int i); }; // NOLINT(not-closed-bracket-is-treated-as-skip-all
-
-class C3 { C3(int i); }; // NOLINT(google-explicit-constructor)
-
-class C4 { C4(int i); }; // NOLINT(some-check, google-explicit-constructor)
-
-class C5 { C5(int i); }; // NOLINT without-brackets-skip-all, another-check
-
-void f() {
- int i;
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: unused variable 'i' [clang-diagnostic-unused-variable]
- int j; // NOLINT
- int k; // NOLINT(clang-diagnostic-unused-variable)
-}
-
-#define MACRO(X) class X { X(int i); };
-MACRO(D)
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
-MACRO(E) // NOLINT
-
-#define MACRO_NOARG class F { F(int i); };
-MACRO_NOARG // NOLINT
-
-#define MACRO_NOLINT class G { G(int i); }; // NOLINT
-MACRO_NOLINT
-
-#define DOUBLE_MACRO MACRO(H) // NOLINT
-DOUBLE_MACRO
-
-// CHECK-MESSAGES: Suppressed 13 warnings (13 NOLINT)
Removed: clang-tools-extra/trunk/test/clang-tidy/nolintnextline-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/nolintnextline-plugin.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/nolintnextline-plugin.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/nolintnextline-plugin.cpp (removed)
@@ -1,48 +0,0 @@
-// RUN: c-index-test -test-load-source-reparse 2 all %s -Xclang -add-plugin -Xclang clang-tidy -Xclang -plugin-arg-clang-tidy -Xclang -checks='-*,google-explicit-constructor' 2>&1 | FileCheck %s
-
-class A { A(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE
-class B { B(int i); };
-
-// NOLINTNEXTLINE(for-some-other-check)
-class C { C(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE(*)
-class C1 { C1(int i); };
-
-// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
-class C2 { C2(int i); };
-
-// NOLINTNEXTLINE(google-explicit-constructor)
-class C3 { C3(int i); };
-
-// NOLINTNEXTLINE(some-check, google-explicit-constructor)
-class C4 { C4(int i); };
-
-// NOLINTNEXTLINE without-brackets-skip-all, another-check
-class C5 { C5(int i); };
-
-
-// NOLINTNEXTLINE
-
-class D { D(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE
-//
-class E { E(int i); };
-// CHECK: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-#define MACRO(X) class X { X(int i); };
-MACRO(F)
-// CHECK: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
-// NOLINTNEXTLINE
-MACRO(G)
-
-#define MACRO_NOARG class H { H(int i); };
-// NOLINTNEXTLINE
-MACRO_NOARG
-
Removed: clang-tools-extra/trunk/test/clang-tidy/nolintnextline.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/nolintnextline.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/nolintnextline.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/nolintnextline.cpp (removed)
@@ -1,49 +0,0 @@
-class A { A(int i); };
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE
-class B { B(int i); };
-
-// NOLINTNEXTLINE(for-some-other-check)
-class C { C(int i); };
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE(*)
-class C1 { C1(int i); };
-
-// NOLINTNEXTLINE(not-closed-bracket-is-treated-as-skip-all
-class C2 { C2(int i); };
-
-// NOLINTNEXTLINE(google-explicit-constructor)
-class C3 { C3(int i); };
-
-// NOLINTNEXTLINE(some-check, google-explicit-constructor)
-class C4 { C4(int i); };
-
-// NOLINTNEXTLINE without-brackets-skip-all, another-check
-class C5 { C5(int i); };
-
-
-// NOLINTNEXTLINE
-
-class D { D(int i); };
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-// NOLINTNEXTLINE
-//
-class E { E(int i); };
-// CHECK-MESSAGES: :[[@LINE-1]]:11: warning: single-argument constructors must be marked explicit
-
-#define MACRO(X) class X { X(int i); };
-MACRO(F)
-// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: single-argument constructors must be marked explicit
-// NOLINTNEXTLINE
-MACRO(G)
-
-#define MACRO_NOARG class H { H(int i); };
-// NOLINTNEXTLINE
-MACRO_NOARG
-
-// CHECK-MESSAGES: Suppressed 8 warnings (8 NOLINT)
-
-// RUN: %check_clang_tidy %s google-explicit-constructor %t --
Removed: clang-tools-extra/trunk/test/clang-tidy/nonstandard-file-extension.test
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/nonstandard-file-extension.test?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/nonstandard-file-extension.test (original)
+++ clang-tools-extra/trunk/test/clang-tidy/nonstandard-file-extension.test (removed)
@@ -1,6 +0,0 @@
-// RUN: %check_clang_tidy -assume-filename=const-cast.cpp %s cppcoreguidelines-pro-type-const-cast %t
-
-const int *i;
-int *j;
-void f() { j = const_cast<int *>(i); }
-// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: do not use const_cast [cppcoreguidelines-pro-type-const-cast]
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-arc-and-properties.m (removed)
@@ -1,21 +0,0 @@
-// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t
-
-// This test checks if Objective-C 2.0 (@properties) and
-// Automatic Reference Counting (ARC) are enabled for .m files
-// checked via check_clang_tidy.py.
-
-#if !__has_feature(objc_arc)
-#error Objective-C ARC not enabled as expected
-#endif
-
- at interface Foo
- at property (nonatomic, assign) int shouldDoStuff;
-- (void)nop;
- at end
-
-void fail(Foo *f)
-{
- if(f.shouldDoStuff); [f nop];
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
- // CHECK-FIXES: if(f.shouldDoStuff) [f nop];
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-avoid-nserror-init.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-avoid-nserror-init.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-avoid-nserror-init.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-avoid-nserror-init.m (removed)
@@ -1,12 +0,0 @@
-// RUN: %check_clang_tidy %s objc-avoid-nserror-init %t
- at interface NSError
-+ (instancetype)alloc;
-- (instancetype)init;
- at end
-
- at implementation foo
-- (void)bar {
- NSError *error = [[NSError alloc] init];
- // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use errorWithDomain:code:userInfo: or initWithDomain:code:userInfo: to create a new NSError [objc-avoid-nserror-init]
-}
- at end
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing-custom.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing-custom.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing-custom.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing-custom.m (removed)
@@ -1,39 +0,0 @@
-// RUN: %check_clang_tidy %s objc-forbidden-subclassing %t \
-// RUN: -config='{CheckOptions: \
-// RUN: [{key: objc-forbidden-subclassing.ClassNames, value: "Foo;Quux"}]}' \
-// RUN: --
-
- at interface UIImagePickerController
- at end
-
-// Make sure custom config options replace (not add to) the default list.
- at interface Waldo : UIImagePickerController
-// CHECK-MESSAGES-NOT: :[[@LINE-1]]:12: warning: Objective-C interface 'Waldo' subclasses 'UIImagePickerController', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
-
- at interface Foo
- at end
-
- at interface Bar : Foo
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Objective-C interface 'Bar' subclasses 'Foo', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
-
-// Check subclasses of subclasses.
- at interface Baz : Bar
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Objective-C interface 'Baz' subclasses 'Foo', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
-
- at interface Quux
- at end
-
-// Check that more than one forbidden superclass can be specified.
- at interface Xyzzy : Quux
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Objective-C interface 'Xyzzy' subclasses 'Quux', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
-
- at interface Plugh
- at end
-
- at interface Corge : Plugh
-// CHECK-MESSAGES-NOT: :[[@LINE-1]]:12: warning: Objective-C interface 'Corge' subclasses 'Plugh', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-forbidden-subclassing.m (removed)
@@ -1,21 +0,0 @@
-// RUN: %check_clang_tidy %s objc-forbidden-subclassing %t
-
- at interface UIImagePickerController
- at end
-
- at interface Foo : UIImagePickerController
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Objective-C interface 'Foo' subclasses 'UIImagePickerController', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
-
-// Check subclasses of subclasses.
- at interface Bar : Foo
-// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Objective-C interface 'Bar' subclasses 'UIImagePickerController', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
-
- at interface Baz
- at end
-
-// Make sure innocent subclasses aren't caught by the check.
- at interface Blech : Baz
-// CHECK-MESSAGES-NOT: :[[@LINE-1]]:12: warning: Objective-C interface 'Blech' subclasses 'Baz', which is not intended to be subclassed [objc-forbidden-subclassing]
- at end
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-missing-hash.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-missing-hash.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-missing-hash.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-missing-hash.m (removed)
@@ -1,68 +0,0 @@
-// RUN: %check_clang_tidy %s objc-missing-hash %t
-
-typedef _Bool BOOL;
-#define YES 1
-#define NO 0
-typedef unsigned int NSUInteger;
-typedef void *id;
-
- at interface NSObject
-- (NSUInteger)hash;
-- (BOOL)isEqual:(id)object;
- at end
-
- at interface MissingHash : NSObject
- at end
-
- at implementation MissingHash
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: 'MissingHash' implements -isEqual: without implementing -hash [objc-missing-hash]
-
-- (BOOL)isEqual:(id)object {
- return YES;
-}
-
- at end
-
- at interface HasHash : NSObject
- at end
-
- at implementation HasHash
-
-- (NSUInteger)hash {
- return 0;
-}
-
-- (BOOL)isEqual:(id)object {
- return YES;
-}
-
- at end
-
- at interface NSArray : NSObject
- at end
-
- at interface MayHaveInheritedHash : NSArray
- at end
-
- at implementation MayHaveInheritedHash
-
-- (BOOL)isEqual:(id)object {
- return YES;
-}
-
- at end
-
- at interface AnotherRootClass
- at end
-
- at interface NotDerivedFromNSObject : AnotherRootClass
- at end
-
- at implementation NotDerivedFromNSObject
-
-- (BOOL)isEqual:(id)object {
- return NO;
-}
-
- at end
-
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-no-arc-or-properties.m (removed)
@@ -1,29 +0,0 @@
-// RUN: %check_clang_tidy -std=c99 %s bugprone-suspicious-semicolon %t -- -- -fno-objc-arc -fobjc-abi-version=1
-
-// This test ensures check_clang_tidy.py allows disabling Objective-C ARC and
-// Objective-C 2.0 via passing arguments after -- on the command line.
-//
-// (We could include a test which doesn't pass any arguments after --
-// to check if ARC and ObjC 2.0 are disabled by default, but that test
-// could change behavior based on the default Objective-C runtime for
-// the platform, which would make this test flaky.)
-
-#if __has_feature(objc_arc)
-#error Objective-C ARC unexpectedly enabled even with -fno-objc-arc
-#endif
-
-#ifdef __OBJC2__
-#error Objective-C 2.0 unexpectedly enabled even with -fobjc-abi-version=1
-#endif
-
- at interface Foo
-- (int)shouldDoStuff;
-- (void)nop;
- at end
-
-void fail(Foo *f)
-{
- if([f shouldDoStuff]); [f nop];
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
- // CHECK-FIXES: if([f shouldDoStuff]) [f nop];
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m (removed)
@@ -1,55 +0,0 @@
-// RUN: %check_clang_tidy %s objc-property-declaration %t
- at class CIColor;
- at class NSArray;
- at class NSData;
- at class NSString;
- at class UIViewController;
-
-typedef void *CGColorRef;
-
- at interface Foo
- at property(assign, nonatomic) int NotCamelCase;
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
-// CHECK-FIXES: @property(assign, nonatomic) int notCamelCase;
- at property(assign, nonatomic) int camelCase;
- at property(strong, nonatomic) NSString *URLString;
- at property(strong, nonatomic) NSString *bundleID;
- at property(strong, nonatomic) NSData *RGBABytes;
- at property(strong, nonatomic) UIViewController *notificationsVC;
- at property(strong, nonatomic) NSString *URL_string;
-// CHECK-MESSAGES: :[[@LINE-1]]:40: warning: property name 'URL_string' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
- at property(strong, nonatomic) NSString *supportURLsCamelCase;
- at property(strong, nonatomic) NSString *supportURLCamelCase;
- at property(strong, nonatomic) NSString *VCsPluralToAdd;
- at property(assign, nonatomic) int centerX;
- at property(assign, nonatomic) int enable2GBackgroundFetch;
- at property(assign, nonatomic) int shouldUseCFPreferences;
- at property(assign, nonatomic) int enableGLAcceleration;
- at property(assign, nonatomic) int ID;
- at property(assign, nonatomic) int hasADog;
- at property(nonatomic, readonly) CGColorRef CGColor;
- at property(nonatomic, readonly) CIColor *CIColor;
- at property(nonatomic, copy) NSArray *IDs;
- at end
-
- at interface Foo (Bar)
- at property(assign, nonatomic) int abc_NotCamelCase;
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
- at property(assign, nonatomic) int abCD_camelCase;
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abCD_camelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
-// CHECK-FIXES: @property(assign, nonatomic) int abcd_camelCase;
- at property(assign, nonatomic) int abCD_NotCamelCase;
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abCD_NotCamelCase' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
-// CHECK-FIXES: @property(assign, nonatomic) int abcd_notCamelCase;
- at property(assign, nonatomic) int wrongFormat_;
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'wrongFormat_' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
- at property(strong, nonatomic) NSString *URLStr;
- at property(assign, nonatomic) int abc_camelCase;
- at property(strong, nonatomic) NSString *abc_URL;
- at property(strong, nonatomic) NSString *opac2_sourceComponent;
- at end
-
- at interface Foo ()
- at property(assign, nonatomic) int abc_inClassExtension;
-// CHECK-MESSAGES: :[[@LINE-1]]:34: warning: property name 'abc_inClassExtension' not using lowerCamelCase style or not prefixed in a category, according to the Apple Coding Guidelines [objc-property-declaration]
- at end
\ No newline at end of file
Removed: clang-tools-extra/trunk/test/clang-tidy/objc-super-self.m
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-super-self.m?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/objc-super-self.m (original)
+++ clang-tools-extra/trunk/test/clang-tidy/objc-super-self.m (removed)
@@ -1,86 +0,0 @@
-// RUN: %check_clang_tidy %s objc-super-self %t
-
- at interface NSObject
-- (instancetype)init;
-- (instancetype)self;
- at end
-
- at interface NSObjectDerivedClass : NSObject
- at end
-
- at implementation NSObjectDerivedClass
-
-- (instancetype)init {
- return [super self];
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious invocation of 'self' in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
-// CHECK-FIXES: return [super init];
-}
-
-- (instancetype)initWithObject:(NSObject *)obj {
- self = [super self];
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious invocation of 'self' in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
-// CHECK-FIXES: self = [super init];
- if (self) {
- // ...
- }
- return self;
-}
-
-#define INITIALIZE() [super self]
-
-- (instancetype)initWithObject:(NSObject *)objc a:(int)a {
- return INITIALIZE();
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious invocation of 'self' in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
-// CHECK-FIXES: return INITIALIZE();
-}
-
-#define INITIALIZER_IMPL() return [super self]
-
-- (instancetype)initWithObject:(NSObject *)objc b:(int)b {
- INITIALIZER_IMPL();
-// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: suspicious invocation of 'self' in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
-// CHECK-FIXES: INITIALIZER_IMPL();
-}
-
-#define INITIALIZER_METHOD self
-
-- (instancetype)initWithObject:(NSObject *)objc c:(int)c {
- return [super INITIALIZER_METHOD];
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious invocation of 'self' in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
-// CHECK-FIXES: return [super INITIALIZER_METHOD];
-}
-
-#define RECEIVER super
-
-- (instancetype)initWithObject:(NSObject *)objc d:(int)d {
- return [RECEIVER self];
-// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious invocation of 'self' in initializer; did you mean to invoke a superclass initializer? [objc-super-self]
-// CHECK-FIXES: return [RECEIVER self];
-}
-
-- (instancetype)foo {
- return [super self];
-}
-
-- (instancetype)bar {
- return [self self];
-}
-
- at end
-
- at interface RootClass
-- (instancetype)init;
-- (instancetype)self;
- at end
-
- at interface NotNSObjectDerivedClass : RootClass
- at end
-
- at implementation NotNSObjectDerivedClass
-
-- (instancetype)init {
- return [super self];
-}
-
- at end
-
Removed: clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/openmp-exception-escape.cpp (removed)
@@ -1,132 +0,0 @@
-// RUN: %check_clang_tidy %s openmp-exception-escape %t -- -extra-arg=-fopenmp=libomp -extra-arg=-fexceptions -config="{CheckOptions: [{key: openmp-exception-escape.IgnoredExceptions, value: 'ignored, ignored2'}]}" --
-
-int thrower() {
- throw 42;
-}
-
-class ignored {};
-class ignored2 {};
-namespace std {
-class bad_alloc {};
-} // namespace std
-
-void parallel() {
-#pragma omp parallel
- thrower();
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region
-}
-
-void ignore() {
-#pragma omp parallel
- throw ignored();
-}
-
-void ignore2() {
-#pragma omp parallel
- throw ignored2();
-}
-
-void standalone_directive() {
-#pragma omp taskwait
- throw ignored(); // not structured block
-}
-
-void ignore_alloc() {
-#pragma omp parallel
- throw std::bad_alloc();
-}
-
-void parallel_caught() {
-#pragma omp parallel
- {
- try {
- thrower();
- } catch (...) {
- }
- }
-}
-
-void for_header(const int a) {
- // Only the body of the loop counts.
-#pragma omp for
- for (int i = 0; i < thrower(); i++)
- ;
-}
-
-void forloop(const int a) {
-#pragma omp for
- for (int i = 0; i < a; i++)
- thrower();
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region
-}
-
-void parallel_forloop(const int a) {
-#pragma omp parallel
- {
-#pragma omp for
- for (int i = 0; i < a; i++)
- thrower();
- thrower();
- // CHECK-MESSAGES: :[[@LINE-5]]:3: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region
- // CHECK-MESSAGES: :[[@LINE-3]]:7: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region
- }
-}
-
-void parallel_forloop_caught(const int a) {
-#pragma omp parallel
- {
-#pragma omp for
- for (int i = 0; i < a; i++) {
- try {
- thrower();
- } catch (...) {
- }
- }
- thrower();
- // CHECK-MESSAGES: :[[@LINE-9]]:3: warning: an exception thrown inside of the OpenMP 'parallel' region is not caught in that same region
- }
-}
-
-void parallel_caught_forloop(const int a) {
-#pragma omp parallel
- {
-#pragma omp for
- for (int i = 0; i < a; i++)
- thrower();
- try {
- thrower();
- } catch (...) {
- }
- // CHECK-MESSAGES: :[[@LINE-5]]:7: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region
- }
-}
-
-void parallel_outercaught_forloop(const int a) {
-#pragma omp parallel
- {
- try {
-#pragma omp for
- for (int i = 0; i < a; i++)
- thrower();
- thrower();
- } catch (...) {
- }
- // CHECK-MESSAGES: :[[@LINE-4]]:9: warning: an exception thrown inside of the OpenMP 'for' region is not caught in that same region
- }
-}
-
-void parallel_outercaught_forloop_caught(const int a) {
-#pragma omp parallel
- {
- try {
-#pragma omp for
- for (int i = 0; i < a; i++) {
- try {
- thrower();
- } catch (...) {
- }
- }
- } catch (...) {
- }
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/openmp-use-default-none.cpp (removed)
@@ -1,160 +0,0 @@
-// RUN: %check_clang_tidy %s openmp-use-default-none %t -- -- -fopenmp=libomp -fopenmp-version=40
-// RUN: %check_clang_tidy -std=c11 %s openmp-use-default-none %t -- -- -x c -fopenmp=libomp -fopenmp-version=40
-
-//----------------------------------------------------------------------------//
-// Null cases.
-//----------------------------------------------------------------------------//
-
-// 'for' directive can not have 'default' clause, no diagnostics.
-void n0(const int a) {
-#pragma omp for
- for (int b = 0; b < a; b++)
- ;
-}
-
-//----------------------------------------------------------------------------//
-// Single-directive positive cases.
-//----------------------------------------------------------------------------//
-
-// 'parallel' directive.
-
-// 'parallel' directive can have 'default' clause, but said clause is not
-// specified, diagnosed.
-void p0_0() {
-#pragma omp parallel
- ;
- // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' does not specify 'default' clause, consider specifying 'default(none)' clause
-}
-
-// 'parallel' directive can have 'default' clause, and said clause specified,
-// with 'none' kind, all good.
-void p0_1() {
-#pragma omp parallel default(none)
- ;
-}
-
-// 'parallel' directive can have 'default' clause, and said clause specified,
-// but with 'shared' kind, which is not 'none', diagnose.
-void p0_2() {
-#pragma omp parallel default(shared)
- ;
- // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'parallel' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
- // CHECK-NOTES: :[[@LINE-3]]:22: note: existing 'default' clause specified here
-}
-
-// 'task' directive.
-
-// 'task' directive can have 'default' clause, but said clause is not
-// specified, diagnosed.
-void p1_0() {
-#pragma omp task
- ;
- // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' does not specify 'default' clause, consider specifying 'default(none)' clause
-}
-
-// 'task' directive can have 'default' clause, and said clause specified,
-// with 'none' kind, all good.
-void p1_1() {
-#pragma omp task default(none)
- ;
-}
-
-// 'task' directive can have 'default' clause, and said clause specified,
-// but with 'shared' kind, which is not 'none', diagnose.
-void p1_2() {
-#pragma omp task default(shared)
- ;
- // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'task' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
- // CHECK-NOTES: :[[@LINE-3]]:18: note: existing 'default' clause specified here
-}
-
-// 'teams' directive. (has to be inside of 'target' directive)
-
-// 'teams' directive can have 'default' clause, but said clause is not
-// specified, diagnosed.
-void p2_0() {
-#pragma omp target
-#pragma omp teams
- ;
- // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' does not specify 'default' clause, consider specifying 'default(none)' clause
-}
-
-// 'teams' directive can have 'default' clause, and said clause specified,
-// with 'none' kind, all good.
-void p2_1() {
-#pragma omp target
-#pragma omp teams default(none)
- ;
-}
-
-// 'teams' directive can have 'default' clause, and said clause specified,
-// but with 'shared' kind, which is not 'none', diagnose.
-void p2_2() {
-#pragma omp target
-#pragma omp teams default(shared)
- ;
- // CHECK-NOTES: :[[@LINE-2]]:1: warning: OpenMP directive 'teams' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
- // CHECK-NOTES: :[[@LINE-3]]:19: note: existing 'default' clause specified here
-}
-
-// 'taskloop' directive.
-
-// 'taskloop' directive can have 'default' clause, but said clause is not
-// specified, diagnosed.
-void p3_0(const int a) {
-#pragma omp taskloop
- for (int b = 0; b < a; b++)
- ;
- // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' does not specify 'default' clause, consider specifying 'default(none)' clause
-}
-
-// 'taskloop' directive can have 'default' clause, and said clause specified,
-// with 'none' kind, all good.
-void p3_1(const int a) {
-#pragma omp taskloop default(none) shared(a)
- for (int b = 0; b < a; b++)
- ;
-}
-
-// 'taskloop' directive can have 'default' clause, and said clause specified,
-// but with 'shared' kind, which is not 'none', diagnose.
-void p3_2(const int a) {
-#pragma omp taskloop default(shared)
- for (int b = 0; b < a; b++)
- ;
- // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'taskloop' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
- // CHECK-NOTES: :[[@LINE-4]]:22: note: existing 'default' clause specified here
-}
-
-//----------------------------------------------------------------------------//
-// Combined directives.
-// Let's not test every single possible permutation/combination of directives,
-// but just *one* combined directive. The rest will be the same.
-//----------------------------------------------------------------------------//
-
-// 'parallel' directive can have 'default' clause, but said clause is not
-// specified, diagnosed.
-void p4_0(const int a) {
-#pragma omp parallel for
- for (int b = 0; b < a; b++)
- ;
- // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'parallel for' does not specify 'default' clause, consider specifying 'default(none)' clause
-}
-
-// 'parallel' directive can have 'default' clause, and said clause specified,
-// with 'none' kind, all good.
-void p4_1(const int a) {
-#pragma omp parallel for default(none) shared(a)
- for (int b = 0; b < a; b++)
- ;
-}
-
-// 'parallel' directive can have 'default' clause, and said clause specified,
-// but with 'shared' kind, which is not 'none', diagnose.
-void p4_2(const int a) {
-#pragma omp parallel for default(shared)
- for (int b = 0; b < a; b++)
- ;
- // CHECK-NOTES: :[[@LINE-3]]:1: warning: OpenMP directive 'parallel for' specifies 'default(shared)' clause, consider using 'default(none)' clause instead
- // CHECK-NOTES: :[[@LINE-4]]:26: note: existing 'default' clause specified here
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/overlapping.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/overlapping.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/overlapping.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/overlapping.cpp (removed)
@@ -1,10 +0,0 @@
-// RUN: clang-tidy -checks=-*,llvm-include-order -header-filter=.* %s \
-// RUN: -- -isystem %S/Inputs/Headers -I %S/Inputs/overlapping | \
-// RUN: not grep "note: this fix will not be applied because it overlaps with another fix"
-
-#include <s.h>
-#include "o.h"
-
-// Test that clang-tidy takes into account in which file we are doing the
-// replacements to determine if they overlap or not. In the file "o.h" there is
-// a similar error at the same file offset, but they do not overlap.
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-faster-string-find.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-faster-string-find.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-faster-string-find.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-faster-string-find.cpp (removed)
@@ -1,110 +0,0 @@
-// RUN: %check_clang_tidy %s performance-faster-string-find %t -- \
-// RUN: -config="{CheckOptions: \
-// RUN: [{key: performance-faster-string-find.StringLikeClasses, \
-// RUN: value: 'std::basic_string; ::llvm::StringRef;'}]}" --
-
-namespace std {
-template <typename Char>
-struct basic_string {
- int find(const Char *, int = 0) const;
- int find(const Char *, int, int) const;
- int rfind(const Char *) const;
- int find_first_of(const Char *) const;
- int find_first_not_of(const Char *) const;
- int find_last_of(const Char *) const;
- int find_last_not_of(const Char *) const;
-};
-
-typedef basic_string<char> string;
-typedef basic_string<wchar_t> wstring;
-} // namespace std
-
-namespace llvm {
-struct StringRef {
- int find(const char *) const;
-};
-} // namespace llvm
-
-struct NotStringRef {
- int find(const char *);
-};
-
-void StringFind() {
- std::string Str;
-
- Str.find("a");
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal consisting of a single character; consider using the more effective overload accepting a character [performance-faster-string-find]
- // CHECK-FIXES: Str.find('a');
-
- // Works with the pos argument.
- Str.find("a", 1);
- // CHECK-MESSAGES: [[@LINE-1]]:12: warning: 'find' called with a string literal
- // CHECK-FIXES: Str.find('a', 1);
-
- // Doens't work with strings smaller or larger than 1 char.
- Str.find("");
- Str.find("ab");
-
- // Doesn't do anything with the 3 argument overload.
- Str.find("a", 1, 1);
-
- // Other methods that can also be replaced
- Str.rfind("a");
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'rfind' called with a string literal
- // CHECK-FIXES: Str.rfind('a');
- Str.find_first_of("a");
- // CHECK-MESSAGES: [[@LINE-1]]:21: warning: 'find_first_of' called with a string
- // CHECK-FIXES: Str.find_first_of('a');
- Str.find_first_not_of("a");
- // CHECK-MESSAGES: [[@LINE-1]]:25: warning: 'find_first_not_of' called with a
- // CHECK-FIXES: Str.find_first_not_of('a');
- Str.find_last_of("a");
- // CHECK-MESSAGES: [[@LINE-1]]:20: warning: 'find_last_of' called with a string
- // CHECK-FIXES: Str.find_last_of('a');
- Str.find_last_not_of("a");
- // CHECK-MESSAGES: [[@LINE-1]]:24: warning: 'find_last_not_of' called with a
- // CHECK-FIXES: Str.find_last_not_of('a');
-
- // std::wstring should work.
- std::wstring WStr;
- WStr.find(L"n");
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'find' called with a string literal
- // CHECK-FIXES: Str.find(L'n');
- // Even with unicode that fits in one wide char.
- WStr.find(L"\x3A9");
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: 'find' called with a string literal
- // CHECK-FIXES: Str.find(L'\x3A9');
-
- // Also with other types, but only if it was specified in the options.
- llvm::StringRef sr;
- sr.find("x");
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: 'find' called with a string literal
- // CHECK-FIXES: sr.find('x');
- NotStringRef nsr;
- nsr.find("x");
-}
-
-
-template <typename T>
-int FindTemplateDependant(T value) {
- return value.find("A");
-}
-template <typename T>
-int FindTemplateNotDependant(T pos) {
- return std::string().find("A", pos);
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: 'find' called with a string literal
- // CHECK-FIXES: return std::string().find('A', pos);
-}
-
-int FindStr() {
- return FindTemplateDependant(std::string()) + FindTemplateNotDependant(1);
-}
-
-#define STR_MACRO(str) str.find("A")
-#define POS_MACRO(pos) std::string().find("A",pos)
-
-int Macros() {
- return STR_MACRO(std::string()) + POS_MACRO(1);
- // CHECK-MESSAGES: [[@LINE-1]]:10: warning: 'find' called with a string literal
- // CHECK-MESSAGES: [[@LINE-2]]:37: warning: 'find' called with a string literal
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-allowed-types.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-allowed-types.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-allowed-types.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-allowed-types.cpp (removed)
@@ -1,126 +0,0 @@
-// RUN: %check_clang_tidy %s performance-for-range-copy %t -- \
-// RUN: -config="{CheckOptions: [{key: performance-for-range-copy.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" \
-// RUN: -- -fno-delayed-template-parsing
-
-template <typename T>
-struct Iterator {
- void operator++() {}
- const T& operator*() {
- static T* TT = new T();
- return *TT;
- }
- bool operator!=(const Iterator &) { return false; }
- typedef const T& const_reference;
-};
-template <typename T>
-struct View {
- T begin() { return T(); }
- T begin() const { return T(); }
- T end() { return T(); }
- T end() const { return T(); }
- typedef typename T::const_reference const_reference;
-};
-
-struct SmartPointer {
- ~SmartPointer();
-};
-
-struct smart_pointer {
- ~smart_pointer();
-};
-
-struct SmartPtr {
- ~SmartPtr();
-};
-
-struct smart_ptr {
- ~smart_ptr();
-};
-
-struct SmartReference {
- ~SmartReference();
-};
-
-struct smart_reference {
- ~smart_reference();
-};
-
-struct SmartRef {
- ~SmartRef();
-};
-
-struct smart_ref {
- ~smart_ref();
-};
-
-struct OtherType {
- ~OtherType();
-};
-
-template <typename T> struct SomeComplexTemplate {
- ~SomeComplexTemplate();
-};
-
-typedef SomeComplexTemplate<int> NotTooComplexRef;
-
-void negativeSmartPointer() {
- for (auto P : View<Iterator<SmartPointer>>()) {
- auto P2 = P;
- }
-}
-
-void negative_smart_pointer() {
- for (auto p : View<Iterator<smart_pointer>>()) {
- auto p2 = p;
- }
-}
-
-void negativeSmartPtr() {
- for (auto P : View<Iterator<SmartPtr>>()) {
- auto P2 = P;
- }
-}
-
-void negative_smart_ptr() {
- for (auto p : View<Iterator<smart_ptr>>()) {
- auto p2 = p;
- }
-}
-
-void negativeSmartReference() {
- for (auto R : View<Iterator<SmartReference>>()) {
- auto R2 = R;
- }
-}
-
-void negative_smart_reference() {
- for (auto r : View<Iterator<smart_reference>>()) {
- auto r2 = r;
- }
-}
-
-void negativeSmartRef() {
- for (auto R : View<Iterator<SmartRef>>()) {
- auto R2 = R;
- }
-}
-
-void negative_smart_ref() {
- for (auto r : View<Iterator<smart_ref>>()) {
- auto r2 = r;
- }
-}
-
-void positiveOtherType() {
- for (auto O : View<Iterator<OtherType>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& O : View<Iterator<OtherType>>()) {
- auto O2 = O;
- }
-}
-
-void negativeNotTooComplexRef() {
- for (NotTooComplexRef R : View<Iterator<NotTooComplexRef>>()) {
- auto R2 = R;
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-warn-on-all-auto-copies.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-warn-on-all-auto-copies.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-warn-on-all-auto-copies.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy-warn-on-all-auto-copies.cpp (removed)
@@ -1,40 +0,0 @@
-// RUN: %check_clang_tidy %s performance-for-range-copy %t -- \
-// RUN: -config="{CheckOptions: [{key: "performance-for-range-copy.WarnOnAllAutoCopies", value: 1}]}"
-
-template <typename T>
-struct Iterator {
- void operator++() {}
- const T& operator*() {
- static T* TT = new T();
- return *TT;
- }
- bool operator!=(const Iterator &) { return false; }
-};
-template <typename T>
-struct View {
- T begin() { return T(); }
- T begin() const { return T(); }
- T end() { return T(); }
- T end() const { return T(); }
-};
-
-struct S {
- S();
- S(const S &);
- ~S();
- S &operator=(const S &);
-};
-
-void NegativeLoopVariableNotAuto() {
- for (S S1 : View<Iterator<S>>()) {
- S* S2 = &S1;
- }
-}
-
-void PositiveTriggeredForAutoLoopVariable() {
- for (auto S1 : View<Iterator<S>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: the loop variable's type is not a reference type; this creates a copy in each iteration; consider making this a reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& S1 : View<Iterator<S>>()) {
- S* S2 = &S1;
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-for-range-copy.cpp (removed)
@@ -1,272 +0,0 @@
-// RUN: %check_clang_tidy %s performance-for-range-copy %t -- -- -fno-delayed-template-parsing
-
-namespace std {
-
-template <typename _Tp>
-struct remove_reference { typedef _Tp type; };
-template <typename _Tp>
-struct remove_reference<_Tp&> { typedef _Tp type; };
-template <typename _Tp>
-struct remove_reference<_Tp&&> { typedef _Tp type; };
-
-template <typename _Tp>
-constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
- return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
-}
-
-} // std
-
-template <typename T>
-struct Iterator {
- void operator++() {}
- const T& operator*() {
- static T* TT = new T();
- return *TT;
- }
- bool operator!=(const Iterator &) { return false; }
- typedef const T& const_reference;
-};
-template <typename T>
-struct View {
- T begin() { return T(); }
- T begin() const { return T(); }
- T end() { return T(); }
- T end() const { return T(); }
- typedef typename T::const_reference const_reference;
-};
-
-struct ConstructorConvertible {
-};
-
-struct S {
- S();
- S(const S &);
- S(const ConstructorConvertible&) {}
- ~S();
- S &operator=(const S &);
-};
-
-struct Convertible {
- operator S() const {
- return S();
- }
-};
-
-void negativeConstReference() {
- for (const S &S1 : View<Iterator<S>>()) {
- }
-}
-
-void negativeUserDefinedConversion() {
- Convertible C[0];
- for (const S &S1 : C) {
- }
-}
-
-void negativeImplicitConstructorConversion() {
- ConstructorConvertible C[0];
- for (const S &S1 : C) {
- }
-}
-
-template <typename T>
-void uninstantiated() {
- for (const S S1 : View<Iterator<S>>()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is not a reference type; this creates a copy in each iteration; consider making this a reference [performance-for-range-copy]
- // CHECK-FIXES: {{^}} for (const S& S1 : View<Iterator<S>>()) {}
-
- // Don't warn on dependent types.
- for (const T t1 : View<Iterator<T>>()) {
- }
-}
-
-template <typename T>
-void instantiated() {
- for (const S S2 : View<Iterator<S>>()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is {{.*}}
- // CHECK-FIXES: {{^}} for (const S& S2 : View<Iterator<S>>()) {}
-
- for (const T T2 : View<Iterator<T>>()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:16: warning: the loop variable's type is {{.*}}
- // CHECK-FIXES: {{^}} for (const T& T2 : View<Iterator<T>>()) {}
-}
-
-template <typename T>
-void instantiatedNegativeTypedefConstReference() {
- for (typename T::const_reference T2 : T()) {
- S S1 = T2;
- }
-}
-
-void f() {
- instantiated<int>();
- instantiated<S>();
- instantiatedNegativeTypedefConstReference<View<Iterator<S>>>();
-}
-
-struct Mutable {
- Mutable() {}
- Mutable(const Mutable &) = default;
- Mutable(Mutable&&) = default;
- Mutable(const Mutable &, const Mutable &) {}
- void setBool(bool B) {}
- bool constMethod() const {
- return true;
- }
- Mutable& operator[](int I) {
- return *this;
- }
- bool operator==(const Mutable &Other) const {
- return true;
- }
- ~Mutable() {}
-};
-
-struct Point {
- ~Point() {}
- int x, y;
-};
-
-Mutable& operator<<(Mutable &Out, bool B) {
- Out.setBool(B);
- return Out;
-}
-
-bool operator!=(const Mutable& M1, const Mutable& M2) {
- return false;
-}
-
-void use(const Mutable &M);
-void use(int I);
-void useTwice(const Mutable &M1, const Mutable &M2);
-void useByValue(Mutable M);
-void useByConstValue(const Mutable M);
-void mutate(Mutable *M);
-void mutate(Mutable &M);
-void onceConstOnceMutated(const Mutable &M1, Mutable &M2);
-
-void negativeVariableIsMutated() {
- for (auto M : View<Iterator<Mutable>>()) {
- mutate(M);
- }
- for (auto M : View<Iterator<Mutable>>()) {
- mutate(&M);
- }
- for (auto M : View<Iterator<Mutable>>()) {
- M.setBool(true);
- }
-}
-
-void negativeOnceConstOnceMutated() {
- for (auto M : View<Iterator<Mutable>>()) {
- onceConstOnceMutated(M, M);
- }
-}
-
-void negativeVarIsMoved() {
- for (auto M : View<Iterator<Mutable>>()) {
- auto Moved = std::move(M);
- }
-}
-
-void negativeNonConstOperatorIsInvoked() {
- for (auto NonConstOperatorInvokee : View<Iterator<Mutable>>()) {
- auto& N = NonConstOperatorInvokee[0];
- }
-}
-
-void negativeNonConstNonMemberOperatorInvoked() {
- for (auto NonConstOperatorInvokee : View<Iterator<Mutable>>()) {
- NonConstOperatorInvokee << true;
- }
-}
-
-void negativeConstCheapToCopy() {
- for (const int I : View<Iterator<int>>()) {
- }
-}
-
-void negativeConstCheapToCopyTypedef() {
- typedef const int ConstInt;
- for (ConstInt C : View<Iterator<ConstInt>>()) {
- }
-}
-
-void negativeCheapToCopy() {
- for (int I : View<Iterator<int>>()) {
- use(I);
- }
-}
-
-void negativeCheapToCopyTypedef() {
- typedef int Int;
- for (Int I : View<Iterator<Int>>()) {
- use(I);
- }
-}
-
-void positiveOnlyConstMethodInvoked() {
- for (auto M : View<Iterator<Mutable>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& M : View<Iterator<Mutable>>()) {
- M.constMethod();
- }
-}
-
-void positiveOnlyUsedAsConstArguments() {
- for (auto UsedAsConst : View<Iterator<Mutable>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& UsedAsConst : View<Iterator<Mutable>>()) {
- use(UsedAsConst);
- useTwice(UsedAsConst, UsedAsConst);
- useByValue(UsedAsConst);
- useByConstValue(UsedAsConst);
- }
-}
-
-void positiveOnlyAccessedFieldAsConst() {
- for (auto UsedAsConst : View<Iterator<Point>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& UsedAsConst : View<Iterator<Point>>()) {
- use(UsedAsConst.x);
- use(UsedAsConst.y);
- }
-}
-
-void positiveOnlyUsedInCopyConstructor() {
- for (auto A : View<Iterator<Mutable>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& A : View<Iterator<Mutable>>()) {
- Mutable Copy = A;
- Mutable Copy2(A);
- }
-}
-
-void positiveTwoConstConstructorArgs() {
- for (auto A : View<Iterator<Mutable>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& A : View<Iterator<Mutable>>()) {
- Mutable Copy(A, A);
- }
-}
-
-void PositiveConstMemberOperatorInvoked() {
- for (auto ConstOperatorInvokee : View<Iterator<Mutable>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& ConstOperatorInvokee : View<Iterator<Mutable>>()) {
- bool result = ConstOperatorInvokee == Mutable();
- }
-}
-
-void PositiveConstNonMemberOperatorInvoked() {
- for (auto ConstOperatorInvokee : View<Iterator<Mutable>>()) {
- // CHECK-MESSAGES: [[@LINE-1]]:13: warning: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy]
- // CHECK-FIXES: for (const auto& ConstOperatorInvokee : View<Iterator<Mutable>>()) {
- bool result = ConstOperatorInvokee != Mutable();
- }
-}
-
-void IgnoreLoopVariableNotUsedInLoopBody() {
- for (auto _ : View<Iterator<S>>()) {
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-implicit-conversion-in-loop.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-implicit-conversion-in-loop.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-implicit-conversion-in-loop.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-implicit-conversion-in-loop.cpp (removed)
@@ -1,197 +0,0 @@
-// RUN: %check_clang_tidy %s performance-implicit-conversion-in-loop %t
-
-// ---------- Classes used in the tests ----------
-
-// Iterator returning by value.
-template <typename T>
-struct Iterator {
- void operator++();
- T operator*();
- bool operator!=(const Iterator& other);
-};
-
-// Iterator returning by reference.
-template <typename T>
-struct RefIterator {
- void operator++();
- T& operator*();
- bool operator!=(const RefIterator& other);
-};
-
-// The template argument is an iterator type, and a view is an object you can
-// run a for loop on.
-template <typename T>
-struct View {
- T begin();
- T end();
-};
-
-// With this class, the implicit conversion is a call to the (implicit)
-// constructor of the class.
-template <typename T>
-class ImplicitWrapper {
- public:
- // Implicit!
- ImplicitWrapper(const T& t);
-};
-
-// With this class, the implicit conversion is a call to the conversion
-// operators of SimpleClass and ComplexClass.
-template <typename T>
-class OperatorWrapper {
- public:
- OperatorWrapper() = delete;
-};
-
-struct SimpleClass {
- int foo;
- operator OperatorWrapper<SimpleClass>();
-};
-
-// The materialize expression is not the same when the class has a destructor,
-// so we make sure we cover that case too.
-class ComplexClass {
- public:
- ComplexClass();
- ~ComplexClass();
- operator OperatorWrapper<ComplexClass>();
-};
-
-typedef View<Iterator<SimpleClass>> SimpleView;
-typedef View<RefIterator<SimpleClass>> SimpleRefView;
-typedef View<Iterator<ComplexClass>> ComplexView;
-typedef View<RefIterator<ComplexClass>> ComplexRefView;
-
-// ---------- The test themselves ----------
-// For each test we do, in the same order, const ref, non const ref, const
-// value, non const value.
-
-void SimpleClassIterator() {
- for (const SimpleClass& foo : SimpleView()) {}
- // This line does not compile because a temporary cannot be assigned to a non
- // const reference.
- // for (SimpleClass& foo : SimpleView()) {}
- for (const SimpleClass foo : SimpleView()) {}
- for (SimpleClass foo : SimpleView()) {}
-}
-
-void SimpleClassRefIterator() {
- for (const SimpleClass& foo : SimpleRefView()) {}
- for (SimpleClass& foo : SimpleRefView()) {}
- for (const SimpleClass foo : SimpleRefView()) {}
- for (SimpleClass foo : SimpleRefView()) {}
-}
-
-void ComplexClassIterator() {
- for (const ComplexClass& foo : ComplexView()) {}
- // for (ComplexClass& foo : ComplexView()) {}
- for (const ComplexClass foo : ComplexView()) {}
- for (ComplexClass foo : ComplexView()) {}
-}
-
-void ComplexClassRefIterator() {
- for (const ComplexClass& foo : ComplexRefView()) {}
- for (ComplexClass& foo : ComplexRefView()) {}
- for (const ComplexClass foo : ComplexRefView()) {}
- for (ComplexClass foo : ComplexRefView()) {}
-}
-
-void ImplicitSimpleClassIterator() {
- for (const ImplicitWrapper<SimpleClass>& foo : SimpleView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the loop variable 'foo' is different from the one returned by the iterator and generates an implicit conversion; you can either change the type to the matching one ('const SimpleClass &' but 'const auto&' is always a valid option) or remove the reference to make it explicit that you are creating a new value [performance-implicit-conversion-in-loop]
- // for (ImplicitWrapper<SimpleClass>& foo : SimpleView()) {}
- for (const ImplicitWrapper<SimpleClass> foo : SimpleView()) {}
- for (ImplicitWrapper<SimpleClass> foo : SimpleView()) {}
-}
-
-void ImplicitSimpleClassRefIterator() {
- for (const ImplicitWrapper<SimpleClass>& foo : SimpleRefView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const SimpleClass &'.*}}
- // for (ImplicitWrapper<SimpleClass>& foo : SimpleRefView()) {}
- for (const ImplicitWrapper<SimpleClass> foo : SimpleRefView()) {}
- for (ImplicitWrapper<SimpleClass> foo : SimpleRefView()) {}
-}
-
-void ImplicitSimpleClassArray() {
- SimpleClass array[5];
- for (const ImplicitWrapper<SimpleClass>& foo : array) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const SimpleClass &'.*}}
- // for (ImplicitWrapper<SimpleClass>& foo : array) {}
- for (const ImplicitWrapper<SimpleClass> foo : array) {}
- for (ImplicitWrapper<SimpleClass> foo : array) {}
-}
-
-void ImplicitComplexClassIterator() {
- for (const ImplicitWrapper<ComplexClass>& foo : ComplexView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const ComplexClass &'.*}}
- // for (ImplicitWrapper<ComplexClass>& foo : ComplexView()) {}
- for (const ImplicitWrapper<ComplexClass> foo : ComplexView()) {}
- for (ImplicitWrapper<ComplexClass> foo : ComplexView()) {}
-}
-
-void ImplicitComplexClassRefIterator() {
- ComplexClass array[5];
- for (const ImplicitWrapper<ComplexClass>& foo : array) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const ComplexClass &'.*}}
- // for (ImplicitWrapper<ComplexClass>& foo : array) {}
- for (const ImplicitWrapper<ComplexClass> foo : array) {}
- for (ImplicitWrapper<ComplexClass> foo : array) {}
-}
-
-void ImplicitComplexClassArray() {
- for (const ImplicitWrapper<ComplexClass>& foo : ComplexRefView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const ComplexClass &'.*}}
- // for (ImplicitWrapper<ComplexClass>& foo : ComplexRefView()) {}
- for (const ImplicitWrapper<ComplexClass> foo : ComplexRefView()) {}
- for (ImplicitWrapper<ComplexClass> foo : ComplexRefView()) {}
-}
-
-void OperatorSimpleClassIterator() {
- for (const OperatorWrapper<SimpleClass>& foo : SimpleView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const SimpleClass &'.*}}
- // for (OperatorWrapper<SimpleClass>& foo : SimpleView()) {}
- for (const OperatorWrapper<SimpleClass> foo : SimpleView()) {}
- for (OperatorWrapper<SimpleClass> foo : SimpleView()) {}
-}
-
-void OperatorSimpleClassRefIterator() {
- for (const OperatorWrapper<SimpleClass>& foo : SimpleRefView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const SimpleClass &'.*}}
- // for (OperatorWrapper<SimpleClass>& foo : SimpleRefView()) {}
- for (const OperatorWrapper<SimpleClass> foo : SimpleRefView()) {}
- for (OperatorWrapper<SimpleClass> foo : SimpleRefView()) {}
-}
-
-void OperatorSimpleClassArray() {
- SimpleClass array[5];
- for (const OperatorWrapper<SimpleClass>& foo : array) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const SimpleClass &'.*}}
- // for (OperatorWrapper<SimpleClass>& foo : array) {}
- for (const OperatorWrapper<SimpleClass> foo : array) {}
- for (OperatorWrapper<SimpleClass> foo : array) {}
-}
-
-void OperatorComplexClassIterator() {
- for (const OperatorWrapper<ComplexClass>& foo : ComplexView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const ComplexClass &'.*}}
- // for (OperatorWrapper<ComplexClass>& foo : ComplexView()) {}
- for (const OperatorWrapper<ComplexClass> foo : ComplexView()) {}
- for (OperatorWrapper<ComplexClass> foo : ComplexView()) {}
-}
-
-void OperatorComplexClassRefIterator() {
- for (const OperatorWrapper<ComplexClass>& foo : ComplexRefView()) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const ComplexClass &'.*}}
- // for (OperatorWrapper<ComplexClass>& foo : ComplexRefView()) {}
- for (const OperatorWrapper<ComplexClass> foo : ComplexRefView()) {}
- for (OperatorWrapper<ComplexClass> foo : ComplexRefView()) {}
-}
-
-void OperatorComplexClassArray() {
- ComplexClass array[5];
- for (const OperatorWrapper<ComplexClass>& foo : array) {}
- // CHECK-MESSAGES: [[@LINE-1]]:{{[0-9]*}}: warning: the type of the{{.*'const ComplexClass &'.*}}
- // for (OperatorWrapper<ComplexClass>& foo : array) {}
- for (const OperatorWrapper<ComplexClass> foo : array) {}
- for (OperatorWrapper<ComplexClass> foo : array) {}
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-algorithm.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-algorithm.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-algorithm.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-algorithm.cpp (removed)
@@ -1,167 +0,0 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s performance-inefficient-algorithm %t
-// FIXME: Fix the checker to work in C++17 mode.
-
-namespace std {
-template <typename T> struct less {
- bool operator()(const T &lhs, const T &rhs) { return lhs < rhs; }
-};
-
-template <typename T> struct greater {
- bool operator()(const T &lhs, const T &rhs) { return lhs > rhs; }
-};
-
-struct iterator_type {};
-
-template <typename K, typename Cmp = less<K>> struct set {
- typedef iterator_type iterator;
- iterator find(const K &k);
- unsigned count(const K &k);
-
- iterator begin();
- iterator end();
- iterator begin() const;
- iterator end() const;
-};
-
-struct other_iterator_type {};
-
-template <typename K, typename V, typename Cmp = less<K>> struct map {
- typedef other_iterator_type iterator;
- iterator find(const K &k);
- unsigned count(const K &k);
-
- iterator begin();
- iterator end();
- iterator begin() const;
- iterator end() const;
-};
-
-template <typename K, typename V> struct multimap : map<K, V> {};
-template <typename K> struct unordered_set : set<K> {};
-template <typename K, typename V> struct unordered_map : map<K, V> {};
-template <typename K> struct unordered_multiset : set<K> {};
-template <typename K, typename V> struct unordered_multimap : map<K, V> {};
-
-template <typename K, typename Cmp = less<K>> struct multiset : set<K, Cmp> {};
-
-template <typename FwIt, typename K>
-FwIt find(FwIt, FwIt end, const K &) { return end; }
-
-template <typename FwIt, typename K, typename Cmp>
-FwIt find(FwIt, FwIt end, const K &, Cmp) { return end; }
-
-template <typename FwIt, typename Pred>
-FwIt find_if(FwIt, FwIt end, Pred) { return end; }
-
-template <typename FwIt, typename K>
-unsigned count(FwIt, FwIt, const K &) { return 0; }
-
-template <typename FwIt, typename K>
-FwIt lower_bound(FwIt, FwIt end, const K &) { return end; }
-
-template <typename FwIt, typename K, typename Ord>
-FwIt lower_bound(FwIt, FwIt end, const K &, Ord) { return end; }
-}
-
-#define FIND_IN_SET(x) find(x.begin(), x.end(), 10)
-// CHECK-FIXES: #define FIND_IN_SET(x) find(x.begin(), x.end(), 10)
-
-template <typename T> void f(const T &t) {
- std::set<int> s;
- find(s.begin(), s.end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}s.find(46);{{$}}
-
- find(t.begin(), t.end(), 46);
- // CHECK-FIXES: {{^ }}find(t.begin(), t.end(), 46);{{$}}
-}
-
-int main() {
- std::set<int> s;
- auto it = std::find(s.begin(), s.end(), 43);
- // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: this STL algorithm call should be replaced with a container method [performance-inefficient-algorithm]
- // CHECK-FIXES: {{^ }}auto it = s.find(43);{{$}}
- auto c = count(s.begin(), s.end(), 43);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}auto c = s.count(43);{{$}}
-
-#define SECOND(x, y, z) y
- SECOND(q,std::count(s.begin(), s.end(), 22),w);
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}SECOND(q,s.count(22),w);{{$}}
-
- it = find_if(s.begin(), s.end(), [](int) { return false; });
-
- std::multiset<int> ms;
- find(ms.begin(), ms.end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}ms.find(46);{{$}}
-
- const std::multiset<int> &msref = ms;
- find(msref.begin(), msref.end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}msref.find(46);{{$}}
-
- std::multiset<int> *msptr = &ms;
- find(msptr->begin(), msptr->end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}msptr->find(46);{{$}}
-
- it = std::find(s.begin(), s.end(), 43, std::greater<int>());
- // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: different comparers used in the algorithm and the container [performance-inefficient-algorithm]
-
- FIND_IN_SET(s);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}FIND_IN_SET(s);{{$}}
-
- f(s);
-
- std::unordered_set<int> us;
- lower_bound(us.begin(), us.end(), 10);
- // CHECK-FIXES: {{^ }}lower_bound(us.begin(), us.end(), 10);{{$}}
- find(us.begin(), us.end(), 10);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}us.find(10);{{$}}
-
- std::unordered_multiset<int> ums;
- find(ums.begin(), ums.end(), 10);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}ums.find(10);{{$}}
-
- std::map<int, int> intmap;
- find(intmap.begin(), intmap.end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}find(intmap.begin(), intmap.end(), 46);{{$}}
-
- std::multimap<int, int> intmmap;
- find(intmmap.begin(), intmmap.end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}find(intmmap.begin(), intmmap.end(), 46);{{$}}
-
- std::unordered_map<int, int> umap;
- find(umap.begin(), umap.end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}find(umap.begin(), umap.end(), 46);{{$}}
-
- std::unordered_multimap<int, int> ummap;
- find(ummap.begin(), ummap.end(), 46);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}find(ummap.begin(), ummap.end(), 46);{{$}}
-}
-
-struct Value {
- int value;
-};
-
-struct Ordering {
- bool operator()(const Value &lhs, const Value &rhs) const {
- return lhs.value < rhs.value;
- }
- bool operator()(int lhs, const Value &rhs) const { return lhs < rhs.value; }
-};
-
-void g(std::set<Value, Ordering> container, int value) {
- lower_bound(container.begin(), container.end(), value, Ordering());
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be
- // CHECK-FIXES: {{^ }}lower_bound(container.begin(), container.end(), value, Ordering());{{$}}
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp (removed)
@@ -1,48 +0,0 @@
-// RUN: %check_clang_tidy %s performance-inefficient-string-concatenation %t
-
-namespace std {
-template <typename T>
-class basic_string {
-public:
- basic_string() {}
- ~basic_string() {}
- basic_string<T> *operator+=(const basic_string<T> &) {}
- friend basic_string<T> operator+(const basic_string<T> &, const basic_string<T> &) {}
-};
-typedef basic_string<char> string;
-typedef basic_string<wchar_t> wstring;
-}
-
-void f(std::string) {}
-std::string g(std::string) {}
-
-int main() {
- std::string mystr1, mystr2;
- std::wstring mywstr1, mywstr2;
- auto myautostr1 = mystr1;
- auto myautostr2 = mystr2;
-
- for (int i = 0; i < 10; ++i) {
- f(mystr1 + mystr2 + mystr1);
- // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead
- mystr1 = mystr1 + mystr2;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
- mystr1 = mystr2 + mystr2 + mystr2;
- // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: string concatenation
- mystr1 = mystr2 + mystr1;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
- mywstr1 = mywstr2 + mywstr1;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
- mywstr1 = mywstr2 + mywstr2 + mywstr2;
- // CHECK-MESSAGES: :[[@LINE-1]]:33: warning: string concatenation
- myautostr1 = myautostr1 + myautostr2;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
-
- mywstr1 = mywstr2 + mywstr2;
- mystr1 = mystr2 + mystr2;
- mystr1 += mystr2;
- f(mystr2 + mystr1);
- mystr1 = g(mystr1);
- }
- return 0;
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-vector-operation.cpp (removed)
@@ -1,361 +0,0 @@
-// RUN: %check_clang_tidy %s performance-inefficient-vector-operation %t -- \
-// RUN: -format-style=llvm \
-// RUN: -config='{CheckOptions: \
-// RUN: [{key: performance-inefficient-vector-operation.EnableProto, value: 1}]}'
-
-namespace std {
-
-typedef int size_t;
-
-template<class E> class initializer_list {
-public:
- using value_type = E;
- using reference = E&;
- using const_reference = const E&;
- using size_type = size_t;
- using iterator = const E*;
- using const_iterator = const E*;
- initializer_list();
- size_t size() const; // number of elements
- const E* begin() const; // first element
- const E* end() const; // one past the last element
-};
-
-// initializer list range access
-template<class E> const E* begin(initializer_list<E> il);
-template<class E> const E* end(initializer_list<E> il);
-
-template <class T>
-class vector {
- public:
- typedef T* iterator;
- typedef const T* const_iterator;
- typedef T& reference;
- typedef const T& const_reference;
- typedef size_t size_type;
-
- explicit vector();
- explicit vector(size_type n);
-
- void push_back(const T& val);
-
- template <class... Args> void emplace_back(Args &&... args);
-
- void reserve(size_t n);
- void resize(size_t n);
-
- size_t size();
- const_reference operator[] (size_type) const;
- reference operator[] (size_type);
-
- const_iterator begin() const;
- const_iterator end() const;
-};
-} // namespace std
-
-class Foo {
- public:
- explicit Foo(int);
-};
-
-class Bar {
- public:
- Bar(int);
-};
-
-int Op(int);
-
-namespace proto2 {
-class MessageLite {};
-class Message : public MessageLite {};
-} // namespace proto2
-
-class FooProto : public proto2::Message {
- public:
- int *add_x(); // repeated int x;
- void add_x(int x);
- void mutable_x();
- void mutable_y();
- int add_z() const; // optional int add_z;
-};
-
-class BarProto : public proto2::Message {
- public:
- int *add_x();
- void add_x(int x);
- void mutable_x();
- void mutable_y();
-};
-
-void f(std::vector<int>& t) {
- {
- std::vector<int> v0;
- // CHECK-FIXES: v0.reserve(10);
- for (int i = 0; i < 10; ++i)
- v0.push_back(i);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called inside a loop; consider pre-allocating the container capacity before the loop
- }
- {
- std::vector<int> v1;
- // CHECK-FIXES: v1.reserve(10);
- for (int i = 0; i < 10; i++)
- v1.push_back(i);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- {
- std::vector<int> v2;
- // CHECK-FIXES: v2.reserve(10);
- for (int i = 0; i < 10; ++i)
- v2.push_back(0);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- {
- std::vector<int> v3;
- // CHECK-FIXES: v3.reserve(5);
- for (int i = 0; i < 5; ++i) {
- v3.push_back(i);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- // CHECK-FIXES-NOT: v3.reserve(10);
- for (int i = 0; i < 10; ++i) {
- // No fix for this loop as we encounter the prior loops.
- v3.push_back(i);
- }
- }
- {
- std::vector<int> v4;
- std::vector<int> v5;
- v5.reserve(3);
- // CHECK-FIXES: v4.reserve(10);
- for (int i = 0; i < 10; ++i)
- v4.push_back(i);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- {
- std::vector<int> v6;
- // CHECK-FIXES: v6.reserve(t.size());
- for (std::size_t i = 0; i < t.size(); ++i) {
- v6.push_back(t[i]);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- }
- {
- std::vector<int> v7;
- // CHECK-FIXES: v7.reserve(t.size() - 1);
- for (std::size_t i = 0; i < t.size() - 1; ++i) {
- v7.push_back(t[i]);
- } // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- {
- std::vector<int> v8;
- // CHECK-FIXES: v8.reserve(t.size());
- for (const auto &e : t) {
- v8.push_back(e);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- }
- {
- std::vector<int> v9;
- // CHECK-FIXES: v9.reserve(t.size());
- for (const auto &e : t) {
- v9.push_back(Op(e));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- }
- {
- std::vector<Foo> v10;
- // CHECK-FIXES: v10.reserve(t.size());
- for (const auto &e : t) {
- v10.push_back(Foo(e));
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- }
- {
- std::vector<Bar> v11;
- // CHECK-FIXES: v11.reserve(t.size());
- for (const auto &e : t) {
- v11.push_back(e);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'push_back' is called
- }
- }
- {
- std::vector<Foo> v12;
- // CHECK-FIXES: v12.reserve(t.size());
- for (const auto &e : t) {
- v12.emplace_back(e);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'emplace_back' is called
- }
- }
-
- {
- FooProto foo;
- // CHECK-FIXES: foo.mutable_x()->Reserve(5);
- for (int i = 0; i < 5; i++) {
- foo.add_x(i);
- // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: 'add_x' is called inside a loop; consider pre-allocating the container capacity before the loop
- }
- }
-
- // ---- Non-fixed Cases ----
- {
- std::vector<int> z0;
- z0.reserve(20);
- // CHECK-FIXES-NOT: z0.reserve(10);
- // There is a "reserve" call already.
- for (int i = 0; i < 10; ++i) {
- z0.push_back(i);
- }
- }
- {
- std::vector<int> z1;
- z1.reserve(5);
- // CHECK-FIXES-NOT: z1.reserve(10);
- // There is a "reserve" call already.
- for (int i = 0; i < 10; ++i) {
- z1.push_back(i);
- }
- }
- {
- std::vector<int> z2;
- z2.resize(5);
- // CHECK-FIXES-NOT: z2.reserve(10);
- // There is a ref usage of v before the loop.
- for (int i = 0; i < 10; ++i) {
- z2.push_back(i);
- }
- }
- {
- std::vector<int> z3;
- z3.push_back(0);
- // CHECK-FIXES-NOT: z3.reserve(10);
- // There is a ref usage of v before the loop.
- for (int i = 0; i < 10; ++i) {
- z3.push_back(i);
- }
- }
- {
- std::vector<int> z4;
- f(z4);
- // CHECK-FIXES-NOT: z4.reserve(10);
- // There is a ref usage of z4 before the loop.
- for (int i = 0; i < 10; ++i) {
- z4.push_back(i);
- }
- }
- {
- std::vector<int> z5(20);
- // CHECK-FIXES-NOT: z5.reserve(10);
- // z5 is not constructed with default constructor.
- for (int i = 0; i < 10; ++i) {
- z5.push_back(i);
- }
- }
- {
- std::vector<int> z6;
- // CHECK-FIXES-NOT: z6.reserve(10);
- // For-loop is not started with 0.
- for (int i = 1; i < 10; ++i) {
- z6.push_back(i);
- }
- }
- {
- std::vector<int> z7;
- // CHECK-FIXES-NOT: z7.reserve(t.size());
- // z7 isn't referenced in for-loop body.
- for (std::size_t i = 0; i < t.size(); ++i) {
- t.push_back(i);
- }
- }
- {
- std::vector<int> z8;
- int k;
- // CHECK-FIXES-NOT: z8.reserve(10);
- // For-loop isn't a fixable loop.
- for (std::size_t i = 0; k < 10; ++i) {
- z8.push_back(t[i]);
- }
- }
- {
- std::vector<int> z9;
- // CHECK-FIXES-NOT: z9.reserve(i + 1);
- // The loop end expression refers to the loop variable i.
- for (int i = 0; i < i + 1; i++)
- z9.push_back(i);
- }
- {
- std::vector<int> z10;
- int k;
- // CHECK-FIXES-NOT: z10.reserve(10);
- // For-loop isn't a fixable loop.
- for (std::size_t i = 0; i < 10; ++k) {
- z10.push_back(t[i]);
- }
- }
- {
- std::vector<int> z11;
- // initializer_list should not trigger the check.
- for (int e : {1, 2, 3, 4, 5}) {
- z11.push_back(e);
- }
- }
- {
- std::vector<int> z12;
- std::vector<int>* z13 = &t;
- // We only support detecting the range init expression which references
- // container directly.
- // Complex range init expressions like `*z13` is not supported.
- for (const auto &e : *z13) {
- z12.push_back(e);
- }
- }
-
- {
- FooProto foo;
- foo.mutable_x();
- // CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
- for (int i = 0; i < 5; i++) {
- foo.add_x(i);
- }
- }
- {
- FooProto foo;
- // CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
- for (int i = 0; i < 5; i++) {
- foo.add_x(i);
- foo.add_x(i);
- }
- }
- {
- FooProto foo;
- // CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
- foo.add_x(-1);
- for (int i = 0; i < 5; i++) {
- foo.add_x(i);
- }
- }
- {
- FooProto foo;
- BarProto bar;
- bar.mutable_x();
- // CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
- for (int i = 0; i < 5; i++) {
- foo.add_x();
- bar.add_x();
- }
- }
- {
- FooProto foo;
- foo.mutable_y();
- // CHECK-FIXES-NOT: foo.mutable_x()->Reserve(5);
- for (int i = 0; i < 5; i++) {
- foo.add_x(i);
- }
- }
- {
- FooProto foo;
- // CHECK-FIXES-NOT: foo.mutable_z()->Reserve(5);
- for (int i = 0; i < 5; i++) {
- foo.add_z();
- }
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp (removed)
@@ -1,97 +0,0 @@
-// RUN: %check_clang_tidy %s performance-move-const-arg %t \
-// RUN: -config='{CheckOptions: \
-// RUN: [{key: performance-move-const-arg.CheckTriviallyCopyableMove, value: 0}]}'
-
-namespace std {
-
-template <typename> struct remove_reference;
-template <typename _Tp> struct remove_reference { typedef _Tp type; };
-template <typename _Tp> struct remove_reference<_Tp &> { typedef _Tp type; };
-template <typename _Tp> struct remove_reference<_Tp &&> { typedef _Tp type; };
-
-template <typename _Tp>
-constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
- return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
-}
-
-template <typename _Tp>
-constexpr _Tp &&
-forward(typename remove_reference<_Tp>::type &__t) noexcept {
- return static_cast<_Tp &&>(__t);
-}
-
-} // namespace std
-
-class NoMoveSemantics {
- public:
- NoMoveSemantics();
- NoMoveSemantics(const NoMoveSemantics &);
-
- NoMoveSemantics &operator=(const NoMoveSemantics &);
-};
-
-void callByConstRef(const NoMoveSemantics &);
-void callByConstRef(int i, const NoMoveSemantics &);
-
-void moveToConstReferencePositives() {
- NoMoveSemantics obj;
-
- // Basic case. It is here just to have a single "detected and fixed" case.
- callByConstRef(std::move(obj));
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
- // CHECK-FIXES: callByConstRef(obj);
-}
-
-struct TriviallyCopyable {
- int i;
-};
-
-void f(TriviallyCopyable) {}
-
-void g() {
- TriviallyCopyable obj;
- f(std::move(obj));
-}
-
-class MoveSemantics {
- public:
- MoveSemantics();
- MoveSemantics(MoveSemantics &&);
-
- MoveSemantics &operator=(MoveSemantics &&);
-};
-
-void fmovable(MoveSemantics);
-
-void lambda1() {
- auto f = [](MoveSemantics m) {
- fmovable(std::move(m));
- };
- f(MoveSemantics());
-}
-
-template<class T> struct function {};
-
-template<typename Result, typename... Args>
-class function<Result(Args...)> {
-public:
- function() = default;
- void operator()(Args... args) const {
- fmovable(std::forward<Args>(args)...);
- }
-};
-
-void functionInvocation() {
- function<void(MoveSemantics)> callback;
- MoveSemantics m;
- callback(std::move(m));
-}
-
-void lambda2() {
- function<void(MoveSemantics)> callback;
-
- auto f = [callback = std::move(callback)](MoveSemantics m) mutable {
- callback(std::move(m));
- };
- f(MoveSemantics());
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp (removed)
@@ -1,248 +0,0 @@
-// RUN: %check_clang_tidy %s performance-move-const-arg %t
-
-namespace std {
-template <typename>
-struct remove_reference;
-
-template <typename _Tp>
-struct remove_reference {
- typedef _Tp type;
-};
-
-template <typename _Tp>
-struct remove_reference<_Tp &> {
- typedef _Tp type;
-};
-
-template <typename _Tp>
-struct remove_reference<_Tp &&> {
- typedef _Tp type;
-};
-
-template <typename _Tp>
-constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
- return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
-}
-
-template <typename _Tp>
-constexpr _Tp &&
-forward(typename remove_reference<_Tp>::type &__t) noexcept {
- return static_cast<_Tp &&>(__t);
-}
-
-} // namespace std
-
-class A {
-public:
- A() {}
- A(const A &rhs) {}
- A(A &&rhs) {}
-};
-
-struct TriviallyCopyable {
- int i;
-};
-
-void f(TriviallyCopyable) {}
-
-void g() {
- TriviallyCopyable obj;
- f(std::move(obj));
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: std::move of the variable 'obj' of the trivially-copyable type 'TriviallyCopyable' has no effect; remove std::move() [performance-move-const-arg]
- // CHECK-FIXES: f(obj);
-}
-
-int f1() {
- return std::move(42);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of the trivially-copyable type 'int' has no effect; remove std::move() [performance-move-const-arg]
- // CHECK-FIXES: return 42;
-}
-
-int f2(int x2) {
- return std::move(x2);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 'x2' of the trivially-copyable type 'int'
- // CHECK-FIXES: return x2;
-}
-
-int *f3(int *x3) {
- return std::move(x3);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 'x3' of the trivially-copyable type 'int *'
- // CHECK-FIXES: return x3;
-}
-
-A f4(A x4) { return std::move(x4); }
-
-A f5(const A x5) {
- return std::move(x5);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x5' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg]
- // CHECK-FIXES: return x5;
-}
-
-template <typename T>
-T f6(const T x6) {
- return std::move(x6);
-}
-
-void f7() { int a = f6(10); }
-
-#define M1(x) x
-void f8() {
- const A a;
- M1(A b = std::move(a);)
- // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: std::move of the const variable 'a' has no effect; remove std::move() or make the variable non-const
- // CHECK-FIXES: M1(A b = a;)
-}
-
-#define M2(x) std::move(x)
-int f9() { return M2(1); }
-
-template <typename T>
-T f10(const int x10) {
- return std::move(x10);
- // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x10' of the trivially-copyable type 'const int' has no effect; remove std::move() [performance-move-const-arg]
- // CHECK-FIXES: return x10;
-}
-void f11() {
- f10<int>(1);
- f10<double>(1);
-}
-
-class NoMoveSemantics {
-public:
- NoMoveSemantics();
- NoMoveSemantics(const NoMoveSemantics &);
-
- NoMoveSemantics &operator=(const NoMoveSemantics &);
-};
-
-void callByConstRef(const NoMoveSemantics &);
-void callByConstRef(int i, const NoMoveSemantics &);
-
-void moveToConstReferencePositives() {
- NoMoveSemantics obj;
-
- // Basic case.
- callByConstRef(std::move(obj));
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as
- // CHECK-FIXES: callByConstRef(obj);
-
- // Also works for second argument.
- callByConstRef(1, std::move(obj));
- // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: passing result of std::move() as
- // CHECK-FIXES: callByConstRef(1, obj);
-
- // Works if std::move() applied to a temporary.
- callByConstRef(std::move(NoMoveSemantics()));
- // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as
- // CHECK-FIXES: callByConstRef(NoMoveSemantics());
-
- // Works if calling a copy constructor.
- NoMoveSemantics other(std::move(obj));
- // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: passing result of std::move() as
- // CHECK-FIXES: NoMoveSemantics other(obj);
-
- // Works if calling assignment operator.
- other = std::move(obj);
- // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: passing result of std::move() as
- // CHECK-FIXES: other = obj;
-}
-
-class MoveSemantics {
-public:
- MoveSemantics();
- MoveSemantics(MoveSemantics &&);
-
- MoveSemantics &operator=(MoveSemantics &&);
-};
-
-void callByValue(MoveSemantics);
-
-void callByRValueRef(MoveSemantics &&);
-
-template <class T>
-void templateFunction(T obj) {
- T other = std::move(obj);
-}
-
-#define M3(T, obj) \
- do { \
- T other = std::move(obj); \
- } while (true)
-
-#define CALL(func) (func)()
-
-void moveToConstReferenceNegatives() {
- // No warning when actual move takes place.
- MoveSemantics move_semantics;
- callByValue(std::move(move_semantics));
- callByRValueRef(std::move(move_semantics));
- MoveSemantics other(std::move(move_semantics));
- other = std::move(move_semantics);
-
- // No warning if std::move() not used.
- NoMoveSemantics no_move_semantics;
- callByConstRef(no_move_semantics);
-
- // No warning if instantiating a template.
- templateFunction(no_move_semantics);
-
- // No warning inside of macro expansions.
- M3(NoMoveSemantics, no_move_semantics);
-
- // No warning inside of macro expansion, even if the macro expansion is inside
- // a lambda that is, in turn, an argument to a macro.
- CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
-
- auto lambda = [] {};
- auto lambda2 = std::move(lambda);
-}
-
-class MoveOnly {
-public:
- MoveOnly(const MoveOnly &other) = delete;
- MoveOnly &operator=(const MoveOnly &other) = delete;
- MoveOnly(MoveOnly &&other) = default;
- MoveOnly &operator=(MoveOnly &&other) = default;
-};
-template <class T>
-void Q(T);
-void moveOnlyNegatives(MoveOnly val) {
- Q(std::move(val));
-}
-
-void fmovable(MoveSemantics);
-
-void lambda1() {
- auto f = [](MoveSemantics m) {
- fmovable(std::move(m));
- };
- f(MoveSemantics());
-}
-
-template<class T> struct function {};
-
-template<typename Result, typename... Args>
-class function<Result(Args...)> {
-public:
- function() = default;
- void operator()(Args... args) const {
- fmovable(std::forward<Args>(args)...);
- }
-};
-
-void functionInvocation() {
- function<void(MoveSemantics)> callback;
- MoveSemantics m;
- callback(std::move(m));
-}
-
-void lambda2() {
- function<void(MoveSemantics)> callback;
-
- auto f = [callback = std::move(callback)](MoveSemantics m) mutable {
- // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: std::move of the variable 'callback' of the trivially-copyable type 'function<void (MoveSemantics)>' has no effect; remove std::move()
- // CHECK-FIXES: auto f = [callback = callback](MoveSemantics m) mutable {
- callback(std::move(m));
- };
- f(MoveSemantics());
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-move-constructor-init.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-move-constructor-init.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-move-constructor-init.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-move-constructor-init.cpp (removed)
@@ -1,156 +0,0 @@
-// RUN: %check_clang_tidy %s performance-move-constructor-init,modernize-pass-by-value %t -- \
-// RUN: -config='{CheckOptions: \
-// RUN: [{key: modernize-pass-by-value.ValuesOnly, value: 1}]}' \
-// RUN: -- -isystem %S/Inputs/Headers
-
-#include <s.h>
-
-// CHECK-FIXES: #include <utility>
-
-template <class T> struct remove_reference {typedef T type;};
-template <class T> struct remove_reference<T&> {typedef T type;};
-template <class T> struct remove_reference<T&&> {typedef T type;};
-
-template <typename T>
-typename remove_reference<T>::type&& move(T&& arg) {
- return static_cast<typename remove_reference<T>::type&&>(arg);
-}
-
-struct C {
- C() = default;
- C(const C&) = default;
-};
-
-struct B {
- B() {}
- B(const B&) {}
- B(B &&) {}
-};
-
-struct D : B {
- D() : B() {}
- D(const D &RHS) : B(RHS) {}
- // CHECK-NOTES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [performance-move-constructor-init]
- // CHECK-NOTES: 26:3: note: copy constructor being called
- // CHECK-NOTES: 27:3: note: candidate move constructor here
- D(D &&RHS) : B(RHS) {}
-};
-
-struct E : B {
- E() : B() {}
- E(const E &RHS) : B(RHS) {}
- E(E &&RHS) : B(move(RHS)) {} // ok
-};
-
-struct F {
- C M;
-
- F(F &&) : M(C()) {} // ok
-};
-
-struct G {
- G() = default;
- G(const G&) = default;
- G(G&&) = delete;
-};
-
-struct H : G {
- H() = default;
- H(const H&) = default;
- H(H &&RHS) : G(RHS) {} // ok
-};
-
-struct I {
- I(const I &) = default; // suppresses move constructor creation
-};
-
-struct J : I {
- J(J &&RHS) : I(RHS) {} // ok
-};
-
-struct K {}; // Has implicit copy and move constructors, is trivially copyable
-struct L : K {
- L(L &&RHS) : K(RHS) {} // ok
-};
-
-struct M {
- B Mem;
- // CHECK-NOTES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [performance-move-constructor-init]
- M(M &&RHS) : Mem(RHS.Mem) {}
- // CHECK-NOTES: 26:3: note: copy constructor being called
- // CHECK-NOTES: 27:3: note: candidate move constructor here
-};
-
-struct N {
- B Mem;
- N(N &&RHS) : Mem(move(RHS.Mem)) {}
-};
-
-struct O {
- O(O&& other) : b(other.b) {} // ok
- const B b;
-};
-
-struct P {
- P(O&& other) : b(other.b) {} // ok
- B b;
-};
-
-struct Movable {
- Movable(Movable &&) = default;
- Movable(const Movable &) = default;
- Movable &operator=(const Movable &) = default;
- ~Movable() {}
-};
-
-struct TriviallyCopyable {
- TriviallyCopyable() = default;
- TriviallyCopyable(TriviallyCopyable &&) = default;
- TriviallyCopyable(const TriviallyCopyable &) = default;
-};
-
-struct Positive {
- Positive(Movable M) : M_(M) {}
- // CHECK-NOTES: [[@LINE-1]]:12: warning: pass by value and use std::move [modernize-pass-by-value]
- // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
- Movable M_;
-};
-
-struct NegativeMultipleInitializerReferences {
- NegativeMultipleInitializerReferences(Movable M) : M_(M), n_(M) {}
- Movable M_;
- Movable n_;
-};
-
-struct NegativeReferencedInConstructorBody {
- NegativeReferencedInConstructorBody(Movable M) : M_(M) { M_ = M; }
- Movable M_;
-};
-
-struct NegativeParamTriviallyCopyable {
- NegativeParamTriviallyCopyable(TriviallyCopyable T) : T_(T) {}
- NegativeParamTriviallyCopyable(int I) : I_(I) {}
-
- TriviallyCopyable T_;
- int I_;
-};
-
-struct NegativeNotPassedByValue {
- // This const ref constructor isn't warned about because the ValuesOnly option is set.
- NegativeNotPassedByValue(const Movable &M) : M_(M) {}
- NegativeNotPassedByValue(const Movable M) : M_(M) {}
- NegativeNotPassedByValue(Movable &M) : M_(M) {}
- NegativeNotPassedByValue(Movable *M) : M_(*M) {}
- NegativeNotPassedByValue(const Movable *M) : M_(*M) {}
- Movable M_;
-};
-
-struct Immovable {
- Immovable(const Immovable &) = default;
- Immovable(Immovable &&) = delete;
-};
-
-struct NegativeImmovableParameter {
- NegativeImmovableParameter(Immovable I) : I_(I) {}
- Immovable I_;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor-fix.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor-fix.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor-fix.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor-fix.cpp (removed)
@@ -1,67 +0,0 @@
-// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t
-
-struct C_1 {
- ~C_1() {}
- C_1(int a) {}
- C_1(C_1&& a) :C_1(5) {}
- // CHECK-FIXES: ){{.*}}noexcept{{.*}}:
- C_1& operator=(C_1&&) { return *this; }
- // CHECK-FIXES: ){{.*}}noexcept{{.*}} {
-};
-
-struct C_2 {
- ~C_2() {}
- C_2(C_2&& a);
-// CHECK-FIXES: ){{.*}}noexcept{{.*}};
- C_2& operator=(C_2&&);
-// CHECK-FIXES: ){{.*}}noexcept{{.*}};
-};
-
-C_2::C_2(C_2&& a) {}
-// CHECK-FIXES: ){{.*}}noexcept{{.*}} {}
-C_2& C_2::operator=(C_2&&) { return *this; }
-// CHECK-FIXES: ){{.*}}noexcept{{.*}} {
-
-struct C_3 {
- ~C_3() {}
- C_3(C_3&& a);
-// CHECK-FIXES: ){{.*}}noexcept{{.*}};
- C_3& operator=(C_3&& a);
-// CHECK-FIXES: ){{.*}}noexcept{{.*}};
-};
-
-C_3::C_3(C_3&& a) = default;
-// CHECK-FIXES: ){{.*}}noexcept{{.*}} = default;
-C_3& C_3::operator=(C_3&& a) = default;
-// CHECK-FIXES: ){{.*}}noexcept{{.*}} = default;
-
-template <class T>
-struct C_4 {
- C_4(C_4<T>&&) {}
-// CHECK-FIXES: ){{.*}}noexcept{{.*}} {}
- ~C_4() {}
- C_4& operator=(C_4&& a) = default;
-// CHECK-FIXES: ){{.*}}noexcept{{.*}} = default;
-};
-
-template <class T>
-struct C_5 {
- C_5(C_5<T>&&) {}
-// CHECK-FIXES:){{.*}}noexcept{{.*}} {}
- ~C_5() {}
- auto operator=(C_5&& a)->C_5<T> = default;
-// CHECK-FIXES:){{.*}}noexcept{{.*}} = default;
-};
-
-template <class T>
-struct C_6 {
- C_6(C_6<T>&&) {}
-// CHECK-FIXES:){{.*}}noexcept{{.*}} {}
- ~C_6() {}
- auto operator=(C_6&& a)->C_6<T>;
-// CHECK-FIXES:){{.*}}noexcept{{.*}};
-};
-
-template <class T>
-auto C_6<T>::operator=(C_6<T>&& a) -> C_6<T> {}
-// CHECK-FIXES: ){{.*}}noexcept{{.*}} {}
\ No newline at end of file
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp (removed)
@@ -1,54 +0,0 @@
-// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t
-
-class A {
- A(A &&);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [performance-noexcept-move-constructor]
- A &operator=(A &&);
- // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
-};
-
-struct B {
- static constexpr bool kFalse = false;
- B(B &&) noexcept(kFalse);
- // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor]
-};
-
-class OK {};
-
-void f() {
- OK a;
- a = OK();
-}
-
-class OK1 {
-public:
- OK1();
- OK1(const OK1 &);
- OK1(OK1 &&) noexcept;
- OK1 &operator=(OK1 &&) noexcept;
- void f();
- void g() noexcept;
-};
-
-class OK2 {
- static constexpr bool kTrue = true;
-
-public:
- OK2(OK2 &&) noexcept(true) {}
- OK2 &operator=(OK2 &&) noexcept(kTrue) { return *this; }
-};
-
-struct OK3 {
- OK3(OK3 &&) noexcept(false) {}
- OK3 &operator=(OK3 &&) = delete;
-};
-
-struct OK4 {
- OK4(OK4 &&) noexcept = default;
- OK4 &operator=(OK4 &&) noexcept = default;
-};
-
-struct OK5 {
- OK5(OK5 &&) noexcept(true) = default;
- OK5 &operator=(OK5 &&) noexcept(true) = default;
-};
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-type-promotion-in-math-fn.cpp (removed)
@@ -1,316 +0,0 @@
-// RUN: %check_clang_tidy %s performance-type-promotion-in-math-fn %t
-
-// CHECK-FIXES: #include <cmath>
-
-double acos(double);
-double acosh(double);
-double asin(double);
-double asinh(double);
-double atan2(double, double);
-double atan(double);
-double atanh(double);
-double cbrt(double);
-double ceil(double);
-double copysign(double, double);
-double cos(double);
-double cosh(double);
-double erfc(double);
-double erf(double);
-double exp2(double);
-double exp(double);
-double expm1(double);
-double fabs(double);
-double fdim(double, double);
-double floor(double);
-double fma(double, double, double);
-double fmax(double, double);
-double fmin(double, double);
-double fmod(double, double);
-double frexp(double, int *);
-double hypot(double, double);
-double ilogb(double);
-double ldexp(double, double);
-double lgamma(double);
-long long llrint(double);
-double log10(double);
-double log1p(double);
-double log2(double);
-double logb(double);
-double log(double);
-long lrint(double);
-double modf(double);
-double nearbyint(double);
-double nextafter(double, double);
-double nexttoward(double, long double);
-double pow(double, double);
-double remainder(double, double);
-double remquo(double, double, int *);
-double rint(double);
-double round(double);
-double scalbln(double, long);
-double scalbn(double, int);
-double sin(double);
-double sinh(double);
-double sqrt(double);
-double tan(double);
-double tanh(double);
-double tgamma(double);
-double trunc(double);
-long long llround(double);
-long lround(double);
-
-void check_all_fns() {
- float a, b, c;
- int i;
- long l;
- int *int_ptr;
-
- acos(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acos' promotes float to double [performance-type-promotion-in-math-fn]
- // CHECK-FIXES: {{^}} std::acos(a);{{$}}
- acosh(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'acosh'
- // CHECK-FIXES: {{^}} std::acosh(a);{{$}}
- asin(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asin'
- // CHECK-FIXES: {{^}} std::asin(a);{{$}}
- asinh(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'asinh'
- // CHECK-FIXES: {{^}} std::asinh(a);{{$}}
- atan2(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan2'
- // CHECK-FIXES: {{^}} std::atan2(a, b);{{$}}
- atan(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atan'
- // CHECK-FIXES: {{^}} std::atan(a);{{$}}
- atanh(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'atanh'
- // CHECK-FIXES: {{^}} std::atanh(a);{{$}}
- cbrt(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cbrt'
- // CHECK-FIXES: {{^}} std::cbrt(a);{{$}}
- ceil(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ceil'
- // CHECK-FIXES: {{^}} std::ceil(a);{{$}}
- copysign(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'copysign'
- // CHECK-FIXES: {{^}} std::copysign(a, b);{{$}}
- cos(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cos'
- // CHECK-FIXES: {{^}} std::cos(a);{{$}}
- cosh(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'cosh'
- // CHECK-FIXES: {{^}} std::cosh(a);{{$}}
- erf(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erf'
- // CHECK-FIXES: {{^}} std::erf(a);{{$}}
- erfc(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'erfc'
- // CHECK-FIXES: {{^}} std::erfc(a);{{$}}
- exp2(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp2'
- // CHECK-FIXES: {{^}} std::exp2(a);{{$}}
- exp(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'exp'
- // CHECK-FIXES: {{^}} std::exp(a);{{$}}
- expm1(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'expm1'
- // CHECK-FIXES: {{^}} std::expm1(a);{{$}}
- fabs(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fabs'
- // CHECK-FIXES: {{^}} std::fabs(a);{{$}}
- fdim(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fdim'
- // CHECK-FIXES: {{^}} std::fdim(a, b);{{$}}
- floor(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'floor'
- // CHECK-FIXES: {{^}} std::floor(a);{{$}}
- fma(a, b, c);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fma'
- // CHECK-FIXES: {{^}} std::fma(a, b, c);{{$}}
- fmax(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fmax'
- // CHECK-FIXES: {{^}} std::fmax(a, b);{{$}}
- fmin(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fmin'
- // CHECK-FIXES: {{^}} std::fmin(a, b);{{$}}
- fmod(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'fmod'
- // CHECK-FIXES: {{^}} std::fmod(a, b);{{$}}
- frexp(a, int_ptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'frexp'
- // CHECK-FIXES: {{^}} std::frexp(a, int_ptr);{{$}}
- hypot(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'hypot'
- // CHECK-FIXES: {{^}} std::hypot(a, b);{{$}}
- ilogb(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ilogb'
- // CHECK-FIXES: {{^}} std::ilogb(a);{{$}}
- ldexp(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'ldexp'
- // CHECK-FIXES: {{^}} std::ldexp(a, b);{{$}}
- lgamma(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'lgamma'
- // CHECK-FIXES: {{^}} std::lgamma(a);{{$}}
- llrint(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'llrint'
- // CHECK-FIXES: {{^}} std::llrint(a);{{$}}
- llround(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'llround'
- // CHECK-FIXES: {{^}} std::llround(a);{{$}}
- log10(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'log10'
- // CHECK-FIXES: {{^}} std::log10(a);{{$}}
- log1p(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'log1p'
- // CHECK-FIXES: {{^}} std::log1p(a);{{$}}
- log2(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'log2'
- // CHECK-FIXES: {{^}} std::log2(a);{{$}}
- log(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'log'
- // CHECK-FIXES: {{^}} std::log(a);{{$}}
- logb(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'logb'
- // CHECK-FIXES: {{^}} std::logb(a);{{$}}
- lrint(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'lrint'
- // CHECK-FIXES: {{^}} std::lrint(a);{{$}}
- lround(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'lround'
- // CHECK-FIXES: {{^}} std::lround(a);{{$}}
- nearbyint(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'nearbyint'
- // CHECK-FIXES: {{^}} std::nearbyint(a);{{$}}
- nextafter(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'nextafter'
- // CHECK-FIXES: {{^}} std::nextafter(a, b);{{$}}
- nexttoward(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'nexttoward'
- // CHECK-FIXES: {{^}} std::nexttoward(a, b);{{$}}
- pow(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'pow'
- // CHECK-FIXES: {{^}} std::pow(a, b);{{$}}
- remainder(a, b);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'remainder'
- // CHECK-FIXES: {{^}} std::remainder(a, b);{{$}}
- remquo(a, b, int_ptr);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'remquo'
- // CHECK-FIXES: {{^}} std::remquo(a, b, int_ptr);{{$}}
- rint(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'rint'
- // CHECK-FIXES: {{^}} std::rint(a);{{$}}
- round(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'round'
- // CHECK-FIXES: {{^}} std::round(a);{{$}}
- scalbln(a, l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'scalbln'
- // CHECK-FIXES: {{^}} std::scalbln(a, l);{{$}}
- scalbn(a, i);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'scalbn'
- // CHECK-FIXES: {{^}} std::scalbn(a, i);{{$}}
- sin(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'sin'
- // CHECK-FIXES: {{^}} std::sin(a);{{$}}
- sinh(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'sinh'
- // CHECK-FIXES: {{^}} std::sinh(a);{{$}}
- sqrt(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'sqrt'
- // CHECK-FIXES: {{^}} std::sqrt(a);{{$}}
- tan(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'tan'
- // CHECK-FIXES: {{^}} std::tan(a);{{$}}
- tanh(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'tanh'
- // CHECK-FIXES: {{^}} std::tanh(a);{{$}}
- tgamma(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'tgamma'
- // CHECK-FIXES: {{^}} std::tgamma(a);{{$}}
- trunc(a);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'trunc'
- // CHECK-FIXES: {{^}} std::trunc(a);{{$}}
-}
-
-// nexttoward/nexttowardf are weird -- the second param is always long double.
-// So we warn if the first arg is a float, regardless of what the second arg is.
-void check_nexttoward() {
- nexttoward(0.f, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'nexttoward'
- // CHECK-FIXES: {{^}} std::nexttoward(0.f, 0);{{$}}
- nexttoward(0.f, 0l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'nexttoward'
- // CHECK-FIXES: {{^}} std::nexttoward(0.f, 0l);{{$}}
- nexttoward(0.f, 0.f);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'nexttoward'
- // CHECK-FIXES: {{^}} std::nexttoward(0.f, 0.f);{{$}}
- nexttoward(0.f, 0.);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'nexttoward'
- // CHECK-FIXES: {{^}} std::nexttoward(0.f, 0.);{{$}}
-
- // No warnings for these.
- nexttoward(0., 0);
- nexttoward(0., 0.f);
- nexttoward(0., 0.);
-}
-
-// The second parameter to scalbn and scalbnf is an int, so we don't care what
-// type you pass as that argument; we warn iff the first argument is a float.
-void check_scalbn() {
- scalbn(0.f, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'scalbn'
- // CHECK-FIXES: {{^}} std::scalbn(0.f, 0);{{$}}
- scalbn(0.f, static_cast<char>(0));
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'scalbn'
- // CHECK-FIXES: {{^}} std::scalbn(0.f, static_cast<char>(0));{{$}}
-
- // No warnings for these.
- scalbn(0., 0);
- scalbn(0., static_cast<char>(0));
-}
-
-// scalbln/scalblnf are like scalbn/scalbnf except their second arg is a long.
-// Again, doesn't matter what we pass for the second arg; we warn iff the first
-// arg is a float.
-void check_scalbln() {
- scalbln(0.f, 0);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'scalbln'
- // CHECK-FIXES: {{^}} std::scalbln(0.f, 0);{{$}}
- scalbln(0.f, 0l);
- // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: call to 'scalbln'
- // CHECK-FIXES: {{^}} std::scalbln(0.f, 0l);{{$}}
-
- // No warnings for these.
- scalbln(0., 0);
- scalbln(0., 0l);
-}
-
-float cosf(float);
-double foo(double); // not a math.h function
-float cos(float); // not a math.h function (wrong signature)
-double cos(double, double); // not a math.h function (wrong signature)
-
-namespace std {
-void cos(float);
-} // namespace std
-
-void check_no_warnings() {
- foo(0.); // no warning because not a math.h function.
-
- sin(0); // no warning because arg is an int
- cos(0.); // no warning because arg is a double
- std::cos(0.f); // no warning because not ::cos.
- cosf(0.f); // no warning; we expect this to take a float
- cos(0.f); // does not match the expected signature of ::cos
- cos(0.f, 0.f); // does not match the expected signature of ::cos
-
- // No warnings because all args are not floats.
- remainder(0., 0.f);
- remainder(0.f, 0.);
- remainder(0, 0.f);
- remainder(0.f, 0);
- fma(0.f, 0.f, 0);
- fma(0.f, 0.f, 0.);
- fma(0.f, 0., 0.f);
- fma(0., 0.f, 0.f);
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization-allowed-types.cpp (removed)
@@ -1,98 +0,0 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t -- -config="{CheckOptions: [{key: performance-unnecessary-copy-initialization.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" --
-
-struct SmartPointer {
- ~SmartPointer();
-};
-
-struct smart_pointer {
- ~smart_pointer();
-};
-
-struct SmartPtr {
- ~SmartPtr();
-};
-
-struct smart_ptr {
- ~smart_ptr();
-};
-
-struct SmartReference {
- ~SmartReference();
-};
-
-struct smart_reference {
- ~smart_reference();
-};
-
-struct SmartRef {
- ~SmartRef();
-};
-
-struct smart_ref {
- ~smart_ref();
-};
-
-struct OtherType {
- ~OtherType();
-};
-
-template <typename T> struct SomeComplexTemplate {
- ~SomeComplexTemplate();
-};
-
-typedef SomeComplexTemplate<int> NotTooComplexRef;
-
-const SmartPointer &getSmartPointer();
-const smart_pointer &get_smart_pointer();
-const SmartPtr &getSmartPtr();
-const smart_ptr &get_smart_ptr();
-const SmartReference &getSmartReference();
-const smart_reference &get_smart_reference();
-const SmartRef &getSmartRef();
-const smart_ref &get_smart_ref();
-const OtherType &getOtherType();
-const NotTooComplexRef &getNotTooComplexRef();
-
-void negativeSmartPointer() {
- const auto P = getSmartPointer();
-}
-
-void negative_smart_pointer() {
- const auto p = get_smart_pointer();
-}
-
-void negativeSmartPtr() {
- const auto P = getSmartPtr();
-}
-
-void negative_smart_ptr() {
- const auto p = get_smart_ptr();
-}
-
-void negativeSmartReference() {
- const auto R = getSmartReference();
-}
-
-void negative_smart_reference() {
- const auto r = get_smart_reference();
-}
-
-void negativeSmartRef() {
- const auto R = getSmartRef();
-}
-
-void negative_smart_ref() {
- const auto r = get_smart_ref();
-}
-
-void positiveOtherType() {
- const auto O = getOtherType();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'O' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
- // CHECK-FIXES: const auto& O = getOtherType();
-}
-
-void negativeNotTooComplexRef() {
- const NotTooComplexRef R = getNotTooComplexRef();
- // Using `auto` here would result in the "canonical" type which does not match
- // the pattern.
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-copy-initialization.cpp (removed)
@@ -1,389 +0,0 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-copy-initialization %t
-
-struct ExpensiveToCopyType {
- ExpensiveToCopyType();
- virtual ~ExpensiveToCopyType();
- const ExpensiveToCopyType &reference() const;
- void nonConstMethod();
- bool constMethod() const;
-};
-
-struct TrivialToCopyType {
- const TrivialToCopyType &reference() const;
-};
-
-struct WeirdCopyCtorType {
- WeirdCopyCtorType();
- WeirdCopyCtorType(const WeirdCopyCtorType &w, bool oh_yes = true);
-
- void nonConstMethod();
- bool constMethod() const;
-};
-
-ExpensiveToCopyType global_expensive_to_copy_type;
-
-const ExpensiveToCopyType &ExpensiveTypeReference();
-const TrivialToCopyType &TrivialTypeReference();
-
-void mutate(ExpensiveToCopyType &);
-void mutate(ExpensiveToCopyType *);
-void useAsConstPointer(const ExpensiveToCopyType *);
-void useAsConstReference(const ExpensiveToCopyType &);
-void useByValue(ExpensiveToCopyType);
-
-void PositiveFunctionCall() {
- const auto AutoAssigned = ExpensiveTypeReference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
- // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
- const auto AutoCopyConstructed(ExpensiveTypeReference());
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
- // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
- const ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
- // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
- const ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
- // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
-}
-
-void PositiveMethodCallConstReferenceParam(const ExpensiveToCopyType &Obj) {
- const auto AutoAssigned = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
- // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
- const auto AutoCopyConstructed(Obj.reference());
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
- // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
- const ExpensiveToCopyType VarAssigned = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
- // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
- const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
- // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
-}
-
-void PositiveMethodCallConstParam(const ExpensiveToCopyType Obj) {
- const auto AutoAssigned = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
- // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
- const auto AutoCopyConstructed(Obj.reference());
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
- // CHECK-FIXES: const auto& AutoCopyConstructed(Obj.reference());
- const ExpensiveToCopyType VarAssigned = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
- // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj.reference();
- const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
- // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj.reference());
-}
-
-void PositiveMethodCallConstPointerParam(const ExpensiveToCopyType *const Obj) {
- const auto AutoAssigned = Obj->reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
- // CHECK-FIXES: const auto& AutoAssigned = Obj->reference();
- const auto AutoCopyConstructed(Obj->reference());
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoCopyConstructed'
- // CHECK-FIXES: const auto& AutoCopyConstructed(Obj->reference());
- const ExpensiveToCopyType VarAssigned = Obj->reference();
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarAssigned'
- // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = Obj->reference();
- const ExpensiveToCopyType VarCopyConstructed(Obj->reference());
- // CHECK-MESSAGES: [[@LINE-1]]:29: warning: the const qualified variable 'VarCopyConstructed'
- // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(Obj->reference());
-}
-
-void PositiveLocalConstValue() {
- const ExpensiveToCopyType Obj;
- const auto UnnecessaryCopy = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'UnnecessaryCopy'
- // CHECK-FIXES: const auto& UnnecessaryCopy = Obj.reference();
-}
-
-void PositiveLocalConstRef() {
- const ExpensiveToCopyType Obj;
- const ExpensiveToCopyType &ConstReference = Obj.reference();
- const auto UnnecessaryCopy = ConstReference.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'UnnecessaryCopy'
- // CHECK-FIXES: const auto& UnnecessaryCopy = ConstReference.reference();
-}
-
-void PositiveLocalConstPointer() {
- const ExpensiveToCopyType Obj;
- const ExpensiveToCopyType *const ConstPointer = &Obj;
- const auto UnnecessaryCopy = ConstPointer->reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'UnnecessaryCopy'
- // CHECK-FIXES: const auto& UnnecessaryCopy = ConstPointer->reference();
-}
-
-void NegativeFunctionCallTrivialType() {
- const auto AutoAssigned = TrivialTypeReference();
- const auto AutoCopyConstructed(TrivialTypeReference());
- const TrivialToCopyType VarAssigned = TrivialTypeReference();
- const TrivialToCopyType VarCopyConstructed(TrivialTypeReference());
-}
-
-void NegativeStaticLocalVar(const ExpensiveToCopyType &Obj) {
- static const auto StaticVar = Obj.reference();
-}
-
-void PositiveFunctionCallExpensiveTypeNonConstVariable() {
- auto AutoAssigned = ExpensiveTypeReference();
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'AutoAssigned' is copy-constructed from a const reference but is only used as const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
- // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
- auto AutoCopyConstructed(ExpensiveTypeReference());
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'AutoCopyConstructed'
- // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
- ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: the variable 'VarAssigned'
- // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
- ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: the variable 'VarCopyConstructed'
- // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
-}
-
-void positiveNonConstVarInCodeBlock(const ExpensiveToCopyType &Obj) {
- {
- auto Assigned = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:10: warning: the variable 'Assigned'
- // CHECK-FIXES: const auto& Assigned = Obj.reference();
- Assigned.reference();
- useAsConstReference(Assigned);
- useByValue(Assigned);
- }
-}
-
-void negativeNonConstVarWithNonConstUse(const ExpensiveToCopyType &Obj) {
- {
- auto NonConstInvoked = Obj.reference();
- // CHECK-FIXES: auto NonConstInvoked = Obj.reference();
- NonConstInvoked.nonConstMethod();
- }
- {
- auto Reassigned = Obj.reference();
- // CHECK-FIXES: auto Reassigned = Obj.reference();
- Reassigned = ExpensiveToCopyType();
- }
- {
- auto MutatedByReference = Obj.reference();
- // CHECK-FIXES: auto MutatedByReference = Obj.reference();
- mutate(MutatedByReference);
- }
- {
- auto MutatedByPointer = Obj.reference();
- // CHECK-FIXES: auto MutatedByPointer = Obj.reference();
- mutate(&MutatedByPointer);
- }
-}
-
-void PositiveMethodCallNonConstRefNotModified(ExpensiveToCopyType &Obj) {
- const auto AutoAssigned = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
- // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
-}
-
-void NegativeMethodCallNonConstRefIsModified(ExpensiveToCopyType &Obj) {
- const auto AutoAssigned = Obj.reference();
- const auto AutoCopyConstructed(Obj.reference());
- const ExpensiveToCopyType VarAssigned = Obj.reference();
- const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
- mutate(&Obj);
-}
-
-void PositiveMethodCallNonConstNotModified(ExpensiveToCopyType Obj) {
- const auto AutoAssigned = Obj.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
- // CHECK-FIXES: const auto& AutoAssigned = Obj.reference();
-}
-
-void NegativeMethodCallNonConstValueArgumentIsModified(ExpensiveToCopyType Obj) {
- Obj.nonConstMethod();
- const auto AutoAssigned = Obj.reference();
-}
-
-void PositiveMethodCallNonConstPointerNotModified(ExpensiveToCopyType *const Obj) {
- const auto AutoAssigned = Obj->reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
- // CHECK-FIXES: const auto& AutoAssigned = Obj->reference();
- Obj->constMethod();
-}
-
-void NegativeMethodCallNonConstPointerIsModified(ExpensiveToCopyType *const Obj) {
- const auto AutoAssigned = Obj->reference();
- const auto AutoCopyConstructed(Obj->reference());
- const ExpensiveToCopyType VarAssigned = Obj->reference();
- const ExpensiveToCopyType VarCopyConstructed(Obj->reference());
- mutate(Obj);
-}
-
-void PositiveLocalVarIsNotModified() {
- ExpensiveToCopyType LocalVar;
- const auto AutoAssigned = LocalVar.reference();
- // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned'
- // CHECK-FIXES: const auto& AutoAssigned = LocalVar.reference();
-}
-
-void NegativeLocalVarIsModified() {
- ExpensiveToCopyType Obj;
- const auto AutoAssigned = Obj.reference();
- Obj = AutoAssigned;
-}
-
-struct NegativeConstructor {
- NegativeConstructor(const ExpensiveToCopyType &Obj) : Obj(Obj) {}
- ExpensiveToCopyType Obj;
-};
-
-#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE) \
- void functionWith##TYPE(const TYPE &T) { \
- auto AssignedInMacro = T.reference(); \
- } \
-// Ensure fix is not applied.
-// CHECK-FIXES: auto AssignedInMacro = T.reference();
-
-UNNECESSARY_COPY_INIT_IN_MACRO_BODY(ExpensiveToCopyType)
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: the variable 'AssignedInMacro' is copy-constructed
-
-#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT) ARGUMENT
-
-void PositiveMacroArgument(const ExpensiveToCopyType &Obj) {
- UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(auto CopyInMacroArg = Obj.reference());
- // CHECK-MESSAGES: [[@LINE-1]]:48: warning: the variable 'CopyInMacroArg' is copy-constructed
- // Ensure fix is not applied.
- // CHECK-FIXES: auto CopyInMacroArg = Obj.reference()
-}
-
-void PositiveLocalCopyConstMethodInvoked() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType copy_1 = orig;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_1' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
- // CHECK-FIXES: const ExpensiveToCopyType& copy_1 = orig;
- copy_1.constMethod();
- orig.constMethod();
-}
-
-void PositiveLocalCopyUsingExplicitCopyCtor() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType copy_2(orig);
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_2'
- // CHECK-FIXES: const ExpensiveToCopyType& copy_2(orig);
- copy_2.constMethod();
- orig.constMethod();
-}
-
-void PositiveLocalCopyCopyIsArgument(const ExpensiveToCopyType &orig) {
- ExpensiveToCopyType copy_3 = orig;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_3'
- // CHECK-FIXES: const ExpensiveToCopyType& copy_3 = orig;
- copy_3.constMethod();
-}
-
-void PositiveLocalCopyUsedAsConstRef() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType copy_4 = orig;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_4'
- // CHECK-FIXES: const ExpensiveToCopyType& copy_4 = orig;
- useAsConstReference(orig);
-}
-
-void PositiveLocalCopyTwice() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType copy_5 = orig;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_5'
- // CHECK-FIXES: const ExpensiveToCopyType& copy_5 = orig;
- ExpensiveToCopyType copy_6 = copy_5;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy_6'
- // CHECK-FIXES: const ExpensiveToCopyType& copy_6 = copy_5;
- copy_5.constMethod();
- copy_6.constMethod();
- orig.constMethod();
-}
-
-
-void PositiveLocalCopyWeirdCopy() {
- WeirdCopyCtorType orig;
- WeirdCopyCtorType weird_1(orig);
- // CHECK-MESSAGES: [[@LINE-1]]:21: warning: local copy 'weird_1'
- // CHECK-FIXES: const WeirdCopyCtorType& weird_1(orig);
- weird_1.constMethod();
-
- WeirdCopyCtorType weird_2 = orig;
- // CHECK-MESSAGES: [[@LINE-1]]:21: warning: local copy 'weird_2'
- // CHECK-FIXES: const WeirdCopyCtorType& weird_2 = orig;
- weird_2.constMethod();
-}
-
-void NegativeLocalCopySimpleTypes() {
- int i1 = 0;
- int i2 = i1;
-}
-
-void NegativeLocalCopyCopyIsModified() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType neg_copy_1 = orig;
- neg_copy_1.nonConstMethod();
-}
-
-void NegativeLocalCopyOriginalIsModified() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType neg_copy_2 = orig;
- orig.nonConstMethod();
-}
-
-void NegativeLocalCopyUsedAsRefArg() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType neg_copy_3 = orig;
- mutate(neg_copy_3);
-}
-
-void NegativeLocalCopyUsedAsPointerArg() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType neg_copy_4 = orig;
- mutate(&neg_copy_4);
-}
-
-void NegativeLocalCopyCopyFromGlobal() {
- ExpensiveToCopyType neg_copy_5 = global_expensive_to_copy_type;
-}
-
-void NegativeLocalCopyCopyToStatic() {
- ExpensiveToCopyType orig;
- static ExpensiveToCopyType neg_copy_6 = orig;
-}
-
-void NegativeLocalCopyNonConstInForLoop() {
- ExpensiveToCopyType orig;
- for (ExpensiveToCopyType neg_copy_7 = orig; orig.constMethod();
- orig.nonConstMethod()) {
- orig.constMethod();
- }
-}
-
-void NegativeLocalCopyWeirdNonCopy() {
- WeirdCopyCtorType orig;
- WeirdCopyCtorType neg_weird_1(orig, false);
- WeirdCopyCtorType neg_weird_2(orig, true);
-}
-void WarningOnlyMultiDeclStmt() {
- ExpensiveToCopyType orig;
- ExpensiveToCopyType copy = orig, copy2;
- // CHECK-MESSAGES: [[@LINE-1]]:23: warning: local copy 'copy' of the variable 'orig' is never modified; consider avoiding the copy [performance-unnecessary-copy-initialization]
- // CHECK-FIXES: ExpensiveToCopyType copy = orig, copy2;
-}
-
-class Element {};
-class Container {
-public:
- class Iterator {
- public:
- void operator++();
- Element operator*();
- bool operator!=(const Iterator &);
- WeirdCopyCtorType c;
- };
- const Iterator &begin() const;
- const Iterator &end() const;
-};
-
-void implicitVarFalsePositive() {
- for (const Element &E : Container()) {
- }
-}
Removed: clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp?rev=374539&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-unnecessary-value-param-allowed-types.cpp (removed)
@@ -1,75 +0,0 @@
-// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t -- -config="{CheckOptions: [{key: performance-unnecessary-value-param.AllowedTypes, value: '[Pp]ointer$;[Pp]tr$;[Rr]ef(erence)?$'}]}" --
-
-struct SmartPointer {
- ~SmartPointer();
-};
-
-struct smart_pointer {
- ~smart_pointer();
-};
-
-struct SmartPtr {
- ~SmartPtr();
-};
-
-struct smart_ptr {
- ~smart_ptr();
-};
-
-struct SmartReference {
- ~SmartReference();
-};
-
-struct smart_reference {
- ~smart_reference();
-};
-
-struct SmartRef {
- ~SmartRef();
-};
-
-struct smart_ref {
- ~smart_ref();
-};
-
-struct OtherType {
- ~OtherType();
-};
-
-template <typename T> struct SomeComplexTemplate {
- ~SomeComplexTemplate();
-};
-
-typedef SomeComplexTemplate<int> NotTooComplexRef;
-
-void negativeSmartPointer(SmartPointer P) {
-}
-
-void negative_smart_pointer(smart_pointer p) {
-}
-
-void negativeSmartPtr(SmartPtr P) {
-}
-
-void negative_smart_ptr(smart_ptr p) {
-}
-
-void negativeSmartReference(SmartReference R) {
-}
-
-void negative_smart_reference(smart_reference r) {
-}
-
-void negativeSmartRef(SmartRef R) {
-}
-
-void negative_smart_ref(smart_ref r) {
-}
-
-void positiveOtherType(OtherType O) {
- // CHECK-MESSAGES: [[@LINE-1]]:34: warning: the parameter 'O' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
- // CHECK-FIXES: void positiveOtherType(const OtherType& O) {
-}
-
-void negativeNotTooComplexRef(NotTooComplexRef R) {
-}
More information about the cfe-commits
mailing list