File: fill-in-missing-abstract-methods-perform.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 (126 lines) | stat: -rw-r--r-- 5,030 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
template <typename T>
struct Generic {  T x; };

struct AbstractClass {
  virtual void pureMethod() = 0;
  virtual void aPureMethod(int (*fptr)(), Generic<int> y) = 0;
  virtual int anotherPureMethod(const int &x) const = 0;
  virtual int operator + (int) const = 0;
  virtual void otherMethod() { }
};

struct Base {
  virtual void nonAbstractClassMethod() { }
};

struct Target : Base, AbstractClass {
};
// CHECK1: "void pureMethod() override;\n\nvoid aPureMethod(int (*fptr)(), Generic<int> y) override;\n\nint anotherPureMethod(const int &x) const override;\n\nint operator+(int) const override;\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1

// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:16:1 %s | FileCheck --check-prefix=CHECK1 %s

struct SubTarget : AbstractClass {
  int anotherPureMethod(const int &) const { return 0; }
#ifdef HAS_OP
  int operator + (int) const override { return 2; }
#endif
};

struct Target2 : SubTarget, Base {
};
// CHECK2: "void pureMethod() override;\n\nvoid aPureMethod(int (*fptr)(), Generic<int> y) override;\n\nint operator+(int) const override;\n\n" [[@LINE-1]]:1
// CHECK3: "void pureMethod() override;\n\nvoid aPureMethod(int (*fptr)(), Generic<int> y) override;\n\n" [[@LINE-2]]:1

// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:29:1 %s | FileCheck --check-prefix=CHECK2 %s
// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:29:1 %s -DHAS_OP | FileCheck --check-prefix=CHECK3 %s

struct Abstract2 {
  virtual void firstMethod(int x, int y) = 0;
  virtual void secondMethod(int, int) { }
  virtual void thirdMethod(int a) = 0;
  virtual void fourthMethod() = 0;
};

struct FillInGoodLocations : Base, Abstract2 {

  void secondMethod(int, int) override; // comment

  void unrelatedMethod();

};
// CHECK4: "\n\nvoid firstMethod(int x, int y) override;\n\nvoid thirdMethod(int a) override;\n\nvoid fourthMethod() override;\n" [[@LINE-5]]:51 -> [[@LINE-5]]:51
// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:44:1 %s | FileCheck --check-prefix=CHECK4 %s

struct FillInGoodLocations2 : FillInGoodLocations, AbstractClass {

  void fourthMethod() override;

  // comment
  void unrelatedMethod();

  int operator + (int) const override;
};
// CHECK5: "\n\nvoid firstMethod(int x, int y) override;\n\nvoid thirdMethod(int a) override;\n" [[@LINE-7]]:32 -> [[@LINE-7]]:32
// CHECK5-NEXT: "\n\nvoid pureMethod() override;\n\nvoid aPureMethod(int (*fptr)(), Generic<int> y) override;\n\nint anotherPureMethod(const int &x) const override;\n" [[@LINE-3]]:39 -> [[@LINE-3]]:39
// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:54:1 %s | FileCheck --check-prefix=CHECK5 %s

struct FillInGoodLocations3 : Base, AbstractClass, Abstract2 {

  // comment
  void unrelatedMethod();

  void thirdMethod(int a) override;

  void firstMethod(int x, int y) override;

};
// CHECK6: "\n\nvoid fourthMethod() override;\n" [[@LINE-3]]:43 -> [[@LINE-3]]:43
// CHECK6-NEXT: "void pureMethod() override;\n\nvoid aPureMethod(int (*fptr)(), Generic<int> y) override;\n\nint anotherPureMethod(const int &x) const override;\n\nint operator+(int) const override;\n\n" [[@LINE-2]]:1 -> [[@LINE-2]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:67:1 %s | FileCheck --check-prefix=CHECK6 %s

struct FIllInGoodLocationsWithMacros : Abstract2 {
#define METHOD(decl) void decl override;

  METHOD(thirdMethod(int a))
  METHOD(firstMethod(int x, int y)) void foo();
};
// CHECK7: "\n\nvoid fourthMethod() override;\n" [[@LINE-2]]:36 -> [[@LINE-2]]:36
// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:81:1 %s | FileCheck --check-prefix=CHECK7 %s

template<typename T>
class GenericType : Abstract2 {

};
// CHECK8: "void firstMethod(int x, int y) override;\n\nvoid thirdMethod(int a) override;\n\nvoid fourthMethod() override;\n\n" [[@LINE-1]]:1

struct GenericSubType : GenericType<int> {

};
// CHECK8: "void firstMethod(int x, int y) override;\n\nvoid thirdMethod(int a) override;\n\nvoid fourthMethod() override;\n\n" [[@LINE-1]]:1

// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=%s:91:1 -at=%s:96:1 %s | FileCheck --check-prefix=CHECK8 %s


struct BaseClass2
{
    virtual ~BaseClass2();
    virtual int load() = 0;
};

// correct-implicit-destructor-placement: +1:1
struct DerivedImplicitDestructorClass2
: public BaseClass2
{

}; // CHECK-DESTRUCTOR: "int load() override;\n\n" [[@LINE]]:1

// Don't insert methods after the destructor:
// correct-destructor-placement: +1:1
struct DerivedExplicitDestructorClass2
: public BaseClass2 {
  ~DerivedImplicitDestructorClass2();


}; // CHECK-DESTRUCTOR: "int load() override;\n\n" [[@LINE]]:1

// RUN: clang-refactor-test perform -action fill-in-missing-abstract-methods -at=correct-implicit-destructor-placement -at=correct-destructor-placement %s | FileCheck --check-prefix=CHECK-DESTRUCTOR %s