Skip to content

Commit 0085151

Browse files
committed
merge main into amd-staging
2 parents 773e74b + 62fc146 commit 0085151

File tree

475 files changed

+6118
-3362
lines changed

Some content is hidden

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

475 files changed

+6118
-3362
lines changed

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

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,79 @@
2323
</head>
2424
<body>
2525
<nav class="navbar">
26-
Navbar
26+
<div class="navbar__container">
27+
{{#ProjectName}}
28+
<div class="navbar__logo">
29+
{{ProjectName}}
30+
</div>
31+
{{/ProjectName}}
32+
<div class="navbar__menu">
33+
<ul class="navbar__links">
34+
<li class="navbar__item">
35+
<a href="/" class="navbar__link">Namespace</a>
36+
</li>
37+
<li class="navbar__item">
38+
<a href="/" class="navbar__link">Class</a>
39+
</li>
40+
</ul>
41+
</div>
42+
</div>
2743
</nav>
2844
<main>
2945
<div class="container">
3046
<div class="sidebar">
31-
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
32-
sed do eiusmod tempor incididunt ut labore et dolore magna
33-
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
34-
laboris nisi ut aliquip ex ea commodo consequat.
35-
Duis aute irure dolor in reprehenderit in voluptate velit esse
36-
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
37-
cupidatat non proident, sunt in culpa qui officia deserunt mollit
38-
anim id est laborum
47+
<h2>{{RecordType}} {{Name}}</h2>
48+
<ul>
49+
{{#Enums}}
50+
<li class="sidebar-section">
51+
<a class="sidebar-item" href="#Enums">Enums</a>
52+
</li>
53+
<ul>
54+
{{#Obj}}
55+
<li class="sidebar-item-container">
56+
<a class="sidebar-item" href="#{{ID}}">{{EnumName}}</a>
57+
</li>
58+
{{/Obj}}
59+
</ul>
60+
{{/Enums}}
61+
{{#Record}}
62+
<li class="sidebar-section">
63+
<a class="sidebar-item" href="#Classes">Inner Classes</a>
64+
</li>
65+
<ul>
66+
{{#Links}}
67+
<li class="sidebar-item-container">
68+
<a class="sidebar-item" href="#{{ID}}">{{Name}}</a>
69+
</li>
70+
{{/Links}}
71+
</ul>
72+
{{/Record}}
73+
</ul>
3974
</div>
4075
<div class="resizer" id="resizer"></div>
4176
<div class="content">
42-
Content
77+
{{#Enums}}
78+
<section id="Enums" class="section-container">
79+
<h2>Enumerations</h2>
80+
<div>
81+
{{#Obj}}
82+
{{>EnumPartial}}
83+
{{/Obj}}
84+
</div>
85+
</section>
86+
{{/Enums}}
87+
{{#Record}}
88+
<section id="Classes" class="section-container">
89+
<h2>Inner Classes</h2>
90+
<ul class="class-container">
91+
{{#Links}}
92+
<li id="{{ID}}" style="max-height: 40px;">
93+
<a href="{{Link}}"><pre><code class="language-cpp code-clang-doc" >class {{Name}}</code></pre></a>
94+
</li>
95+
{{/Links}}
96+
</ul>
97+
</section>
98+
{{/Record}}
4399
</div>
44100
</div>
45101
</main>

clang-tools-extra/clang-doc/tool/ClangDocMain.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,8 @@ static llvm::Error handleMappingFailures(llvm::Error Err) {
267267

268268
static llvm::Error createDirectories(llvm::StringRef OutDirectory) {
269269
if (std::error_code Err = llvm::sys::fs::create_directories(OutDirectory))
270-
return llvm::createFileError(OutDirectory, Err);
270+
return llvm::createFileError(OutDirectory, Err,
271+
"failed to create directory.");
271272
return llvm::Error::success();
272273
}
273274

clang-tools-extra/test/clang-doc/invalid-options.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// RUN: rm -rf %t && touch %t
33
// RUN: not clang-doc %s -output=%t/subdir 2>&1 | FileCheck %s --check-prefix=OUTPUT-FAIL
44
// OUTPUT-FAIL: clang-doc error:
5-
// OUTPUT-FAIL: {{(Not a directory|[Nn]o such file or directory)}}
5+
// OUTPUT-FAIL-SAME: failed to create directory.
66

77
/// Invalid format option.
88
// RUN: rm -rf %t && mkdir %t && touch %t/file
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
// RUN: rm -rf %t && mkdir -p %t
2+
// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
3+
// RUN: FileCheck %s < %t/GlobalNamespace/index.html
4+
5+
enum Color {
6+
RED,
7+
BLUE,
8+
GREEN
9+
};
10+
11+
class Foo;
12+
13+
// CHECK: <li class="sidebar-section">
14+
// CHECK-NEXT: <a class="sidebar-item" href="#Enums">Enums</a>
15+
// CHECK-NEXT: </li>
16+
// CHECK-NEXT: <ul>
17+
// CHECK-NEXT: <li class="sidebar-item-container">
18+
// CHECK-NEXT: <a class="sidebar-item" href="#{{[0-9A-F]*}}">enum Color</a>
19+
// CHECK-NEXT: </li>
20+
// CHECK-NEXT: </ul>
21+
// CHECK: <li class="sidebar-section">
22+
// CHECK-NEXT: <a class="sidebar-item" href="#Classes">Inner Classes</a>
23+
// CHECK-NEXT: </li>
24+
// CHECK-NEXT: <ul>
25+
// CHECK-NEXT: <li class="sidebar-item-container">
26+
// CHECK-NEXT: <a class="sidebar-item" href="#{{[0-9A-F]*}}">Foo</a>
27+
// CHECK-NEXT: </li>
28+
// CHECK-NEXT: </ul>
29+
30+
// CHECK: <section id="Enums" class="section-container">
31+
// CHECK-NEXT: <h2>Enumerations</h2>
32+
// CHECK-NEXT: <div>
33+
// CHECK-NEXT: <div id="{{[0-9A-F]*}}" class="delimiter-container">
34+
// CHECK-NEXT: <div>
35+
// CHECK-NEXT: <pre>
36+
// CHECK-NEXT: <code class="language-cpp code-clang-doc">
37+
// CHECK-NEXT: enum Color
38+
// CHECK-NEXT: </code>
39+
// CHECK-NEXT: </pre>
40+
// CHECK-NEXT: </div>
41+
// CHECK-NEXT: <table class="table-wrapper">
42+
// CHECK-NEXT: <tbody>
43+
// CHECK-NEXT: <tr>
44+
// CHECK-NEXT: <th>Name</th>
45+
// CHECK-NEXT: <th>Value</th>
46+
// CHECK: </tr>
47+
// CHECK-NEXT: <tr>
48+
// CHECK-NEXT: <td>RED</td>
49+
// CHECK-NEXT: <td>0</td>
50+
// CHECK: </tr>
51+
// CHECK-NEXT: <tr>
52+
// CHECK-NEXT: <td>BLUE</td>
53+
// CHECK-NEXT: <td>1</td>
54+
// CHECK: </tr>
55+
// CHECK-NEXT: <tr>
56+
// CHECK-NEXT: <td>GREEN</td>
57+
// CHECK-NEXT: <td>2</td>
58+
// CHECK: </tr>
59+
// CHECK-NEXT: </tbody>
60+
// CHECK-NEXT: </table>
61+
// CHECK-NEXT: <div>
62+
// CHECK-NEXT: Defined at line 5 of file {{.*}}mustache-index.cpp
63+
// CHECK-NEXT: </div>
64+
// CHECK-NEXT: </div>
65+
// CHECK-NEXT: </div>
66+
// CHECK-NEXT: </section>
67+
68+
// CHECK: <section id="Classes" class="section-container">
69+
// CHECK-NEXT: <h2>Inner Classes</h2>
70+
// CHECK-NEXT: <ul class="class-container">
71+
// CHECK-NEXT: <li id="{{[0-9A-F]*}}" style="max-height: 40px;">
72+
// CHECK-NEXT: <a href="Foo.html"><pre><code class="language-cpp code-clang-doc" >class Foo</code></pre></a>
73+
// CHECK-NEXT: </li>
74+
// CHECK-NEXT: </ul>
75+
// CHECK-NEXT: </section>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: rm -rf %t && mkdir -p %t
2+
// RUN: clang-doc --format=mustache --output=%t --executor=standalone %s
3+
// RUN: FileCheck %s < %t/MyNamespace/index.html
4+
5+
namespace MyNamespace {
6+
class Foo;
7+
}
8+
9+
// CHECK: <ul class="class-container">
10+
// CHECK-NEXT: <li id="{{[0-9A-F]*}}" style="max-height: 40px;">
11+
// CHECK-NEXT: <a href="Foo.html"><pre><code class="language-cpp code-clang-doc" >class Foo</code></pre></a>
12+
// CHECK-NEXT: </li>
13+
// CHECK-NEXT: </ul>

clang-tools-extra/unittests/clang-doc/HTMLMustacheGeneratorTest.cpp

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -87,29 +87,6 @@ TEST(HTMLMustacheGeneratorTest, createResources) {
8787
}
8888
}
8989

90-
TEST(HTMLMustacheGeneratorTest, generateDocs) {
91-
auto G = getHTMLMustacheGenerator();
92-
assert(G && "Could not find HTMLMustacheGenerator");
93-
ClangDocContext CDCtx = getClangDocContext();
94-
95-
unittest::TempDir RootTestDirectory("generateDocsTest", /*Unique=*/true);
96-
CDCtx.OutDirectory = RootTestDirectory.path();
97-
98-
#if ENABLE_LOCAL_TEST
99-
// FIXME: We can't read files during unit tests. Migrate to lit once
100-
// tool support lands.
101-
getMustacheHtmlFiles(CLANG_DOC_TEST_ASSET_DIR, CDCtx);
102-
103-
EXPECT_THAT_ERROR(G->generateDocs(RootTestDirectory.path(), {}, CDCtx),
104-
Succeeded())
105-
<< "Failed to generate docs.";
106-
#else
107-
EXPECT_THAT_ERROR(G->generateDocs(RootTestDirectory.path(), {}, CDCtx),
108-
Failed())
109-
<< "Failed to generate docs.";
110-
#endif
111-
}
112-
11390
TEST(HTMLGeneratorTest, emitFunctionHTML) {
11491
#if ENABLE_LOCAL_TEST
11592
auto G = getHTMLMustacheGenerator();
@@ -160,50 +137,6 @@ TEST(HTMLGeneratorTest, emitFunctionHTML) {
160137
#endif
161138
}
162139

163-
TEST(HTMLMustacheGeneratorTest, emitEnumHTML) {
164-
#if ENABLE_LOCAL_TEST
165-
auto G = getHTMLMustacheGenerator();
166-
assert(G && "Could not find HTMLMustacheGenerator");
167-
ClangDocContext CDCtx = getClangDocContext();
168-
std::string Buffer;
169-
llvm::raw_string_ostream Actual(Buffer);
170-
171-
unittest::TempDir RootTestDirectory("emitEnumHTML",
172-
/*Unique=*/true);
173-
CDCtx.OutDirectory = RootTestDirectory.path();
174-
175-
getMustacheHtmlFiles(CLANG_DOC_TEST_ASSET_DIR, CDCtx);
176-
177-
// FIXME: This is a terrible hack, since we can't initialize the templates
178-
// directly. We'll need to update the interfaces so that we can call
179-
// SetupTemplateFiles() from outsize of HTMLMustacheGenerator.cpp
180-
EXPECT_THAT_ERROR(G->generateDocs(RootTestDirectory.path(), {}, CDCtx),
181-
Succeeded())
182-
<< "Failed to generate docs.";
183-
184-
CDCtx.RepositoryUrl = "http://www.repository.com";
185-
186-
EnumInfo I;
187-
I.Name = "e";
188-
I.Namespace.emplace_back(EmptySID, "A", InfoType::IT_namespace);
189-
190-
I.DefLoc = Location(10, 10, "test.cpp", true);
191-
I.Loc.emplace_back(12, 12, "test.cpp");
192-
193-
I.Members.emplace_back("X");
194-
I.Scoped = true;
195-
196-
auto Err = G->generateDocForInfo(&I, Actual, CDCtx);
197-
assert(!Err);
198-
199-
std::string Expected = R"raw(IT_enum
200-
)raw";
201-
202-
// FIXME: Enums are not handled yet.
203-
EXPECT_EQ(Expected, Actual.str());
204-
#endif
205-
}
206-
207140
TEST(HTMLMustacheGeneratorTest, emitCommentHTML) {
208141
#if ENABLE_LOCAL_TEST
209142
auto G = getHTMLMustacheGenerator();

clang/include/clang/AST/Type.h

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,6 +1985,10 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
19851985
LLVM_PREFERRED_TYPE(bool)
19861986
unsigned HasTrailingReturn : 1;
19871987

1988+
/// Whether this function has is a cfi unchecked callee.
1989+
LLVM_PREFERRED_TYPE(bool)
1990+
unsigned CFIUncheckedCallee : 1;
1991+
19881992
/// Extra information which affects how the function is called, like
19891993
/// regparm and the calling convention.
19901994
LLVM_PREFERRED_TYPE(CallingConv)
@@ -2566,6 +2570,8 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
25662570
bool isSignableIntegerType(const ASTContext &Ctx) const;
25672571
bool isAnyPointerType() const; // Any C pointer or ObjC object pointer
25682572
bool isCountAttributedType() const;
2573+
bool isCFIUncheckedCalleeFunctionType() const;
2574+
bool hasPointeeToToCFIUncheckedCalleeFunctionType() const;
25692575
bool isBlockPointerType() const;
25702576
bool isVoidPointerType() const;
25712577
bool isReferenceType() const;
@@ -4713,6 +4719,10 @@ class FunctionType : public Type {
47134719
/// type.
47144720
bool getNoReturnAttr() const { return getExtInfo().getNoReturn(); }
47154721

4722+
/// Determine whether this is a function prototype that includes the
4723+
/// cfi_unchecked_callee attribute.
4724+
bool getCFIUncheckedCalleeAttr() const;
4725+
47164726
bool getCmseNSCallAttr() const { return getExtInfo().getCmseNSCall(); }
47174727
CallingConv getCallConv() const { return getExtInfo().getCC(); }
47184728
ExtInfo getExtInfo() const { return ExtInfo(FunctionTypeBits.ExtInfo); }
@@ -5249,8 +5259,12 @@ class FunctionProtoType final
52495259
/// the various bits of extra information about a function prototype.
52505260
struct ExtProtoInfo {
52515261
FunctionType::ExtInfo ExtInfo;
5262+
LLVM_PREFERRED_TYPE(bool)
52525263
unsigned Variadic : 1;
5264+
LLVM_PREFERRED_TYPE(bool)
52535265
unsigned HasTrailingReturn : 1;
5266+
LLVM_PREFERRED_TYPE(bool)
5267+
unsigned CFIUncheckedCallee : 1;
52545268
unsigned AArch64SMEAttributes : 9;
52555269
Qualifiers TypeQuals;
52565270
RefQualifierKind RefQualifier = RQ_None;
@@ -5260,19 +5274,25 @@ class FunctionProtoType final
52605274
FunctionEffectsRef FunctionEffects;
52615275

52625276
ExtProtoInfo()
5263-
: Variadic(false), HasTrailingReturn(false),
5277+
: Variadic(false), HasTrailingReturn(false), CFIUncheckedCallee(false),
52645278
AArch64SMEAttributes(SME_NormalFunction) {}
52655279

52665280
ExtProtoInfo(CallingConv CC)
52675281
: ExtInfo(CC), Variadic(false), HasTrailingReturn(false),
5268-
AArch64SMEAttributes(SME_NormalFunction) {}
5282+
CFIUncheckedCallee(false), AArch64SMEAttributes(SME_NormalFunction) {}
52695283

52705284
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &ESI) {
52715285
ExtProtoInfo Result(*this);
52725286
Result.ExceptionSpec = ESI;
52735287
return Result;
52745288
}
52755289

5290+
ExtProtoInfo withCFIUncheckedCallee(bool CFIUncheckedCallee) {
5291+
ExtProtoInfo Result(*this);
5292+
Result.CFIUncheckedCallee = CFIUncheckedCallee;
5293+
return Result;
5294+
}
5295+
52765296
bool requiresFunctionProtoTypeExtraBitfields() const {
52775297
return ExceptionSpec.Type == EST_Dynamic ||
52785298
requiresFunctionProtoTypeArmAttributes() ||
@@ -5432,6 +5452,7 @@ class FunctionProtoType final
54325452
EPI.Variadic = isVariadic();
54335453
EPI.EllipsisLoc = getEllipsisLoc();
54345454
EPI.HasTrailingReturn = hasTrailingReturn();
5455+
EPI.CFIUncheckedCallee = hasCFIUncheckedCallee();
54355456
EPI.ExceptionSpec = getExceptionSpecInfo();
54365457
EPI.TypeQuals = getMethodQuals();
54375458
EPI.RefQualifier = getRefQualifier();
@@ -5557,6 +5578,10 @@ class FunctionProtoType final
55575578
/// Whether this function prototype has a trailing return type.
55585579
bool hasTrailingReturn() const { return FunctionTypeBits.HasTrailingReturn; }
55595580

5581+
bool hasCFIUncheckedCallee() const {
5582+
return FunctionTypeBits.CFIUncheckedCallee;
5583+
}
5584+
55605585
Qualifiers getMethodQuals() const {
55615586
if (hasExtQualifiers())
55625587
return *getTrailingObjects<Qualifiers>();
@@ -8391,6 +8416,27 @@ inline bool Type::isObjectPointerType() const {
83918416
return false;
83928417
}
83938418

8419+
inline bool Type::isCFIUncheckedCalleeFunctionType() const {
8420+
if (const auto *Fn = getAs<FunctionProtoType>())
8421+
return Fn->hasCFIUncheckedCallee();
8422+
return false;
8423+
}
8424+
8425+
inline bool Type::hasPointeeToToCFIUncheckedCalleeFunctionType() const {
8426+
QualType Pointee;
8427+
if (const auto *PT = getAs<PointerType>())
8428+
Pointee = PT->getPointeeType();
8429+
else if (const auto *RT = getAs<ReferenceType>())
8430+
Pointee = RT->getPointeeType();
8431+
else if (const auto *MPT = getAs<MemberPointerType>())
8432+
Pointee = MPT->getPointeeType();
8433+
else if (const auto *DT = getAs<DecayedType>())
8434+
Pointee = DT->getPointeeType();
8435+
else
8436+
return false;
8437+
return Pointee->isCFIUncheckedCalleeFunctionType();
8438+
}
8439+
83948440
inline bool Type::isFunctionPointerType() const {
83958441
if (const auto *T = getAs<PointerType>())
83968442
return T->getPointeeType()->isFunctionType();

0 commit comments

Comments
 (0)