Skip to content

Commit b0d0d19

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:acebaa01623b into amd-gfx:58cb02d5f29e
Local branch amd-gfx 58cb02d Merged main:814db6c53fae into amd-gfx:1cc8749516de Remote branch main acebaa0 [X86] fp-round.ll - regenerate VPTERNLOG comments
2 parents 58cb02d + acebaa0 commit b0d0d19

File tree

100 files changed

+7409
-665
lines changed

Some content is hidden

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

100 files changed

+7409
-665
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ Removed Compiler Flags
112112
Attribute Changes in Clang
113113
--------------------------
114114

115+
- The ``no_sanitize`` attribute now accepts both ``gnu`` and ``clang`` names.
116+
115117
Improvements to Clang's diagnostics
116118
-----------------------------------
117119

@@ -149,6 +151,8 @@ Bug Fixes to AST Handling
149151
Miscellaneous Bug Fixes
150152
^^^^^^^^^^^^^^^^^^^^^^^
151153

154+
- HTML tags in comments that span multiple lines are now parsed correctly by Clang's comment parser. (#GH120843)
155+
152156
Miscellaneous Clang Crashes Fixed
153157
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
154158

clang/include/clang/AST/DeclTemplate.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,15 +1841,23 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
18411841
LLVM_PREFERRED_TYPE(TemplateSpecializationKind)
18421842
unsigned SpecializationKind : 3;
18431843

1844+
/// Indicate that we have matched a parameter pack with a non pack
1845+
/// argument, when the opposite match is also allowed (strict pack match).
1846+
/// This needs to be cached as deduction is performed during declaration,
1847+
/// and we need the information to be preserved so that it is consistent
1848+
/// during instantiation.
1849+
bool MatchedPackOnParmToNonPackOnArg : 1;
1850+
18441851
protected:
18451852
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
18461853
DeclContext *DC, SourceLocation StartLoc,
18471854
SourceLocation IdLoc,
18481855
ClassTemplateDecl *SpecializedTemplate,
18491856
ArrayRef<TemplateArgument> Args,
1857+
bool MatchedPackOnParmToNonPackOnArg,
18501858
ClassTemplateSpecializationDecl *PrevDecl);
18511859

1852-
explicit ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
1860+
ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
18531861

18541862
public:
18551863
friend class ASTDeclReader;
@@ -1859,7 +1867,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
18591867
Create(ASTContext &Context, TagKind TK, DeclContext *DC,
18601868
SourceLocation StartLoc, SourceLocation IdLoc,
18611869
ClassTemplateDecl *SpecializedTemplate,
1862-
ArrayRef<TemplateArgument> Args,
1870+
ArrayRef<TemplateArgument> Args, bool MatchedPackOnParmToNonPackOnArg,
18631871
ClassTemplateSpecializationDecl *PrevDecl);
18641872
static ClassTemplateSpecializationDecl *CreateDeserialized(ASTContext &C,
18651873
GlobalDeclID ID);
@@ -1930,6 +1938,10 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
19301938
SpecializationKind = TSK;
19311939
}
19321940

1941+
bool hasMatchedPackOnParmToNonPackOnArg() const {
1942+
return MatchedPackOnParmToNonPackOnArg;
1943+
}
1944+
19331945
/// Get the point of instantiation (if any), or null if none.
19341946
SourceLocation getPointOfInstantiation() const {
19351947
return PointOfInstantiation;

clang/include/clang/AST/OpenMPClause.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9451,7 +9451,8 @@ struct TargetOMPContext final : public llvm::omp::OMPContext {
94519451
TargetOMPContext(ASTContext &ASTCtx,
94529452
std::function<void(StringRef)> &&DiagUnknownTrait,
94539453
const FunctionDecl *CurrentFunctionDecl,
9454-
ArrayRef<llvm::omp::TraitProperty> ConstructTraits);
9454+
ArrayRef<llvm::omp::TraitProperty> ConstructTraits,
9455+
int DeviceNum);
94559456

94569457
virtual ~TargetOMPContext() = default;
94579458

clang/include/clang/Basic/Attr.td

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,13 @@ class Clang<string name, bit allowInC = 1, int version = 1>
380380
bit AllowInC = allowInC;
381381
}
382382

