Skip to content

Commit a517d8c

Browse files
authored
merge main into amd-staging (#834)
2 parents 387f93d + 07e7a39 commit a517d8c

File tree

457 files changed

+20318
-8737
lines changed

Some content is hidden

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

457 files changed

+20318
-8737
lines changed

clang-tools-extra/clang-doc/JSONGenerator.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,15 @@ static void serializeInfo(const ArrayRef<TemplateParamInfo> &Params,
378378
json::Value ParamsArray = Array();
379379
auto &ParamsArrayRef = *ParamsArray.getAsArray();
380380
ParamsArrayRef.reserve(Params.size());
381-
for (const auto &Param : Params)
382-
ParamsArrayRef.push_back(Param.Contents);
381+
for (size_t Idx = 0; Idx < Params.size(); ++Idx) {
382+
json::Value ParamObjVal = Object();
383+
Object &ParamObj = *ParamObjVal.getAsObject();
384+
385+
ParamObj["Param"] = Params[Idx].Contents;
386+
if (Idx == Params.size() - 1)
387+
ParamObj["End"] = true;
388+
ParamsArrayRef.push_back(ParamObjVal);
389+
}
383390
Obj["Parameters"] = ParamsArray;
384391
}
385392

@@ -622,8 +629,10 @@ static void serializeInfo(const NamespaceInfo &I, json::Object &Obj,
622629
serializeInfo(Info, Object, RepositoryUrl);
623630
};
624631

625-
if (!I.Children.Functions.empty())
632+
if (!I.Children.Functions.empty()) {
626633
serializeArray(I.Children.Functions, Obj, "Functions", SerializeInfo);
634+
Obj["HasFunctions"] = true;
635+
}
627636

628637
if (!I.Children.Concepts.empty())
629638
serializeArray(I.Children.Concepts, Obj, "Concepts", SerializeInfo);

clang-tools-extra/clang-doc/assets/class-template.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
<div class="resizer" id="resizer"></div>
108108
<div class="content">
109109
<section class="hero section-container">
110+
{{#Template}}
111+
<pre><code class="language-cpp code-clang-doc">template &lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;</code></pre>
112+
{{/Template}}
110113
<div class="hero__title">
111114
<h1 class="hero__title-large">{{TagType}} {{Name}}</h1>
112115
<p>Defined at line {{Location.LineNumber}} of file {{Location.Filename}}</p>

clang-tools-extra/clang-doc/assets/function-template.mustache

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@
77
}}
88
<div class="delimiter-container">
99
<div id="{{USR}}">
10+
{{#Template}}
11+
<pre><code class="language-cpp code-clang-doc">template &lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;</code></pre>
12+
{{/Template}}
1013
{{! Function Prototype }}
11-
<pre><code class="language-cpp code-clang-doc">{{ReturnType.Name}} {{Name}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})</code></pre>
14+
<pre><code class="language-cpp code-clang-doc">{{ReturnType.Name}} {{Name}}{{#Template}}{{#Specialization}}&lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;{{/Specialization}}{{/Template}} ({{#Params}}{{^End}}{{Type}} {{Name}}, {{/End}}{{#End}}{{Type}} {{Name}}{{/End}}{{/Params}})</code></pre>
1215
{{! Function Comments }}
1316
{{#Description}}
1417
<div>
1518
{{>Comments}}
1619
</div>
1720
{{/Description}}
21+
<p>Defined at line {{Location.LineNumber}} of file {{Location.Filename}}</p>
1822
</div>
1923
</div>

clang-tools-extra/clang-doc/assets/namespace-template.mustache

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@
4343
</ul>
4444
</li>
4545
{{/HasRecords}}
46+
{{#HasFunctions}}
47+
<li class="sidebar-section">
48+
<a class="sidebar-item" href="#Functions">Functions</a>
49+
</li>
50+
<li>
51+
<ul>
52+
{{#Functions}}
53+
<li class="sidebar-item-container">
54+
<a class="sidebar-item" href="#{{USR}}">{{Name}}{{#Template}}{{#Specialization}}&lt;{{#Parameters}}{{Param}}{{^End}}, {{/End}}{{/Parameters}}&gt;{{/Specialization}}{{/Template}}</a>
55+
</li>
56+
{{/Functions}}
57+
</ul>
58+
</li>
59+
{{/HasFunctions}}
4660
</ul>
4761
</div>
4862
<div class="resizer" id="resizer"></div>
@@ -71,6 +85,18 @@
7185
</ul>
7286
</section>
7387
{{/HasRecords}}
88+
{{#HasFunctions}}
89+
<section id="Functions" class="section-container">
90+
<h2>Functions</h2>
91+
<ul class="class-container">
92+
{{#Functions}}
93+
<li>
94+
{{>FunctionPartial}}
95+
</li>
96+
{{/Functions}}
97+
</ul>
98+
</section>
99+
{{/HasFunctions}}
74100
</div>
75101
</div>
76102
</main>

clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp

Lines changed: 14 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,14 @@ using SwitchBranch = llvm::SmallVector<const Stmt *, 2>;
2929
static bool areSwitchBranchesIdentical(const SwitchBranch &LHS,
3030
const SwitchBranch &RHS,
3131
const ASTContext &Context) {
32-
if (LHS.size() != RHS.size())
33-
return false;
34-
35-
for (size_t I = 0, Size = LHS.size(); I < Size; I++) {
32+
return llvm::equal(LHS, RHS, [&](const Stmt *S1, const Stmt *S2) {
3633
// NOTE: We strip goto labels and annotations in addition to stripping
3734
// the `case X:` or `default:` labels, but it is very unlikely that this
3835
// would cause false positives in real-world code.
39-
if (!tidy::utils::areStatementsIdentical(LHS[I]->stripLabelLikeStatements(),
40-
RHS[I]->stripLabelLikeStatements(),
41-
Context)) {
42-
return false;
43-
}
44-
}
45-
46-
return true;
36+
return tidy::utils::areStatementsIdentical(S1->stripLabelLikeStatements(),
37+
S2->stripLabelLikeStatements(),
38+
Context);
39+
});
4740
}
4841

4942
static bool isFallthroughSwitchBranch(const SwitchBranch &Branch) {
@@ -137,19 +130,10 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
137130
return false;
138131

139132
// If all children of two expressions are identical, return true.
140-
Expr::const_child_iterator I1 = Expr1->child_begin();
141-
Expr::const_child_iterator I2 = Expr2->child_begin();
142-
while (I1 != Expr1->child_end() && I2 != Expr2->child_end()) {
143-
if (!isIdenticalStmt(Ctx, *I1, *I2, IgnoreSideEffects))
144-
return false;
145-
++I1;
146-
++I2;
147-
}
148-
// If there are different number of children in the statements, return
149-
// false.
150-
if (I1 != Expr1->child_end())
151-
return false;
152-
if (I2 != Expr2->child_end())
133+
if (!llvm::equal(Expr1->children(), Expr2->children(),
134+
[&](const Stmt *S1, const Stmt *S2) {
135+
return isIdenticalStmt(Ctx, S1, S2, IgnoreSideEffects);
136+
}))
153137
return false;
154138
}
155139

@@ -246,22 +230,10 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
246230
case Stmt::CompoundStmtClass: {
247231
const auto *CompStmt1 = cast<CompoundStmt>(Stmt1);
248232
const auto *CompStmt2 = cast<CompoundStmt>(Stmt2);
249-
250-
if (CompStmt1->size() != CompStmt2->size())
251-
return false;
252-
253-
if (!llvm::all_of(llvm::zip(CompStmt1->body(), CompStmt2->body()),
254-
[&Ctx, IgnoreSideEffects](
255-
std::tuple<const Stmt *, const Stmt *> StmtPair) {
256-
const Stmt *Stmt0 = std::get<0>(StmtPair);
257-
const Stmt *Stmt1 = std::get<1>(StmtPair);
258-
return isIdenticalStmt(Ctx, Stmt0, Stmt1,
259-
IgnoreSideEffects);
260-
})) {
261-
return false;
262-
}
263-
264-
return true;
233+
return llvm::equal(CompStmt1->body(), CompStmt2->body(),
234+
[&](const Stmt *S1, const Stmt *S2) {
235+
return isIdenticalStmt(Ctx, S1, S2, IgnoreSideEffects);
236+
});
265237
}
266238
case Stmt::CompoundAssignOperatorClass:
267239
case Stmt::BinaryOperatorClass: {
@@ -456,7 +428,7 @@ void BranchCloneCheck::check(const MatchFinder::MatchResult &Result) {
456428

457429
diag(BeginCurrent->front()->getBeginLoc(),
458430
"switch has %0 consecutive identical branches")
459-
<< static_cast<int>(std::distance(BeginCurrent, EndCurrent));
431+
<< std::distance(BeginCurrent, EndCurrent);
460432

461433
SourceLocation EndLoc = (EndCurrent - 1)->back()->getEndLoc();
462434
// If the case statement is generated from a macro, it's SourceLocation

clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ using namespace clang::ast_matchers;
1818
namespace clang::tidy::readability {
1919

2020
void RedundantTypenameCheck::registerMatchers(MatchFinder *Finder) {
21-
Finder->addMatcher(typeLoc(unless(hasAncestor(decl(isInstantiated()))))
22-
.bind("nonDependentTypeLoc"),
23-
this);
21+
Finder->addMatcher(
22+
typeLoc(unless(hasAncestor(decl(isInstantiated())))).bind("typeLoc"),
23+
this);
2424

2525
if (!getLangOpts().CPlusPlus20)
2626
return;
@@ -44,38 +44,34 @@ void RedundantTypenameCheck::registerMatchers(MatchFinder *Finder) {
4444
}
4545

4646
void RedundantTypenameCheck::check(const MatchFinder::MatchResult &Result) {
47+
const TypeLoc TL = [&] {
48+
if (const auto *TL = Result.Nodes.getNodeAs<TypeLoc>("typeLoc"))
49+
return TL->getType()->isDependentType() ? TypeLoc() : *TL;
50+
51+
auto TL = *Result.Nodes.getNodeAs<TypeLoc>("dependentTypeLoc");
52+
while (const TypeLoc Next = TL.getNextTypeLoc())
53+
TL = Next;
54+
return TL;
55+
}();
56+
57+
if (TL.isNull())
58+
return;
59+
4760
const SourceLocation ElaboratedKeywordLoc = [&] {
48-
if (const auto *NonDependentTypeLoc =
49-
Result.Nodes.getNodeAs<TypeLoc>("nonDependentTypeLoc")) {
50-
if (NonDependentTypeLoc->getType()->isDependentType())
51-
return SourceLocation();
52-
53-
if (const auto TL = NonDependentTypeLoc->getAs<TypedefTypeLoc>())
54-
return TL.getElaboratedKeywordLoc();
55-
56-
if (const auto TL = NonDependentTypeLoc->getAs<TagTypeLoc>())
57-
return TL.getElaboratedKeywordLoc();
58-
59-
if (const auto TL = NonDependentTypeLoc
60-
->getAs<DeducedTemplateSpecializationTypeLoc>())
61-
return TL.getElaboratedKeywordLoc();
62-
63-
if (const auto TL =
64-
NonDependentTypeLoc->getAs<TemplateSpecializationTypeLoc>())
65-
return TL.getElaboratedKeywordLoc();
66-
} else {
67-
TypeLoc InnermostTypeLoc =
68-
*Result.Nodes.getNodeAs<TypeLoc>("dependentTypeLoc");
69-
while (const TypeLoc Next = InnermostTypeLoc.getNextTypeLoc())
70-
InnermostTypeLoc = Next;
71-
72-
if (const auto TL = InnermostTypeLoc.getAs<DependentNameTypeLoc>())
73-
return TL.getElaboratedKeywordLoc();
74-
75-
if (const auto TL =
76-
InnermostTypeLoc.getAs<TemplateSpecializationTypeLoc>())
77-
return TL.getElaboratedKeywordLoc();
78-
}
61+
if (const auto CastTL = TL.getAs<TypedefTypeLoc>())
62+
return CastTL.getElaboratedKeywordLoc();
63+
64+
if (const auto CastTL = TL.getAs<TagTypeLoc>())
65+
return CastTL.getElaboratedKeywordLoc();
66+
67+
if (const auto CastTL = TL.getAs<DeducedTemplateSpecializationTypeLoc>())
68+
return CastTL.getElaboratedKeywordLoc();
69+
70+
if (const auto CastTL = TL.getAs<TemplateSpecializationTypeLoc>())
71+
return CastTL.getElaboratedKeywordLoc();
72+
73+
if (const auto CastTL = TL.getAs<DependentNameTypeLoc>())
74+
return CastTL.getElaboratedKeywordLoc();
7975

8076
return SourceLocation();
8177
}();

clang-tools-extra/test/clang-doc/json/class-requires.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ struct MyClass;
2929
// CHECK-NEXT: }
3030
// CHECK-NEXT: ],
3131
// CHECK-NEXT: "Parameters": [
32-
// CHECK-NEXT: "typename T"
32+
// CHECK-NEXT: {
33+
// CHECK-NEXT: "End": true,
34+
// CHECK-NEXT: "typename T"
35+
// CHECK-NEXT: }
3336
// CHECK-NEXT: ]
3437
// CHECK-NEXT: },
3538
// CHECK-NEXT: "USR": "{{[0-9A-F]*}}"

clang-tools-extra/test/clang-doc/json/class-specialization.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ template<> struct MyClass<int> {};
1616
// BASE-NEXT: "TagType": "struct",
1717
// BASE-NEXT: "Template": {
1818
// BASE-NEXT: "Parameters": [
19-
// BASE-NEXT: "typename T"
19+
// BASE-NEXT: {
20+
// BASE-NEXT: "End": true,
21+
// BASE-NEXT: "Param": "typename T"
22+
// BASE-NEXT: }
2023
// BASE-NEXT: ]
2124
// BASE-NEXT: },
2225

@@ -30,7 +33,10 @@ template<> struct MyClass<int> {};
3033
// SPECIALIZATION-NEXT: "Template": {
3134
// SPECIALIZATION-NEXT: "Specialization": {
3235
// SPECIALIZATION-NEXT: "Parameters": [
33-
// SPECIALIZATION-NEXT: "int"
36+
// SPECIALIZATION-NEXT: {
37+
// SPECIALIZATION-NEXT: "End": true,
38+
// SPECIALIZATION-NEXT: "Param": "int"
39+
// SPECIALIZATION-NEXT: }
3440
// SPECIALIZATION-NEXT: ],
3541
// SPECIALIZATION-NEXT: "SpecializationOf": "{{[0-9A-F]*}}"
3642
// SPECIALIZATION-NEXT: }

clang-tools-extra/test/clang-doc/json/class-template.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,8 @@ template<typename T> struct MyClass {
2626
// CHECK: "Type": "T"
2727
// CHECK: "Template": {
2828
// CHECK-NEXT: "Parameters": [
29-
// CHECK-NEXT: "typename T"
29+
// CHECK-NEXT: {
30+
// CHECK-NEXT: "End": true,
31+
// CHECK-NEXT: "Param": "typename T"
32+
// CHECK-NEXT: }
3033
// CHECK-NEXT: ]

clang-tools-extra/test/clang-doc/json/class.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ struct MyClass {
108108
// CHECK-NEXT: },
109109
// CHECK-NEXT: "Template": {
110110
// CHECK-NEXT: "Parameters": [
111-
// CHECK-NEXT: "typename T"
111+
// CHECK-NEXT: {
112+
// CHECK-NEXT: "End": true,
113+
// CHECK-NEXT: "Param": "typename T"
114+
// CHECK-NEXT: }
112115
// CHECK-NEXT: ]
113116
// CHECK-NEXT: }
114117
// CHECK-NEXT: },

0 commit comments

Comments
 (0)