Skip to content

Commit c1ed4f6

Browse files
authored
[clang-doc] Format test files (#132428)
Many of the test files had an inconsistent formatting. This patch ran clang-format over them using the project's .clang-format file, with column limit = 0, to prevent test directives from being split over multiple lines.
1 parent 71a0cfd commit c1ed4f6

File tree

9 files changed

+74
-92
lines changed

9 files changed

+74
-92
lines changed

clang-tools-extra/test/clang-doc/DR-131697.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@ int main() {
1313
}
1414

1515
//--- compile_commands.json
16-
[
17-
{
18-
"directory": "foo",
19-
"file":"main.cpp",
20-
"command":"clang main.cpp -c"
21-
}
22-
]
16+
[{
17+
"directory" : "foo",
18+
"file" : "main.cpp",
19+
"command" : "clang main.cpp -c"
20+
}]
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#include "Calculator.h"
22

33
int Calculator::add(int a, int b) {
4-
return a + b;
4+
return a + b;
55
}
66

77
int Calculator::subtract(int a, int b) {
8-
return a - b;
8+
return a - b;
99
}
1010

1111
int Calculator::multiply(int a, int b) {
12-
return a * b;
12+
return a * b;
1313
}
1414

1515
double Calculator::divide(int a, int b) {
16-
return static_cast<double>(a) / b;
16+
return static_cast<double>(a) / b;
1717
}

clang-tools-extra/test/clang-doc/Inputs/basic-project/src/Circle.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@
33
Circle::Circle(double radius) : radius_(radius) {}
44

55
double Circle::area() const {
6-
return 3.141 * radius_ * radius_;
6+
return 3.141 * radius_ * radius_;
77
}
88

99
double Circle::perimeter() const {
10-
return 3.141 * radius_;
10+
return 3.141 * radius_;
1111
}
12-
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "Rectangle.h"
22

33
Rectangle::Rectangle(double width, double height)
4-
: width_(width), height_(height) {}
4+
: width_(width), height_(height) {}
55

66
double Rectangle::area() const {
7-
return width_ * height_;
7+
return width_ * height_;
88
}
99

1010
double Rectangle::perimeter() const {
11-
return 2 * (width_ + height_);
11+
return 2 * (width_ + height_);
1212
}

clang-tools-extra/test/clang-doc/enum.cpp

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,15 @@
1414
// RUN: FileCheck %s < %t/Vehicles/index.md --check-prefix=MD-VEHICLES-LINE
1515
// RUN: FileCheck %s < %t/Vehicles/index.md --check-prefix=MD-VEHICLES
1616

17-
1817
/**
1918
* @brief For specifying RGB colors
2019
*/
2120
enum Color {
22-
// MD-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
23-
// HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
24-
Red, ///< Comment 1
21+
// MD-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
22+
// HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
23+
Red, ///< Comment 1
2524
Green, ///< Comment 2
26-
Blue ///< Comment 3
25+
Blue ///< Comment 3
2726
};
2827

2928
// MD-INDEX: ## Enums
@@ -49,8 +48,8 @@ enum Color {
4948
* @brief Shape Types
5049
*/
5150
enum class Shapes {
52-
// MD-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
53-
// HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
51+
// MD-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
52+
// HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
5453

5554
/// Comment 1
5655
Circle,
@@ -77,22 +76,20 @@ enum class Shapes {
7776
// HTML-INDEX: <td>2</td>
7877
// HTML-INDEX: <p> Comment 3</p>
7978

80-
81-
8279
class Animals {
83-
// MD-ANIMAL-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
84-
// HTML-ANIMAL-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
80+
// MD-ANIMAL-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
81+
// HTML-ANIMAL-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
8582
public:
86-
/**
87-
* @brief specify what animal the class is
88-
*/
89-
enum AnimalType {
90-
// MD-ANIMAL-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
91-
// HTML-ANIMAL-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
92-
Dog, ///< Man's best friend
93-
Cat, ///< Man's other best friend
94-
Iguana ///< A lizard
95-
};
83+
/**
84+
* @brief specify what animal the class is
85+
*/
86+
enum AnimalType {
87+
// MD-ANIMAL-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
88+
// HTML-ANIMAL-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
89+
Dog, ///< Man's best friend
90+
Cat, ///< Man's other best friend
91+
Iguana ///< A lizard
92+
};
9693
};
9794

9895
// HTML-ANIMAL: <h1>class Animals</h1>
@@ -108,7 +105,6 @@ class Animals {
108105
// HTML-ANIMAL: <td>2</td>
109106
// HTML-ANIMAL: <p> A lizard</p>
110107

111-
112108
// MD-ANIMAL: # class Animals
113109
// MD-ANIMAL: ## Enums
114110
// MD-ANIMAL: | enum AnimalType |
@@ -118,21 +114,20 @@ class Animals {
118114
// MD-ANIMAL: | Iguana |
119115
// MD-ANIMAL: **brief** specify what animal the class is
120116

121-
122117
namespace Vehicles {
123-
/**
124-
* @brief specify type of car
125-
*/
126-
enum Car {
127-
// MD-VEHICLES-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
128-
// HTML-VEHICLES-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
129-
130-
Sedan, ///< Comment 1
131-
SUV, ///< Comment 2
132-
Pickup, ///< Comment 3
133-
Hatchback ///< Comment 4
134-
};
135-
}
118+
/**
119+
* @brief specify type of car
120+
*/
121+
enum Car {
122+
// MD-VEHICLES-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
123+
// HTML-VEHICLES-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
124+
125+
Sedan, ///< Comment 1
126+
SUV, ///< Comment 2
127+
Pickup, ///< Comment 3
128+
Hatchback ///< Comment 4
129+
};
130+
} // namespace Vehicles
136131

137132
// MD-VEHICLES: # namespace Vehicles
138133
// MD-VEHICLES: ## Enums
@@ -159,7 +154,6 @@ namespace Vehicles {
159154
// HTML-VEHICLES: <td>3</td>
160155
// HTML-VEHICLES: <p> Comment 4</p>
161156

162-
163157
enum ColorUserSpecified {
164158
RedUserSpecified = 'A',
165159
GreenUserSpecified = 2,

clang-tools-extra/test/clang-doc/namespace.cpp

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,19 @@
3939
// RUN: FileCheck %s < %t/all_files.md -check-prefix=MD-ALL-FILES
4040
// RUN: FileCheck %s < %t/index.md -check-prefix=MD-INDEX
4141

42-
43-
4442
// Anonymous Namespace
45-
namespace
46-
{
47-
void anonFunction() {}
43+
namespace {
44+
void anonFunction() {}
4845
// MD-ANON-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
4946
// HTML-ANON-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
5047

51-
class AnonClass {};
48+
class AnonClass {};
5249
// MD-ANON-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
5350
// HTML-ANON-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
5451

5552
// MD-ANON-CLASS: # class AnonClass
5653
// HTML-ANON-CLASS: <h1>class AnonClass</h1>
57-
}
54+
} // namespace
5855

5956
// MD-ANON-INDEX: # namespace @nonymous_namespace
6057
// MD-ANON-INDEX: Anonymous Namespace
@@ -72,16 +69,15 @@ namespace
7269
// HTML-ANON-INDEX: <h3 id="{{([0-9A-F]{40})}}">anonFunction</h3>
7370
// HTML-ANON-INDEX: <p>void anonFunction()</p>
7471

75-
7672
// Primary Namespace
7773
namespace PrimaryNamespace {
78-
// Function in PrimaryNamespace
79-
void functionInPrimaryNamespace() {}
74+
// Function in PrimaryNamespace
75+
void functionInPrimaryNamespace() {}
8076
// MD-PRIMARY-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
8177
// HTML-PRIMARY-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
8278

83-
// Class in PrimaryNamespace
84-
class ClassInPrimaryNamespace {};
79+
// Class in PrimaryNamespace
80+
class ClassInPrimaryNamespace {};
8581
// MD-PRIMARY-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
8682
// HTML-PRIMARY-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
8783

@@ -91,15 +87,15 @@ namespace PrimaryNamespace {
9187
// HTML-PRIMARY-CLASS: <h1>class ClassInPrimaryNamespace</h1>
9288
// HTML-PRIMARY-CLASS: <p> Class in PrimaryNamespace</p>
9389

94-
// Nested namespace
95-
namespace NestedNamespace {
96-
// Function in NestedNamespace
97-
void functionInNestedNamespace() {}
90+
// Nested namespace
91+
namespace NestedNamespace {
92+
// Function in NestedNamespace
93+
void functionInNestedNamespace() {}
9894
// MD-NESTED-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
9995
// HTML-NESTED-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
10096

101-
// Class in NestedNamespace
102-
class ClassInNestedNamespace {};
97+
// Class in NestedNamespace
98+
class ClassInNestedNamespace {};
10399
// MD-NESTED-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
104100
// HTML-NESTED-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
105101

@@ -108,7 +104,7 @@ namespace PrimaryNamespace {
108104

109105
// HTML-NESTED-CLASS: <h1>class ClassInNestedNamespace</h1>
110106
// HTML-NESTED-CLASS: <p> Class in NestedNamespace</p>
111-
}
107+
} // namespace NestedNamespace
112108

113109
// MD-NESTED-INDEX: # namespace NestedNamespace
114110
// MD-NESTED-INDEX: Nested namespace
@@ -127,7 +123,7 @@ namespace PrimaryNamespace {
127123
// HTML-NESTED-INDEX: <h3 id="{{([0-9A-F]{40})}}">functionInNestedNamespace</h3>
128124
// HTML-NESTED-INDEX: <p>void functionInNestedNamespace()</p>
129125
// HTML-NESTED-INDEX: <p> Function in NestedNamespace</p>
130-
}
126+
} // namespace PrimaryNamespace
131127

132128
// MD-PRIMARY-INDEX: # namespace PrimaryNamespace
133129
// MD-PRIMARY-INDEX: Primary Namespace
@@ -151,16 +147,15 @@ namespace PrimaryNamespace {
151147
// HTML-PRIMARY-INDEX: <p>void functionInPrimaryNamespace()</p>
152148
// HTML-PRIMARY-INDEX: <p> Function in PrimaryNamespace</p>
153149

154-
155150
// AnotherNamespace
156151
namespace AnotherNamespace {
157-
// Function in AnotherNamespace
158-
void functionInAnotherNamespace() {}
152+
// Function in AnotherNamespace
153+
void functionInAnotherNamespace() {}
159154
// MD-ANOTHER-INDEX-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
160155
// HTML-ANOTHER-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
161156

162-
// Class in AnotherNamespace
163-
class ClassInAnotherNamespace {};
157+
// Class in AnotherNamespace
158+
class ClassInAnotherNamespace {};
164159
// MD-ANOTHER-CLASS-LINE: *Defined at {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp#[[@LINE-1]]*
165160
// HTML-ANOTHER-CLASS-LINE: <p>Defined at line [[@LINE-2]] of file {{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}namespace.cpp</p>
166161

@@ -170,7 +165,7 @@ namespace AnotherNamespace {
170165
// HTML-ANOTHER-CLASS: <h1>class ClassInAnotherNamespace</h1>
171166
// HTML-ANOTHER-CLASS: <p> Class in AnotherNamespace</p>
172167

173-
}
168+
} // namespace AnotherNamespace
174169

175170
// MD-ANOTHER-INDEX: # namespace AnotherNamespace
176171
// MD-ANOTHER-INDEX: AnotherNamespace
@@ -275,14 +270,12 @@ namespace AnotherNamespace {
275270
// HTML-GLOBAL-INDEX: <li>AnotherNamespace</li>
276271
// HTML-GLOBAL-INDEX: <li>PrimaryNamespace</li>
277272

278-
279273
// MD-GLOBAL-INDEX: # Global Namespace
280274
// MD-GLOBAL-INDEX: ## Namespaces
281275
// MD-GLOBAL-INDEX: * [@nonymous_namespace](..{{[\/]}}@nonymous_namespace{{[\/]}}index.md)
282276
// MD-GLOBAL-INDEX: * [AnotherNamespace](..{{[\/]}}AnotherNamespace{{[\/]}}index.md)
283277
// MD-GLOBAL-INDEX: * [PrimaryNamespace](..{{[\/]}}PrimaryNamespace{{[\/]}}index.md)
284278

285-
286279
// MD-ALL-FILES: # All Files
287280
// MD-ALL-FILES: ## [@nonymous_namespace](@nonymous_namespace{{[\/]}}index.md)
288281
// MD-ALL-FILES: ## [AnotherNamespace](AnotherNamespace{{[\/]}}index.md)

clang-tools-extra/test/clang-doc/single-file-public.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99

1010
class Record {
1111
private:
12-
void function_private();
12+
void function_private();
1313

1414
public:
15-
void function_public();
15+
void function_public();
1616
};
1717

1818
void Record::function_private() {}

clang-tools-extra/test/clang-doc/templates.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// MD: # Global Namespace
2020
// MD: ## Functions
2121

22-
template<class... T>
22+
template <class... T>
2323
void ParamPackFunction(T... args);
2424

2525
// YAML-NEXT: ChildFunctions:
@@ -44,7 +44,7 @@ void ParamPackFunction(T... args);
4444
// MD: ### ParamPackFunction
4545
// MD: *void ParamPackFunction(T... args)*
4646

47-
template<typename T, int U = 1>
47+
template <typename T, int U = 1>
4848
void function(T x) {}
4949

5050
// YAML-NEXT: - USR: '{{([0-9A-F]{40})}}'
@@ -70,7 +70,7 @@ void function(T x) {}
7070
// MD: *void function(T x)*
7171
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 23]]*
7272

73-
template<>
73+
template <>
7474
void function<bool, 0>(bool x) {}
7575

7676
// YAML-NEXT: - USR: '{{([0-9A-F]{40})}}'
@@ -101,13 +101,13 @@ void function<bool, 0>(bool x) {}
101101
/// A Tuple type
102102
///
103103
/// Does Tuple things.
104-
template<typename ...Tys>
105-
struct tuple{};
104+
template <typename... Tys>
105+
struct tuple {};
106106

107107
/// A function with a tuple parameter
108108
///
109109
/// \param t The input to func_with_tuple_param
110-
tuple<int,int,bool> func_with_tuple_param(tuple<int,int,bool> t){ return t;}
110+
tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> t) { return t; }
111111

112112
// YAML-NEXT: - USR: '{{([0-9A-F]{40})}}'
113113
// YAML-NEXT: Name: 'func_with_tuple_param'
@@ -154,4 +154,3 @@ tuple<int,int,bool> func_with_tuple_param(tuple<int,int,bool> t){ return t;}
154154
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 44]]*
155155
// MD: A function with a tuple parameter
156156
// MD: **t** The input to func_with_tuple_param
157-

clang-tools-extra/test/clang-doc/test-path-abs.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
// RUN: FileCheck %s -input-file=%t/index_json.js -check-prefix=JSON-INDEX
44

55
// JSON-INDEX: var RootPath = "{{.*}}test-path-abs.cpp.tmp";
6-

0 commit comments

Comments
 (0)