File: isolate-declaration-fixing.cpp

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (64 lines) | stat: -rw-r--r-- 2,698 bytes parent folder | download | duplicates (25)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// RUN: %check_clang_tidy %s readability-isolate-declaration %t
// XFAIL: *

struct S {
  int a;
  const int b;
  void f() {}
};

void member_pointers() {
  // FIXME: Memberpointers are transformed incorrect. Emit only a warning
  // for now.
  int S::*p = &S::a, S::*const q = &S::a;
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
  // CHECK-FIXES: int S::*p = &S::a;
  // CHECK-FIXES: {{^  }}int S::*const q = &S::a;

  int /* :: */ S::*pp2 = &S::a, var1 = 0;
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
  // CHECK-FIXES: int /* :: */ S::*pp2 = &S::a;
  // CHECK-FIXES: {{^  }}int var1 = 0;

  const int S::*r = &S::b, S::*t;
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
  // CHECK-FIXES: const int S::*r = &S::b;
  // CHECK-FIXES: {{^  }}const int S::*t;

  {
    int S::*mdpa1[2] = {&S::a, &S::a}, var1 = 0;
    // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
    // CHECK-FIXES: int S::*mdpa1[2] = {&S::a, &S::a};
    // CHECK-FIXES: {{^    }}int var1 = 0;

    int S ::**mdpa2[2] = {&p, &pp2}, var2 = 0;
    // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
    // CHECK-FIXES: int S ::**mdpa2[2] = {&p, &pp2};
    // CHECK-FIXES: {{^    }}int var2 = 0;

    void (S::*mdfp1)() = &S::f, (S::*mdfp2)() = &S::f;
    // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
    // CHECK-FIXES: void (S::*mdfp1)() = &S::f;
    // CHECK-FIXES: {{^    }}void (S::*mdfp2)() = &S::f;

    void (S::*mdfpa1[2])() = {&S::f, &S::f}, (S::*mdfpa2)() = &S::f;
    // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
    // CHECK-FIXES: void (S::*mdfpa1[2])() = {&S::f, &S::f};
    // CHECK-FIXES: {{^    }}void (S::*mdfpa2)() = &S::f;

    void (S::* * mdfpa3[2])() = {&mdfpa1[0], &mdfpa1[1]}, (S::*mdfpa4)() = &S::f;
    // CHECK-MESSAGES: [[@LINE-1]]:5: warning: multiple declarations in a single statement reduces readability
    // CHECK-FIXES: void (S::* * mdfpa3[2])() = {&mdfpa1[0], &mdfpa1[1]};
    // CHECK-FIXES: {{^    }}void (S::*mdfpa4)() = &S::f;
  }

  class CS {
  public:
    int a;
    const int b;
  };
  int const CS ::*pp = &CS::a, CS::*const qq = &CS::a;
  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: multiple declarations in a single statement reduces readability
  // CHECK-FIXES: int const CS ::*pp = &CS::a;
  // CHECK-FIXES: {{^  }}int const CS::*const qq = &CS::a;
}