383+
// This spelling combines the spellings of GCC and Clang for cases where the
384+
// spellings are equivalent for compile compatibility.
385+
class ClangGCC<string name, bit allowInC = 1, int version = 1>
386+
: Spelling<name, "ClangGCC", version> {
387+
bit AllowInC = allowInC;
388+
}
389+
383390
// HLSL Annotation spellings
384391
class HLSLAnnotation<string name> : Spelling<name, "HLSLAnnotation">;
385392

@@ -3677,7 +3684,7 @@ def X86ForceAlignArgPointer : InheritableAttr, TargetSpecificAttr<TargetAnyX86>
36773684
}
36783685

36793686
def NoSanitize : InheritableAttr {
3680-
let Spellings = [Clang<"no_sanitize">];
3687+
let Spellings = [ClangGCC<"no_sanitize">];
36813688
let Args = [VariadicStringArgument<"Sanitizers">];
36823689
let Subjects = SubjectList<[Function, ObjCMethod, GlobalVar], ErrorDiag>;
36833690
let Documentation = [NoSanitizeDocs];

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,9 @@ def W_Joined : Joined<["-"], "W">, Group<W_Group>,
932932
def Xanalyzer : Separate<["-"], "Xanalyzer">,
933933
HelpText<"Pass <arg> to the static analyzer">, MetaVarName<"<arg>">,
934934
Group<StaticAnalyzer_Group>;
935-
def Xarch__ : JoinedAndSeparate<["-"], "Xarch_">, Flags<[NoXarchOption]>;
935+
def Xarch__ : JoinedAndSeparate<["-"], "Xarch_">, Flags<[NoXarchOption]>,
936+
HelpText<"Pass <arg> to the compiliation if the target matches <arch>">,
937+
MetaVarName<"<arch> <arg>">;
936938
def Xarch_host : Separate<["-"], "Xarch_host">, Flags<[NoXarchOption]>,
937939
HelpText<"Pass <arg> to the CUDA/HIP host compilation">, MetaVarName<"<arg>">;
938940
def Xarch_device : Separate<["-"], "Xarch_device">, Flags<[NoXarchOption]>,
@@ -1115,8 +1117,8 @@ def fno_convergent_functions : Flag<["-"], "fno-convergent-functions">,
11151117

11161118
// Common offloading options
11171119
let Group = offload_Group in {
1118-
def offload_arch_EQ : Joined<["--"], "offload-arch=">, Flags<[NoXarchOption]>,
1119-
Visibility<[ClangOption, FlangOption]>,
1120+
def offload_arch_EQ : Joined<["--"], "offload-arch=">,
1121+
Visibility<[ClangOption, FlangOption]>, Flags<[NoXarchOption]>,
11201122
HelpText<"Specify an offloading device architecture for CUDA, HIP, or OpenMP. (e.g. sm_35). "
11211123
"If 'native' is used the compiler will detect locally installed architectures. "
11221124
"For HIP offloading, the device architecture can be followed by target ID features "

clang/include/clang/Sema/Sema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13499,8 +13499,8 @@ class Sema final : public SemaBase {
1349913499
bool InstantiateClassTemplateSpecialization(
1350013500
SourceLocation PointOfInstantiation,
1350113501
ClassTemplateSpecializationDecl *ClassTemplateSpec,
13502-
TemplateSpecializationKind TSK, bool Complain = true,
13503-
bool PrimaryHasMatchedPackOnParmToNonPackOnArg = false);
13502+
TemplateSpecializationKind TSK, bool Complain,
13503+
bool PrimaryHasMatchedPackOnParmToNonPackOnArg);
1350413504

1350513505
/// Instantiates the definitions of all of the member
1350613506
/// of the given class, which is an instantiation of a class template

clang/include/clang/Sema/SemaOpenMP.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,9 @@ class SemaOpenMP : public SemaBase {
849849
ArrayRef<OMPInteropInfo> AppendArgs, SourceLocation AdjustArgsLoc,
850850
SourceLocation AppendArgsLoc, SourceRange SR);
851851

852+
/// Called on device_num selector in context selectors.
853+
void ActOnOpenMPDeviceNum(Expr *DeviceNumExpr);
854+
852855
OMPClause *ActOnOpenMPSingleExprClause(OpenMPClauseKind Kind, Expr *Expr,
853856
SourceLocation StartLoc,
854857
SourceLocation LParenLoc,
@@ -1410,6 +1413,13 @@ class SemaOpenMP : public SemaBase {
14101413

14111414
void handleOMPAssumeAttr(Decl *D, const ParsedAttr &AL);
14121415

1416+
/// Setter and getter functions for device_num.
1417+
void setOpenMPDeviceNum(int Num);
1418+
1419+
int getOpenMPDeviceNum() const;
1420+
1421+
void setOpenMPDeviceNumID(StringRef ID);
1422+
14131423
private:
14141424
void *VarDataSharingAttributesStack;
14151425

@@ -1480,6 +1490,12 @@ class SemaOpenMP : public SemaBase {
14801490

14811491
/// All `omp assumes` we encountered so far.
14821492
SmallVector<OMPAssumeAttr *, 4> OMPAssumeGlobal;
1493+
1494+
/// Device number specified by the context selector.
1495+
int DeviceNum = -1;
1496+
1497+
/// Device number identifier specified by the context selector.
1498+
StringRef DeviceNumID;
14831499
};
14841500

14851501
} // namespace clang

clang/lib/AST/ASTImporter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6321,9 +6321,9 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
63216321
updateLookupTableForTemplateParameters(*ToTPList);
63226322
} else { // Not a partial specialization.
63236323
if (GetImportedOrCreateDecl(
6324-
D2, D, Importer.getToContext(), D->getTagKind(), DC,
6325-
*BeginLocOrErr, *IdLocOrErr, ClassTemplate, TemplateArgs,
6326-
PrevDecl))
6324+
D2, D, Importer.getToContext(), D->getTagKind(), DC, *BeginLocOrErr,
6325+
*IdLocOrErr, ClassTemplate, TemplateArgs,
6326+
D->hasMatchedPackOnParmToNonPackOnArg(), PrevDecl))
63276327
return D2;
63286328

63296329
// Update InsertPos, because preceding import calls may have invalidated

clang/lib/AST/CommentLexer.cpp

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,15 @@ const char *skipWhitespace(const char *BufferPtr, const char *BufferEnd) {
196196
return BufferEnd;
197197
}
198198

199+
const char *skipHorizontalWhitespace(const char *BufferPtr,
200+
const char *BufferEnd) {
201+
for (; BufferPtr != BufferEnd; ++BufferPtr) {
202+
if (!isHorizontalWhitespace(*BufferPtr))
203+
return BufferPtr;
204+
}
205+
return BufferEnd;
206+
}
207+
199208
bool isWhitespace(const char *BufferPtr, const char *BufferEnd) {
200209
return skipWhitespace(BufferPtr, BufferEnd) == BufferEnd;
201210
}
@@ -637,17 +646,41 @@ void Lexer::setupAndLexHTMLStartTag(Token &T) {
637646
formTokenWithChars(T, TagNameEnd, tok::html_start_tag);
638647
T.setHTMLTagStartName(Name);
639648

640-
BufferPtr = skipWhitespace(BufferPtr, CommentEnd);
649+
BufferPtr = skipHorizontalWhitespace(BufferPtr, CommentEnd);
650+
if (BufferPtr == CommentEnd) { // in BCPL comments
651+
State = LS_HTMLStartTag;
652+
return;
653+
}
641654

642655
const char C = *BufferPtr;
643656
if (BufferPtr != CommentEnd &&
644-
(C == '>' || C == '/' || isHTMLIdentifierStartingCharacter(C)))
657+
(C == '>' || C == '/' || isVerticalWhitespace(C) ||
658+
isHTMLIdentifierStartingCharacter(C)))
645659
State = LS_HTMLStartTag;
646660
}
647661

