Skip to content

Commit 1136f15

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/user-begin
2 parents b9cc2e6 + 4ca4287 commit 1136f15

File tree

155 files changed

+9940
-2927
lines changed

Some content is hidden

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

155 files changed

+9940
-2927
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,7 @@ Bug Fixes to C++ Support
850850
- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278)
851851
- Fixed recognition of ``std::initializer_list`` when it's surrounded with ``extern "C++"`` and exported
852852
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)
853854

854855
Bug Fixes to AST Handling
855856
^^^^^^^^^^^^^^^^^^^^^^^^^

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);

clang/include/clang/Basic/CodeGenOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ class CodeGenOptions : public CodeGenOptionsBase {
380380
/// Set of sanitizer checks that trap rather than diagnose.
381381
SanitizerSet SanitizeTrap;
382382

383+
/// Set of sanitizer checks that can merge handlers (smaller code size at
384+
/// the expense of debuggability).
385+
SanitizerSet SanitizeMergeHandlers;
386+
383387
/// List of backend command-line options for -fembed-bitcode.
384388
std::vector<uint8_t> CmdArgs;
385389

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5863,10 +5863,10 @@ def err_pack_expansion_without_parameter_packs : Error<
58635863
"pack expansion does not contain any unexpanded parameter packs">;
58645864
def err_pack_expansion_length_conflict : Error<
58655865
"pack expansion contains parameter packs %0 and %1 that have different "
5866-
"lengths (%2 vs. %3)">;
5866+
"lengths (%2 vs. %select{|at least }3%4))">;
58675867
def err_pack_expansion_length_conflict_multilevel : Error<
58685868
"pack expansion contains parameter pack %0 that has a different "
5869-
"length (%1 vs. %2) from outer parameter packs">;
5869+
"length (%1 vs. %select{|at least }2%3) from outer parameter packs">;
58705870
def err_pack_expansion_length_conflict_partial : Error<
58715871
"pack expansion contains parameter pack %0 that has a different "
58725872
"length (at least %1 vs. %2) from outer parameter packs">;

clang/include/clang/Basic/StmtNodes.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ def OpenACCDataConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
312312
def OpenACCEnterDataConstruct : StmtNode<OpenACCConstructStmt>;
313313
def OpenACCExitDataConstruct : StmtNode<OpenACCConstructStmt>;
314314
def OpenACCHostDataConstruct : StmtNode<OpenACCAssociatedStmtConstruct>;
315+
def OpenACCWaitConstruct : StmtNode<OpenACCConstructStmt>;
315316

316317
// OpenACC Additional Expressions.
317318
def OpenACCAsteriskSizeExpr : StmtNode<Expr>;

clang/include/clang/Driver/Options.td

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2555,6 +2555,21 @@ def fno_sanitize_trap : Flag<["-"], "fno-sanitize-trap">, Group<f_clang_Group>,
25552555
Alias<fno_sanitize_trap_EQ>, AliasArgs<["all"]>,
25562556
Visibility<[ClangOption, CLOption]>,
25572557
HelpText<"Disable trapping for all sanitizers">;
2558+
def fsanitize_merge_handlers_EQ
2559+
: CommaJoined<["-"], "fsanitize-merge=">,
2560+
Group<f_clang_Group>,
2561+
HelpText<"Allow compiler to merge handlers for specified sanitizers">;
2562+
def fno_sanitize_merge_handlers_EQ
2563+
: CommaJoined<["-"], "fno-sanitize-merge=">,
2564+
Group<f_clang_Group>,
2565+
HelpText<"Do not allow compiler to merge handlers for specified sanitizers">;
2566+
def fsanitize_merge_handlers : Flag<["-"], "fsanitize-merge">, Group<f_clang_Group>,
2567+
Alias<fsanitize_merge_handlers_EQ>, AliasArgs<["all"]>,
2568+
HelpText<"Allow compiler to merge handlers for all sanitizers">;
2569+
def fno_sanitize_merge_handlers : Flag<["-"], "fno-sanitize-merge">, Group<f_clang_Group>,
2570+
Alias<fno_sanitize_merge_handlers_EQ>, AliasArgs<["all"]>,
2571+
Visibility<[ClangOption, CLOption]>,
2572+
HelpText<"Do not allow compiler to merge handlers for any sanitizers">;
25582573
def fsanitize_undefined_trap_on_error
25592574
: Flag<["-"], "fsanitize-undefined-trap-on-error">, Group<f_clang_Group>,
25602575
Alias<fsanitize_trap_EQ>, AliasArgs<["undefined"]>;

0 commit comments

Comments
 (0)