Skip to content

Commit 8973d17

Browse files
authored
Merge branch 'main' into fmv-always-emit-mangled-default
2 parents 1e84b67 + eaf482f commit 8973d17

File tree

532 files changed

+22679
-9741
lines changed

Some content is hidden

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

532 files changed

+22679
-9741
lines changed

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,10 @@ static RecordDecl *getRecordDeclForType(const QualType &T) {
236236
return nullptr;
237237
}
238238

239-
TypeInfo getTypeInfoForType(const QualType &T) {
239+
TypeInfo getTypeInfoForType(const QualType &T, const PrintingPolicy &Policy) {
240240
const TagDecl *TD = getTagDeclForType(T);
241241
if (!TD)
242-
return TypeInfo(Reference(SymbolID(), T.getAsString()));
242+
return TypeInfo(Reference(SymbolID(), T.getAsString(Policy)));
243243

244244
InfoType IT;
245245
if (dyn_cast<EnumDecl>(TD)) {
@@ -250,7 +250,7 @@ TypeInfo getTypeInfoForType(const QualType &T) {
250250
IT = InfoType::IT_default;
251251
}
252252
return TypeInfo(Reference(getUSRForDecl(TD), TD->getNameAsString(), IT,
253-
T.getAsString(), getInfoRelativePath(TD)));
253+
T.getAsString(Policy), getInfoRelativePath(TD)));
254254
}
255255