648662
void Lexer::lexHTMLStartTag(Token &T) {
649663
assert(State == LS_HTMLStartTag);
650664

665+
// Skip leading whitespace and comment decorations
666+
while (isVerticalWhitespace(*BufferPtr)) {
667+
BufferPtr = skipNewline(BufferPtr, CommentEnd);
668+
669+
if (CommentState == LCS_InsideCComment)
670+
skipLineStartingDecorations();
671+
672+
BufferPtr = skipHorizontalWhitespace(BufferPtr, CommentEnd);
673+
if (BufferPtr == CommentEnd) {
674+
// HTML starting tags must be defined in a single comment block.
675+
// It's likely a user-error where they forgot to terminate the comment.
676+
State = LS_Normal;
677+
// Since at least one newline was skipped and one token needs to be lexed,
678+
// return a newline.
679+
formTokenWithChars(T, BufferPtr, tok::newline);
680+
return;
681+
}
682+
}
683+
651684
const char *TokenPtr = BufferPtr;
652685
char C = *TokenPtr;
653686
if (isHTMLIdentifierCharacter(C)) {
@@ -693,14 +726,13 @@ void Lexer::lexHTMLStartTag(Token &T) {
693726

694727
// Now look ahead and return to normal state if we don't see any HTML tokens
695728
// ahead.
696-
BufferPtr = skipWhitespace(BufferPtr, CommentEnd);
729+
BufferPtr = skipHorizontalWhitespace(BufferPtr, CommentEnd);
697730
if (BufferPtr == CommentEnd) {
698-
State = LS_Normal;
699731
return;
700732
}
701733

702734
C = *BufferPtr;
703-
if (!isHTMLIdentifierStartingCharacter(C) &&
735+
if (!isHTMLIdentifierStartingCharacter(C) && !isVerticalWhitespace(C) &&
704736
C != '=' && C != '\"' && C != '\'' && C != '>' && C != '/') {
705737
State = LS_Normal;
706738
return;
@@ -774,8 +806,17 @@ void Lexer::lex(Token &T) {
774806
BufferPtr++;
775807

776808
CommentState = LCS_InsideBCPLComment;
777-
if (State != LS_VerbatimBlockBody && State != LS_VerbatimBlockFirstLine)
809+
switch (State) {
810+
case LS_VerbatimBlockFirstLine:
811+
case LS_VerbatimBlockBody:
812+
break;
813+
case LS_HTMLStartTag:
814+
BufferPtr = skipHorizontalWhitespace(BufferPtr, BufferEnd);
815+
break;
816+
default:
778817
State = LS_Normal;
818+
break;
819+
}
779820
CommentEnd = findBCPLCommentEnd(BufferPtr, BufferEnd);
780821
goto again;
781822
}
@@ -807,6 +848,14 @@ void Lexer::lex(Token &T) {
807848
while(EndWhitespace != BufferEnd && *EndWhitespace != '/')
808849
EndWhitespace++;
809850

851+
// When lexing the start of an HTML tag (i.e. going through the attributes)
852+
// there won't be any newlines generated.
853+
if (State == LS_HTMLStartTag && EndWhitespace != BufferEnd) {
854+
CommentState = LCS_BeforeComment;
855+
BufferPtr = EndWhitespace;
856+
goto again;
857+
}
858+
810859
// Turn any whitespace between comments (and there is only whitespace
811860
// between them -- guaranteed by comment extraction) into a newline. We
812861
// have two newlines between C comments in total (first one was synthesized
@@ -829,6 +878,14 @@ void Lexer::lex(Token &T) {
829878
BufferPtr += 2;
830879
assert(BufferPtr <= BufferEnd);
831880

881+
// When lexing the start of an HTML tag (i.e. going through the
882+
// attributes) there won't be any newlines generated - whitespace still
883+
// needs to be skipped.
884+
if (State == LS_HTMLStartTag && BufferPtr != BufferEnd) {
885+
CommentState = LCS_BetweenComments;
886+
goto again;
887+
}
888+
832889
// Synthenize newline just after the C comment, regardless if there is
833890
// actually a newline.
834891
formTokenWithChars(T, BufferPtr, tok::newline);

clang/lib/AST/DeclTemplate.cpp

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -957,18 +957,20 @@ FunctionTemplateSpecializationInfo *FunctionTemplateSpecializationInfo::Create(
957957
// ClassTemplateSpecializationDecl Implementation
958958
//===----------------------------------------------------------------------===//
959959

960-
ClassTemplateSpecializationDecl::
961-
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,
962-
DeclContext *DC, SourceLocation StartLoc,
963-
SourceLocation IdLoc,
964-
ClassTemplateDecl *SpecializedTemplate,
965-
ArrayRef<TemplateArgument> Args,
966-
ClassTemplateSpecializationDecl *PrevDecl)
960+
ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(
961+
ASTContext &Context, Kind DK, TagKind TK, DeclContext *DC,
962+
SourceLocation StartLoc, SourceLocation IdLoc,
963+
ClassTemplateDecl *SpecializedTemplate, ArrayRef<TemplateArgument> Args,
964+
bool MatchedPackOnParmToNonPackOnArg,
965+
ClassTemplateSpecializationDecl *PrevDecl)
967966
: CXXRecordDecl(DK, TK, Context, DC, StartLoc, IdLoc,
968967
SpecializedTemplate->getIdentifier(), PrevDecl),
969-
SpecializedTemplate(SpecializedTemplate),
970-
TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
971-
SpecializationKind(TSK_Undeclared) {
968+
SpecializedTemplate(SpecializedTemplate),
969+
TemplateArgs(TemplateArgumentList::CreateCopy(Context, Args)),
970+
SpecializationKind(TSK_Undeclared),
971+
MatchedPackOnParmToNonPackOnArg(MatchedPackOnParmToNonPackOnArg) {
972+
assert(DK == Kind::ClassTemplateSpecialization ||
973+
MatchedPackOnParmToNonPackOnArg == false);
972974
}
973975

974976
ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
@@ -977,18 +979,14 @@ ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
977979
SourceLocation(), nullptr, nullptr),
978980
SpecializationKind(TSK_Undeclared) {}
979981

980-
ClassTemplateSpecializationDecl *
981-
ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK,
982-
DeclContext *DC,
983-
SourceLocation StartLoc,
984-
SourceLocation IdLoc,
985-
ClassTemplateDecl *SpecializedTemplate,
986-
ArrayRef<TemplateArgument> Args,
987-
ClassTemplateSpecializationDecl *PrevDecl) {
988-
auto *Result =
989-
new (Context, DC) ClassTemplateSpecializationDecl(
990-
Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
991-
SpecializedTemplate, Args, PrevDecl);
982+
ClassTemplateSpecializationDecl *ClassTemplateSpecializationDecl::Create(
983+
ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc,
984+
SourceLocation IdLoc, ClassTemplateDecl *SpecializedTemplate,
985+
ArrayRef<TemplateArgument> Args, bool MatchedPackOnParmToNonPackOnArg,
986+
ClassTemplateSpecializationDecl *PrevDecl) {
987+
auto *Result = new (Context, DC) ClassTemplateSpecializationDecl(
988+
Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
989+
SpecializedTemplate, Args, MatchedPackOnParmToNonPackOnArg, PrevDecl);
992990
Result->setMayHaveOutOfDateDef(false);
993991

994992
// If the template decl is incomplete, copy the external lexical storage from
@@ -1175,7 +1173,10 @@ ClassTemplatePartialSpecializationDecl::ClassTemplatePartialSpecializationDecl(
11751173
ClassTemplatePartialSpecializationDecl *PrevDecl)
11761174
: ClassTemplateSpecializationDecl(
11771175
Context, ClassTemplatePartialSpecialization, TK, DC, StartLoc, IdLoc,
1178-
SpecializedTemplate, Args, PrevDecl),
1176+
// Tracking MatchedPackOnParmToNonPackOnArg for Partial
1177+
// Specializations is not needed.
1178+
SpecializedTemplate, Args, /*MatchedPackOnParmToNonPackOnArg=*/false,
1179+
PrevDecl),
11791180
TemplateParams(Params), InstantiatedFromMember(nullptr, false) {
11801181
if (AdoptTemplateParameterList(Params, this))
11811182
setInvalidDecl();

clang/lib/AST/JSONNodeDumper.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,11 @@ void JSONNodeDumper::VisitRecordDecl(const RecordDecl *RD) {
10031003
void JSONNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *RD) {
10041004
VisitRecordDecl(RD);
10051005

1006+
if (const auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
1007+
if (CTSD->hasMatchedPackOnParmToNonPackOnArg())
1008+
JOS.attribute("strict-pack-match", true);
1009+
}
1010+
10061011
// All other information requires a complete definition.
10071012
if (!RD->isCompleteDefinition())
10081013
return;

0 commit comments

Comments
 (0)