Skip to content

Commit 4f775bc

Browse files
authored
merge main into amd-staging (llvm#1327)
2 parents e1f2791 + 024cc97 commit 4f775bc

File tree

102 files changed

+4478
-444
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+4478
-444
lines changed

clang-tools-extra/clangd/HeaderSourceSwitch.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ std::optional<Path> getCorrespondingHeaderOrSource(
2222
PathRef OriginalFile, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
2323
llvm::StringRef SourceExtensions[] = {".cpp", ".c", ".cc", ".cxx",
2424
".c++", ".m", ".mm"};
25-
llvm::StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx", ".inc"};
25+
llvm::StringRef HeaderExtensions[] = {".h", ".hh", ".hpp", ".hxx",
26+
".inc", ".cppm", ".ccm", ".cxxm",
27+
".c++m", ".ixx"};
2628

2729
llvm::StringRef PathExt = llvm::sys::path::extension(OriginalFile);
2830

clang-tools-extra/clangd/unittests/HeaderSourceSwitchTests.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,44 @@ TEST(HeaderSourceSwitchTest, FileHeuristic) {
7676
EXPECT_FALSE(PathResult.has_value());
7777
}
7878

79+
TEST(HeaderSourceSwitchTest, ModuleInterfaces) {
80+
MockFS FS;
81+
82+
auto FooCC = testPath("foo.cc");
83+
auto FooCPPM = testPath("foo.cppm");
84+
FS.Files[FooCC];
85+
FS.Files[FooCPPM];
86+
std::optional<Path> PathResult =
87+
getCorrespondingHeaderOrSource(FooCC, FS.view(std::nullopt));
88+
EXPECT_TRUE(PathResult.has_value());
89+
ASSERT_EQ(*PathResult, FooCPPM);
90+
91+
auto Foo2CPP = testPath("foo2.cpp");
92+
auto Foo2CCM = testPath("foo2.ccm");
93+
FS.Files[Foo2CPP];
94+
FS.Files[Foo2CCM];
95+
PathResult = getCorrespondingHeaderOrSource(Foo2CPP, FS.view(std::nullopt));
96+
EXPECT_TRUE(PathResult.has_value());
97+
ASSERT_EQ(*PathResult, Foo2CCM);
98+
99+
auto Foo3CXX = testPath("foo3.cxx");
100+
auto Foo3CXXM = testPath("foo3.cxxm");
101+
FS.Files[Foo3CXX];
102+
FS.Files[Foo3CXXM];
103+
PathResult = getCorrespondingHeaderOrSource(Foo3CXX, FS.view(std::nullopt));
104+
EXPECT_TRUE(PathResult.has_value());
105+
ASSERT_EQ(*PathResult, Foo3CXXM);
106+
107+
auto Foo4CPLUSPLUS = testPath("foo4.c++");
108+
auto Foo4CPLUSPLUSM = testPath("foo4.c++m");
109+
FS.Files[Foo4CPLUSPLUS];
110+
FS.Files[Foo4CPLUSPLUSM];
111+
PathResult =
112+
getCorrespondingHeaderOrSource(Foo4CPLUSPLUS, FS.view(std::nullopt));
113+
EXPECT_TRUE(PathResult.has_value());
114+
ASSERT_EQ(*PathResult, Foo4CPLUSPLUSM);
115+
}
116+
79117
MATCHER_P(declNamed, Name, "") {
80118
if (const NamedDecl *ND = dyn_cast<NamedDecl>(arg))
81119
if (ND->getQualifiedNameAsString() == Name)

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() {}

0 commit comments

Comments
 (0)