256256
static bool isPublic(const clang::AccessSpecifier AS,
@@ -379,10 +379,11 @@ static void parseFields(RecordInfo &I, const RecordDecl *D, bool PublicOnly,
379379
if (!shouldSerializeInfo(PublicOnly, /*IsInAnonymousNamespace=*/false, F))
380380
continue;
381381

382+
auto &LO = F->getLangOpts();
382383
// Use getAccessUnsafe so that we just get the default AS_none if it's not
383384
// valid, as opposed to an assert.
384385
MemberTypeInfo &NewMember = I.Members.emplace_back(
385-
getTypeInfoForType(F->getTypeSourceInfo()->getType()),
386+
getTypeInfoForType(F->getTypeSourceInfo()->getType(), LO),
386387
F->getNameAsString(),
387388
getFinalAccessSpecifier(Access, F->getAccessUnsafe()));
388389
populateMemberTypeInfo(NewMember, F);
@@ -412,9 +413,10 @@ static void parseEnumerators(EnumInfo &I, const EnumDecl *D) {
412413
}
413414

414415
static void parseParameters(FunctionInfo &I, const FunctionDecl *D) {
416+
auto &LO = D->getLangOpts();
415417
for (const ParmVarDecl *P : D->parameters()) {
416418
FieldTypeInfo &FieldInfo = I.Params.emplace_back(
417-
getTypeInfoForType(P->getOriginalType()), P->getNameAsString());
419+
getTypeInfoForType(P->getOriginalType(), LO), P->getNameAsString());
418420
FieldInfo.DefaultValue = getSourceCode(D, P->getDefaultArgRange());
419421
}
420422
}
@@ -541,7 +543,8 @@ static void populateFunctionInfo(FunctionInfo &I, const FunctionDecl *D,
541543
bool &IsInAnonymousNamespace) {
542544
populateSymbolInfo(I, D, FC, LineNumber, Filename, IsFileInRootDir,
543545
IsInAnonymousNamespace);
544-
I.ReturnType = getTypeInfoForType(D->getReturnType());
546+
auto &LO = D->getLangOpts();
547+
I.ReturnType = getTypeInfoForType(D->getReturnType(), LO);
545548
parseParameters(I, D);
546549

547550
PopulateTemplateParameters(I.Template, D);
@@ -783,7 +786,8 @@ emitInfo(const TypedefDecl *D, const FullComment *FC, int LineNumber,
783786
return {};
784787

785788
Info.DefLoc.emplace(LineNumber, File, IsFileInRootDir);
786-
Info.Underlying = getTypeInfoForType(D->getUnderlyingType());
789+
auto &LO = D->getLangOpts();
790+
Info.Underlying = getTypeInfoForType(D->getUnderlyingType(), LO);
787791
if (Info.Underlying.Type.Name.empty()) {
788792
// Typedef for an unnamed type. This is like "typedef struct { } Foo;"
789793
// The record serializer explicitly checks for this syntax and constructs
@@ -809,7 +813,8 @@ emitInfo(const TypeAliasDecl *D, const FullComment *FC, int LineNumber,
809813
return {};
810814

811815
Info.DefLoc.emplace(LineNumber, File, IsFileInRootDir);
812-
Info.Underlying = getTypeInfoForType(D->getUnderlyingType());
816+
auto &LO = D->getLangOpts();
817+
Info.Underlying = getTypeInfoForType(D->getUnderlyingType(), LO);
813818
Info.IsUsing = true;
814819

815820
// Info is wrapped in its parent scope so is returned in the second position.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ extern bool b();
2323
// YAML-NEXT: Filename: '{{.*}}'
2424
// YAML-NEXT: ReturnType:
2525
// YAML-NEXT: Type:
26-
// YAML-NEXT: Name: '_Bool'
27-
// YAML-NEXT: QualName: '_Bool'
26+
// YAML-NEXT: Name: 'bool'
27+
// YAML-NEXT: QualName: 'bool'
2828

2929
// MD: ### b
30-
// MD: *_Bool b()*
30+
// MD: *bool b()*
3131

3232
char c();
3333

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ void function<bool, 0>(bool x) {}
8080
// YAML-NEXT: Filename: '{{.*}}'
8181
// YAML-NEXT: Params:
8282
// YAML-NEXT: - Type:
83-
// YAML-NEXT: Name: '_Bool'
84-
// YAML-NEXT: QualName: '_Bool'
83+
// YAML-NEXT: Name: 'bool'
84+
// YAML-NEXT: QualName: 'bool'
8585
// YAML-NEXT: Name: 'x'
8686
// YAML-NEXT: ReturnType:
8787
// YAML-NEXT: Type:
@@ -95,7 +95,7 @@ void function<bool, 0>(bool x) {}
9595
// YAML-NEXT: - Contents: '0'
9696

9797
// MD: ### function
98-
// MD: *void function(_Bool x)*
98+
// MD: *void function(bool x)*
9999
// MD: *Defined at {{.*}}templates.cpp#[[# @LINE - 26]]*
100100

101101
/// A Tuple type
@@ -136,21 +136,21 @@ tuple<int,int,bool> func_with_tuple_param(tuple<int,int,bool> t){ return t;}
136136
// YAML-NEXT: - Type:
137137
// YAML-NEXT: Type: Record
138138
// YAML-NEXT: Name: 'tuple'
139-
// YAML-NEXT: QualName: 'tuple<int, int, _Bool>'
139+
// YAML-NEXT: QualName: 'tuple<int, int, bool>'
140140
// YAML-NEXT: USR: '{{([0-9A-F]{40})}}'
141141
// YAML-NEXT: Path: 'GlobalNamespace'
142142
// YAML-NEXT: Name: 't'
143143
// YAML-NEXT: ReturnType:
144144
// YAML-NEXT: Type:
145145
// YAML-NEXT: Type: Record
146146
// YAML-NEXT: Name: 'tuple'
147-
// YAML-NEXT: QualName: 'tuple<int, int, _Bool>'
147+
// YAML-NEXT: QualName: 'tuple<int, int, bool>'
148148
// YAML-NEXT: USR: '{{([0-9A-F]{40})}}'
149149
// YAML-NEXT: Path: 'GlobalNamespace'
150150
// YAML-NEXT: ...
151151

152152
// MD: ### func_with_tuple_param
153-
// MD: *tuple<int, int, _Bool> func_with_tuple_param(tuple<int, int, _Bool> t)*
153+
// MD: *tuple<int, int, bool> func_with_tuple_param(tuple<int, int, bool> 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

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,8 @@ TEST(SerializeTests, emitTypedefs) {
631631
TEST(SerializeTests, emitFunctionTemplate) {
632632
EmittedInfoList Infos;
633633
// A template and a specialization.
634-
ExtractInfosFromCode("template<typename T = int> void GetFoo(T);\n"
635-
"template<> void GetFoo<bool>(bool);",
634+
ExtractInfosFromCode("template<typename T = int> bool GetFoo(T);\n"
635+
"template<> bool GetFoo<bool>(bool);",
636636
2,
637637
/*Public=*/false, Infos);
638638

@@ -666,6 +666,8 @@ TEST(SerializeTests, emitFunctionTemplate) {
666666
ASSERT_EQ(1u, Func2.Template->Specialization->Params.size());
667667
EXPECT_EQ("bool", Func2.Template->Specialization->Params[0].Contents);
668668
EXPECT_EQ(Func1.USR, Func2.Template->Specialization->SpecializationOf);
669+
670+
EXPECT_EQ("bool", Func2.ReturnType.Type.Name);
669671
}
670672

671673
TEST(SerializeTests, emitClassTemplate) {

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ C++23 Feature Support
272272

273273
- Extend lifetime of temporaries in mem-default-init for P2718R0. Clang now fully
274274
supports `P2718R0 Lifetime extension in range-based for loops <https://wg21.link/P2718R0>`_.
275+
276+
- ``__cpp_explicit_this_parameter`` is now defined. (#GH82780)
275277

276278
C++20 Feature Support
277279
^^^^^^^^^^^^^^^^^^^^^
@@ -848,6 +850,7 @@ Bug Fixes to C++ Support
848850
- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278)
849851
- Fixed recognition of ``std::initializer_list`` when it's surrounded with ``extern "C++"`` and exported
850852
out of a module (which is the case e.g. in MSVC's implementation of ``std`` module). (#GH118218)
853+
- Fixed a pack expansion issue in checking unexpanded parameter sizes. (#GH17042)
851854

852855
Bug Fixes to AST Handling
853856
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang-c/Index.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2186,7 +2186,11 @@ enum CXCursorKind {
21862186
*/
21872187
CXCursor_OpenACCHostDataConstruct = 326,
21882188

2189-
CXCursor_LastStmt = CXCursor_OpenACCHostDataConstruct,
2189+
/** OpenACC wait Construct.
2190+
*/
2191+
CXCursor_OpenACCWaitConstruct = 327,
2192+
2193+
CXCursor_LastStmt = CXCursor_OpenACCWaitConstruct,
21902194

21912195
/**
21922196
* Cursor that represents the translation unit itself.

clang/include/clang/AST/ASTNodeTraverser.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class ASTNodeTraverser
159159

160160
// Some statements have custom mechanisms for dumping their children.
161161
if (isa<DeclStmt>(S) || isa<GenericSelectionExpr>(S) ||
162-
isa<RequiresExpr>(S))
162+
isa<RequiresExpr>(S) || isa<OpenACCWaitConstruct>(S))
163163
return;
164164

165165
if (Traversal == TK_IgnoreUnlessSpelledInSource &&
@@ -825,6 +825,16 @@ class ASTNodeTraverser
825825
Visit(C);
826826
}
827827

828+
void VisitOpenACCWaitConstruct(const OpenACCWaitConstruct *Node) {
829+
// Needs custom child checking to put clauses AFTER the children, which are
830+
// the expressions in the 'wait' construct. Others likely need this as well,
831+
// and might need to do the associated statement after it.
832+
for (const Stmt *S : Node->children())
833+
Visit(S);
834+
for (const auto *C : Node->clauses())
835+
Visit(C);
836+
}
837+
828838
void VisitInitListExpr(const InitListExpr *ILE) {
829839
if (auto *Filler = ILE->getArrayFiller()) {
830840
Visit(Filler, "array_filler");

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4063,10 +4063,19 @@ DEF_TRAVERSE_STMT(OpenACCCombinedConstruct,
40634063
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
40644064
DEF_TRAVERSE_STMT(OpenACCDataConstruct,
40654065
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4066-
DEF_TRAVERSE_STMT(OpenACCEnterDataConstruct, {})
4067-
DEF_TRAVERSE_STMT(OpenACCExitDataConstruct, {})
4066+
DEF_TRAVERSE_STMT(OpenACCEnterDataConstruct,
4067+
{ TRY_TO(VisitOpenACCClauseList(S->clauses())); })
4068+
DEF_TRAVERSE_STMT(OpenACCExitDataConstruct,
4069+
{ TRY_TO(VisitOpenACCClauseList(S->clauses())); })
40684070
DEF_TRAVERSE_STMT(OpenACCHostDataConstruct,
40694071
{ TRY_TO(TraverseOpenACCAssociatedStmtConstruct(S)); })
4072+
DEF_TRAVERSE_STMT(OpenACCWaitConstruct, {
4073+
if (S->hasDevNumExpr())
4074+
TRY_TO(TraverseStmt(S->getDevNumExpr()));
4075+
for (auto *E : S->getQueueIdExprs())
4076+
TRY_TO(TraverseStmt(E));
4077+
TRY_TO(VisitOpenACCClauseList(S->clauses()));
4078+
})
40704079

40714080
// Traverse HLSL: Out argument expression
40724081
DEF_TRAVERSE_STMT(HLSLOutArgExpr, {})

clang/include/clang/AST/StmtOpenACC.h

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,5 +469,128 @@ class OpenACCHostDataConstruct final
469469
return const_cast<OpenACCHostDataConstruct *>(this)->getStructuredBlock();
470470
}
471471
};
472+
473+
// This class represents a 'wait' construct, which has some expressions plus a
474+
// clause list.
475+
class OpenACCWaitConstruct final
476+
: public OpenACCConstructStmt,
477+
private llvm::TrailingObjects<OpenACCWaitConstruct, Expr *,
478+
OpenACCClause *> {
479+
// FIXME: We should be storing a `const OpenACCClause *` to be consistent with
480+
// the rest of the constructs, but TrailingObjects doesn't allow for mixing
481+
// constness in its implementation of `getTrailingObjects`.
482+
483+
friend TrailingObjects;
484+
friend class ASTStmtWriter;
485+
friend class ASTStmtReader;
486+
// Locations of the left and right parens of the 'wait-argument'
487+
// expression-list.
488+
SourceLocation LParenLoc, RParenLoc;
489+
// Location of the 'queues' keyword, if present.
490+
SourceLocation QueuesLoc;
491+
492+
// Number of the expressions being represented. Index '0' is always the
493+
// 'devnum' expression, even if it not present.
494+
unsigned NumExprs = 0;
495+
496+
OpenACCWaitConstruct(unsigned NumExprs, unsigned NumClauses)
497+
: OpenACCConstructStmt(OpenACCWaitConstructClass,
498+
OpenACCDirectiveKind::Wait, SourceLocation{},
499+
SourceLocation{}, SourceLocation{}),
500+
NumExprs(NumExprs) {
501+
assert(NumExprs >= 1 &&
502+
"NumExprs should always be >= 1 because the 'devnum' "
503+
"expr is represented by a null if necessary");
504+
std::uninitialized_value_construct(getExprPtr(),
505+
getExprPtr() + NumExprs);
506+
std::uninitialized_value_construct(getTrailingObjects<OpenACCClause *>(),
507+
getTrailingObjects<OpenACCClause *>() +
508+
NumClauses);
509+
setClauseList(MutableArrayRef(const_cast<const OpenACCClause **>(
510+
getTrailingObjects<OpenACCClause *>()),
511+
NumClauses));
512+
}
513+
514+
OpenACCWaitConstruct(SourceLocation Start, SourceLocation DirectiveLoc,
515+
SourceLocation LParenLoc, Expr *DevNumExpr,
516+
SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs,
517+
SourceLocation RParenLoc, SourceLocation End,
518+
ArrayRef<const OpenACCClause *> Clauses)
519+
: OpenACCConstructStmt(OpenACCWaitConstructClass,
520+
OpenACCDirectiveKind::Wait, Start, DirectiveLoc,
521+
End),
522+
LParenLoc(LParenLoc), RParenLoc(RParenLoc), QueuesLoc(QueuesLoc),
523+
NumExprs(QueueIdExprs.size() + 1) {
524+
assert(NumExprs >= 1 &&
525+
"NumExprs should always be >= 1 because the 'devnum' "
526+
"expr is represented by a null if necessary");
527+
528+
std::uninitialized_copy(&DevNumExpr, &DevNumExpr + 1,
529+
getExprPtr());
530+
std::uninitialized_copy(QueueIdExprs.begin(), QueueIdExprs.end(),
531+
getExprPtr() + 1);
532+
533+
std::uninitialized_copy(const_cast<OpenACCClause **>(Clauses.begin()),
534+
const_cast<OpenACCClause **>(Clauses.end()),
535+
getTrailingObjects<OpenACCClause *>());
536+
setClauseList(MutableArrayRef(const_cast<const OpenACCClause **>(
537+
getTrailingObjects<OpenACCClause *>()),
538+
Clauses.size()));
539+
}
540+
541+
size_t numTrailingObjects(OverloadToken<Expr *>) const { return NumExprs; }
542+
size_t numTrailingObjects(OverloadToken<const OpenACCClause *>) const {
543+
return clauses().size();
544+
}
545+
546+
Expr **getExprPtr() const {
547+
return const_cast<Expr**>(getTrailingObjects<Expr *>());
548+
}
549+
550+
llvm::ArrayRef<Expr *> getExprs() const {
551+
return llvm::ArrayRef<Expr *>(getExprPtr(), NumExprs);
552+
}
553+
554+
llvm::ArrayRef<Expr *> getExprs() {
555+
return llvm::ArrayRef<Expr *>(getExprPtr(), NumExprs);
556+
}
557+
558+
public:
559+
static bool classof(const Stmt *T) {
560+
return T->getStmtClass() == OpenACCWaitConstructClass;
561+
}
562+
563+
static OpenACCWaitConstruct *
564+
CreateEmpty(const ASTContext &C, unsigned NumExprs, unsigned NumClauses);
565+
566+
static OpenACCWaitConstruct *
567+
Create(const ASTContext &C, SourceLocation Start, SourceLocation DirectiveLoc,
568+
SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc,
569+
ArrayRef<Expr *> QueueIdExprs, SourceLocation RParenLoc,
570+
SourceLocation End, ArrayRef<const OpenACCClause *> Clauses);
571+
572+
SourceLocation getLParenLoc() const { return LParenLoc; }
573+
SourceLocation getRParenLoc() const { return RParenLoc; }
574+
bool hasQueuesTag() const { return !QueuesLoc.isInvalid(); }
575+
SourceLocation getQueuesLoc() const { return QueuesLoc; }
576+
577+
bool hasDevNumExpr() const { return getExprs()[0]; }
578+
Expr *getDevNumExpr() const { return getExprs()[0]; }
579+
llvm::ArrayRef<Expr *> getQueueIdExprs() { return getExprs().drop_front(); }
580+
llvm::ArrayRef<Expr *> getQueueIdExprs() const {
581+
return getExprs().drop_front();
582+
}
583+
584+
child_range children() {
585+
Stmt **Begin = reinterpret_cast<Stmt **>(getExprPtr());
586+
return child_range(Begin, Begin + NumExprs);
587+
}
588+
589+
const_child_range children() const {
590+
Stmt *const *Begin =
591+
reinterpret_cast<Stmt *const *>(getExprPtr());
592+
return const_child_range(Begin, Begin + NumExprs);
593+
}
594+
};
472595
} // namespace clang
473596
#endif // LLVM_CLANG_AST_STMTOPENACC_H

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ class TextNodeDumper
415415
void VisitOpenACCEnterDataConstruct(const OpenACCEnterDataConstruct *S);
416416
void VisitOpenACCExitDataConstruct(const OpenACCExitDataConstruct *S);
417417
void VisitOpenACCHostDataConstruct(const OpenACCHostDataConstruct *S);
418+
void VisitOpenACCWaitConstruct(const OpenACCWaitConstruct *S);
418419
void VisitOpenACCAsteriskSizeExpr(const OpenACCAsteriskSizeExpr *S);
419420
void VisitEmbedExpr(const EmbedExpr *S);
420421
void VisitAtomicExpr(const AtomicExpr *AE);

0 commit comments

Comments
 (0)