aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration.cpp158
1 files changed, 79 insertions, 79 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration.cpp
index 7489d5d..ce3a0da 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/isolate-declaration.cpp
@@ -8,14 +8,14 @@ void f2() {
int i, j, *k, lala = 42;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int i;
- // CHECK-FIXES: {{^ }}int j;
- // CHECK-FIXES: {{^ }}int *k;
- // CHECK-FIXES: {{^ }}int lala = 42;
+ // CHECK-FIXES: int j;
+ // CHECK-FIXES: int *k;
+ // CHECK-FIXES: int lala = 42;
int normal, weird = /* comment */ 42;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int normal;
- // CHECK-FIXES: {{^ }}int weird = /* comment */ 42;
+ // CHECK-FIXES: int weird = /* comment */ 42;
int /* here is a comment */ v1,
// another comment
@@ -23,79 +23,79 @@ void f2() {
;
// CHECK-MESSAGES: [[@LINE-4]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int /* here is a comment */ v1;
- // CHECK-FIXES: {{^ }}int /* here is a comment */ // another comment
- // CHECK-FIXES: {{^ }}v2 = 42 // Ok, more comments
- // CHECK-FIXES: {{^ }};
+ // CHECK-FIXES: int /* here is a comment */ // another comment
+ // CHECK-FIXES: v2 = 42 // Ok, more comments
+ // CHECK-FIXES: ;
auto int1 = 42, int2 = 0, int3 = 43;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: auto int1 = 42;
- // CHECK-FIXES: {{^ }}auto int2 = 0;
- // CHECK-FIXES: {{^ }}auto int3 = 43;
+ // CHECK-FIXES: auto int2 = 0;
+ // CHECK-FIXES: auto int3 = 43;
decltype(auto) ptr1 = &int1, ptr2 = &int1;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: decltype(auto) ptr1 = &int1;
- // CHECK-FIXES: {{^ }}decltype(auto) ptr2 = &int1;
+ // CHECK-FIXES: decltype(auto) ptr2 = &int1;
decltype(k) ptr3 = &int1, ptr4 = &int1;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: decltype(k) ptr3 = &int1;
- // CHECK-FIXES: {{^ }}decltype(k) ptr4 = &int1;
+ // CHECK-FIXES: decltype(k) ptr4 = &int1;
}
void f3() {
int i, *pointer1;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int i;
- // CHECK-FIXES: {{^ }}int *pointer1;
+ // CHECK-FIXES: int *pointer1;
//
int *pointer2 = nullptr, *pointer3 = &i;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int *pointer2 = nullptr;
- // CHECK-FIXES: {{^ }}int *pointer3 = &i;
+ // CHECK-FIXES: int *pointer3 = &i;
int *(i_ptr) = nullptr, *((i_ptr2));
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int *(i_ptr) = nullptr;
- // CHECK-FIXES: {{^ }}int *((i_ptr2));
+ // CHECK-FIXES: int *((i_ptr2));
float(*f_ptr)[42], (((f_value))) = 42;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: float (*f_ptr)[42];
- // CHECK-FIXES: {{^ }}float (((f_value))) = 42;
+ // CHECK-FIXES: float (((f_value))) = 42;
float(((*f_ptr2)))[42], ((*f_ptr3)), f_value2 = 42.f;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: float (((*f_ptr2)))[42];
- // CHECK-FIXES: {{^ }}float ((*f_ptr3));
- // CHECK-FIXES: {{^ }}float f_value2 = 42.f;
+ // CHECK-FIXES: float ((*f_ptr3));
+ // CHECK-FIXES: float f_value2 = 42.f;
float(((*f_ptr4)))[42], *f_ptr5, ((f_value3));
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: float (((*f_ptr4)))[42];
- // CHECK-FIXES: {{^ }}float *f_ptr5;
- // CHECK-FIXES: {{^ }}float ((f_value3));
+ // CHECK-FIXES: float *f_ptr5;
+ // CHECK-FIXES: float ((f_value3));
void(((*f2))(int)), (*g2)(int, float);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: void (((*f2))(int));
- // CHECK-FIXES: {{^ }}void (*g2)(int, float);
+ // CHECK-FIXES: void (*g2)(int, float);
float(*(*(*f_ptr6)))[42], (*f_ptr7);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: float (*(*(*f_ptr6)))[42];
- // CHECK-FIXES: {{^ }}float (*f_ptr7);
+ // CHECK-FIXES: float (*f_ptr7);
}
void f4() {
double d = 42. /* foo */, z = 43., /* hi */ y, c /* */ /* */, l = 2.;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: double d = 42. /* foo */;
- // CHECK-FIXES: {{^ }}double z = 43.;
- // CHECK-FIXES: {{^ }}double /* hi */ y;
- // CHECK-FIXES: {{^ }}double c /* */ /* */;
- // CHECK-FIXES: {{^ }}double l = 2.;
+ // CHECK-FIXES: double z = 43.;
+ // CHECK-FIXES: double /* hi */ y;
+ // CHECK-FIXES: double c /* */ /* */;
+ // CHECK-FIXES: double l = 2.;
}
struct SomeClass {
@@ -123,35 +123,35 @@ void f5() {
SomeClass v1, v2(42), v3{42}, v4(42.5);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: SomeClass v1;
- // CHECK-FIXES: {{^ }}SomeClass v2(42);
- // CHECK-FIXES: {{^ }}SomeClass v3{42};
- // CHECK-FIXES: {{^ }}SomeClass v4(42.5);
+ // CHECK-FIXES: SomeClass v2(42);
+ // CHECK-FIXES: SomeClass v3{42};
+ // CHECK-FIXES: SomeClass v4(42.5);
SomeClass v5 = 42, *p1 = nullptr;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: SomeClass v5 = 42;
- // CHECK-FIXES: {{^ }}SomeClass *p1 = nullptr;
+ // CHECK-FIXES: SomeClass *p1 = nullptr;
Point P1(0., 2.), P2{2., 0.};
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: Point P1(0., 2.);
- // CHECK-FIXES: {{^ }}Point P2{2., 0.};
+ // CHECK-FIXES: Point P2{2., 0.};
Rectangle R1({0., 0.}, {1., -2.}), R2{{0., 1.}, {1., 0.}}, R3(P1, P2), R4{P1, P2};
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: Rectangle R1({0., 0.}, {1., -2.});
- // CHECK-FIXES: {{^ }}Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
- // CHECK-FIXES: {{^ }}Rectangle R3(P1, P2);
- // CHECK-FIXES: {{^ }}Rectangle R4{P1, P2};
+ // CHECK-FIXES: Rectangle R2{{[{][{]}}0., 1.}, {1., 0.{{[}][}]}};
+ // CHECK-FIXES: Rectangle R3(P1, P2);
+ // CHECK-FIXES: Rectangle R4{P1, P2};
}
void f6() {
int array1[] = {1, 2, 3, 4}, array2[] = {1, 2, 3}, value1, value2 = 42;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int array1[] = {1, 2, 3, 4};
- // CHECK-FIXES: {{^ }}int array2[] = {1, 2, 3};
- // CHECK-FIXES: {{^ }}int value1;
- // CHECK-FIXES: {{^ }}int value2 = 42;
+ // CHECK-FIXES: int array2[] = {1, 2, 3};
+ // CHECK-FIXES: int value1;
+ // CHECK-FIXES: int value2 = 42;
}
template <typename T>
@@ -164,25 +164,25 @@ void f7() {
TemplatedType<int> TT1(42), TT2{42}, TT3;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: TemplatedType<int> TT1(42);
- // CHECK-FIXES: {{^ }}TemplatedType<int> TT2{42};
- // CHECK-FIXES: {{^ }}TemplatedType<int> TT3;
+ // CHECK-FIXES: TemplatedType<int> TT2{42};
+ // CHECK-FIXES: TemplatedType<int> TT3;
//
TemplatedType<int *> *TT4(nullptr), TT5, **TT6 = nullptr, *const *const TT7{nullptr};
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: TemplatedType<int *> *TT4(nullptr);
- // CHECK-FIXES: {{^ }}TemplatedType<int *> TT5;
- // CHECK-FIXES: {{^ }}TemplatedType<int *> **TT6 = nullptr;
- // CHECK-FIXES: {{^ }}TemplatedType<int *> *const *const TT7{nullptr};
+ // CHECK-FIXES: TemplatedType<int *> TT5;
+ // CHECK-FIXES: TemplatedType<int *> **TT6 = nullptr;
+ // CHECK-FIXES: TemplatedType<int *> *const *const TT7{nullptr};
TemplatedType<int &> **TT8(nullptr), *TT9;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: TemplatedType<int &> **TT8(nullptr);
- // CHECK-FIXES: {{^ }}TemplatedType<int &> *TT9;
+ // CHECK-FIXES: TemplatedType<int &> *TT9;
TemplatedType<int *> TT10{nullptr}, *TT11(nullptr);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: TemplatedType<int *> TT10{nullptr};
- // CHECK-FIXES: {{^ }}TemplatedType<int *> *TT11(nullptr);
+ // CHECK-FIXES: TemplatedType<int *> *TT11(nullptr);
}
void forbidden_transformations() {
@@ -199,7 +199,7 @@ void macros() {
int *p1 = NULL, *p2 = NULL;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int *p1 = NULL;
- // CHECK-FIXES: {{^ }}int *p2 = NULL;
+ // CHECK-FIXES: int *p2 = NULL;
// Macros are involved, so there will be no transformation
MY_NICE_TYPE p3, v1, v2;
@@ -253,25 +253,25 @@ void complex_typedefs() {
IntPtr intptr1, intptr2 = nullptr, intptr3;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: IntPtr intptr1;
- // CHECK-FIXES: {{^ }}IntPtr intptr2 = nullptr;
- // CHECK-FIXES: {{^ }}IntPtr intptr3;
+ // CHECK-FIXES: IntPtr intptr2 = nullptr;
+ // CHECK-FIXES: IntPtr intptr3;
IntPtr *DoublePtr1 = nullptr, **TriplePtr, SinglePtr = nullptr;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: IntPtr *DoublePtr1 = nullptr;
- // CHECK-FIXES: {{^ }}IntPtr **TriplePtr;
- // CHECK-FIXES: {{^ }}IntPtr SinglePtr = nullptr;
+ // CHECK-FIXES: IntPtr **TriplePtr;
+ // CHECK-FIXES: IntPtr SinglePtr = nullptr;
IntPtr intptr_array1[2], intptr_array2[4] = {nullptr, nullptr, nullptr, nullptr};
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: IntPtr intptr_array1[2];
- // CHECK-FIXES: {{^ }}IntPtr intptr_array2[4] = {nullptr, nullptr, nullptr, nullptr};
+ // CHECK-FIXES: IntPtr intptr_array2[4] = {nullptr, nullptr, nullptr, nullptr};
ArrayType arraytype1, arraytype2 = {1}, arraytype3;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: ArrayType arraytype1;
- // CHECK-FIXES: {{^ }}ArrayType arraytype2 = {1};
- // CHECK-FIXES: {{^ }}ArrayType arraytype3;
+ // CHECK-FIXES: ArrayType arraytype2 = {1};
+ // CHECK-FIXES: ArrayType arraytype3;
// Don't touch function declarations.
FunType funtype1, funtype2, functype3;
@@ -280,29 +280,29 @@ void complex_typedefs() {
int localFor1 = 1, localFor2 = 2;
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int localFor1 = 1;
- // CHECK-FIXES: {{^ }}int localFor2 = 2;
+ // CHECK-FIXES: int localFor2 = 2;
}
StructOne s1, s2(23), s3, s4(3), *sptr = new StructOne(2);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: StructOne s1;
- // CHECK-FIXES: {{^ }}StructOne s2(23);
- // CHECK-FIXES: {{^ }}StructOne s3;
- // CHECK-FIXES: {{^ }}StructOne s4(3);
- // CHECK-FIXES: {{^ }}StructOne *sptr = new StructOne(2);
+ // CHECK-FIXES: StructOne s2(23);
+ // CHECK-FIXES: StructOne s3;
+ // CHECK-FIXES: StructOne s4(3);
+ // CHECK-FIXES: StructOne *sptr = new StructOne(2);
struct StructOne cs1, cs2(42);
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: struct StructOne cs1;
- // CHECK-FIXES: {{^ }}struct StructOne cs2(42);
+ // CHECK-FIXES: struct StructOne cs2(42);
int *ptrArray[3], dummy, **ptrArray2[5], twoDim[2][3], *twoDimPtr[2][3];
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int *ptrArray[3];
- // CHECK-FIXES: {{^ }}int dummy;
- // CHECK-FIXES: {{^ }}int **ptrArray2[5];
- // CHECK-FIXES: {{^ }}int twoDim[2][3];
- // CHECK-FIXES: {{^ }}int *twoDimPtr[2][3];
+ // CHECK-FIXES: int dummy;
+ // CHECK-FIXES: int **ptrArray2[5];
+ // CHECK-FIXES: int twoDim[2][3];
+ // CHECK-FIXES: int *twoDimPtr[2][3];
{
void f1(int), g1(int, float);
@@ -314,12 +314,12 @@ void complex_typedefs() {
void (*f2)(int), (*g2)(int, float) = gg;
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: void (*f2)(int);
- // CHECK-FIXES: {{^ }}void (*g2)(int, float) = gg;
+ // CHECK-FIXES: void (*g2)(int, float) = gg;
void /*(*/ (/*(*/ *f3)(int), (*g3)(int, float);
// CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: void /*(*/ (/*(*/ *f3)(int);
- // CHECK-FIXES: {{^ }}void /*(*/ (*g3)(int, float);
+ // CHECK-FIXES: void /*(*/ (*g3)(int, float);
}
// clang-format off
@@ -333,26 +333,26 @@ void complex_typedefs() {
}, bb = 4;
// CHECK-MESSAGES: [[@LINE-7]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int intfunction = returner();
- // CHECK-FIXES: {{^ }}int intarray[] =
- // CHECK-FIXES: {{^ }}{
- // CHECK-FIXES: {{^ }}1,
- // CHECK-FIXES: {{^ }}2,
- // CHECK-FIXES: {{^ }}3,
- // CHECK-FIXES: {{^ }}4
- // CHECK-FIXES: {{^ }}};
- // CHECK-FIXES: {{^ }}int bb = 4;
+ // CHECK-FIXES: int intarray[] =
+ // CHECK-FIXES: {
+ // CHECK-FIXES: 1,
+ // CHECK-FIXES: 2,
+ // CHECK-FIXES: 3,
+ // CHECK-FIXES: 4
+ // CHECK-FIXES: };
+ // CHECK-FIXES: int bb = 4;
// clang-format on
TemT *T1 = &TT1, *T2 = &TT2;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: TemT *T1 = &TT1;
- // CHECK-FIXES: {{^ }}TemT *T2 = &TT2;
+ // CHECK-FIXES: TemT *T2 = &TT2;
const PointerType *PT1 = T1->getAs<PointerType>(),
*PT2 = T2->getAs<PointerType>();
// CHECK-MESSAGES: [[@LINE-2]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: const PointerType *PT1 = T1->getAs<PointerType>();
- // CHECK-FIXES: {{^ }}const PointerType *PT2 = T2->getAs<PointerType>();
+ // CHECK-FIXES: const PointerType *PT2 = T2->getAs<PointerType>();
const int *p1 = nullptr;
const int *p2 = nullptr;
@@ -360,7 +360,7 @@ void complex_typedefs() {
const int *&pref1 = p1, *&pref2 = p2;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: const int *&pref1 = p1;
- // CHECK-FIXES: {{^ }}const int *&pref2 = p2;
+ // CHECK-FIXES: const int *&pref2 = p2;
// clang-format off
const char *literal1 = "clang" "test"\
@@ -368,9 +368,9 @@ void complex_typedefs() {
*literal2 = "empty", literal3[] = "three";
// CHECK-MESSAGES: [[@LINE-3]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: const char *literal1 = "clang" "test"\
- // CHECK-FIXES: {{^ }}"one";
- // CHECK-FIXES: {{^ }}const char *literal2 = "empty";
- // CHECK-FIXES: {{^ }}const char literal3[] = "three";
+ // CHECK-FIXES: "one";
+ // CHECK-FIXES: const char *literal2 = "empty";
+ // CHECK-FIXES: const char literal3[] = "three";
// clang-format on
}
@@ -378,7 +378,7 @@ void g() try {
int i, j;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: int i;
- // CHECK-FIXES: {{^ }}int j;
+ // CHECK-FIXES: int j;
} catch (...) {
}
@@ -393,7 +393,7 @@ void memberPointers() {
MemPtr aaa = &S::a, bbb = &S::b;
// CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
// CHECK-FIXES: MemPtr aaa = &S::a;
- // CHECK-FIXES: {{^ }}MemPtr bbb = &S::b;
+ // CHECK-FIXES: MemPtr bbb = &S::b;
}
typedef int *tptr, tbt;