Skip to content

Commit 1abce96

Browse files
authored
Merge pull request #161 from AMD-Lightning-Internal/amd/merge/upstream_merge_20250116164428
merge main into amd-staging
2 parents 11540e5 + a7f09f9 commit 1abce96

File tree

346 files changed

+9342
-3023
lines changed

Some content is hidden

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

346 files changed

+9342
-3023
lines changed

clang-tools-extra/clang-reorder-fields/ReorderFieldsAction.cpp

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -118,47 +118,19 @@ findMembersUsedInInitExpr(const CXXCtorInitializer *Initializer,
118118
return Results;
119119
}
120120

121-
/// Returns the next token after `Loc` (including comment tokens).
122-
static std::optional<Token> getTokenAfter(SourceLocation Loc,
123-
const SourceManager &SM,
124-
const LangOptions &LangOpts) {
125-
if (Loc.isMacroID()) {
126-
return std::nullopt;
127-
}
128-
Loc = Lexer::getLocForEndOfToken(Loc, 0, SM, LangOpts);
129-
130-
// Break down the source location.
131-
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Loc);
132-
133-
// Try to load the file buffer.
134-
bool InvalidTemp = false;
135-
StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
136-
if (InvalidTemp)
137-
return std::nullopt;
138-
139-
const char *TokenBegin = File.data() + LocInfo.second;
140-
141-
Lexer lexer(SM.getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(),
142-
TokenBegin, File.end());
143-
lexer.SetCommentRetentionState(true);
144-
// Find the token.
145-
Token Tok;
146-
lexer.LexFromRawLexer(Tok);
147-
return Tok;
148-
}
149-
150121
/// Returns the end of the trailing comments after `Loc`.
151122
static SourceLocation getEndOfTrailingComment(SourceLocation Loc,
152123
const SourceManager &SM,
153124
const LangOptions &LangOpts) {
154125
// We consider any following comment token that is indented more than the
155126
// first comment to be part of the trailing comment.
156127
const unsigned Column = SM.getPresumedColumnNumber(Loc);
157-
std::optional<Token> Tok = getTokenAfter(Loc, SM, LangOpts);
128+
std::optional<Token> Tok =
129+
Lexer::findNextToken(Loc, SM, LangOpts, /*IncludeComments=*/true);
158130
while (Tok && Tok->is(tok::comment) &&
159131
SM.getPresumedColumnNumber(Tok->getLocation()) > Column) {
160132
Loc = Tok->getEndLoc();
161-
Tok = getTokenAfter(Loc, SM, LangOpts);
133+
Tok = Lexer::findNextToken(Loc, SM, LangOpts, /*IncludeComments=*/true);
162134
}
163135
return Loc;
164136
}

clang-tools-extra/clang-tidy/utils/LexerUtils.cpp

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,29 +86,6 @@ SourceLocation findNextTerminator(SourceLocation Start, const SourceManager &SM,
8686
return findNextAnyTokenKind(Start, SM, LangOpts, tok::comma, tok::semi);
8787
}
8888

89-
std::optional<Token>
90-
findNextTokenIncludingComments(SourceLocation Start, const SourceManager &SM,
91-
const LangOptions &LangOpts) {
92-
// `Lexer::findNextToken` will ignore comment
93-
if (Start.isMacroID())
94-
return std::nullopt;
95-
Start = Lexer::getLocForEndOfToken(Start, 0, SM, LangOpts);
96-
// Break down the source location.
97-
std::pair<FileID, unsigned> LocInfo = SM.getDecomposedLoc(Start);
98-
bool InvalidTemp = false;
99-
StringRef File = SM.getBufferData(LocInfo.first, &InvalidTemp);
100-
if (InvalidTemp)
101-
return std::nullopt;
102-
// Lex from the start of the given location.
103-
Lexer L(SM.getLocForStartOfFile(LocInfo.first), LangOpts, File.begin(),
104-
File.data() + LocInfo.second, File.end());
105-
L.SetCommentRetentionState(true);
106-
// Find the token.
107-
Token Tok;
108-
L.LexFromRawLexer(Tok);
109-
return Tok;
110-
}
111-
11289
std::optional<Token>
11390
findNextTokenSkippingComments(SourceLocation Start, const SourceManager &SM,
11491
const LangOptions &LangOpts) {

clang-tools-extra/clang-tidy/utils/LexerUtils.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ SourceLocation findNextAnyTokenKind(SourceLocation Start,
8989
}
9090
}
9191

92-
std::optional<Token>
92+
inline std::optional<Token>
9393
findNextTokenIncludingComments(SourceLocation Start, const SourceManager &SM,
94-
const LangOptions &LangOpts);
94+
const LangOptions &LangOpts) {
95+
return Lexer::findNextToken(Start, SM, LangOpts, true);
96+
}
9597

9698
// Finds next token that's not a comment.
9799
std::optional<Token> findNextTokenSkippingComments(SourceLocation Start,

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,8 @@ Bug Fixes to C++ Support
984984
- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#GH121274)
985985
- Fixed a crash caused by the incorrect construction of template arguments for CTAD alias guides when type
986986
constraints are applied. (#GH122134)
987+
- Fixed canonicalization of pack indexing types - Clang did not always recognized identical pack indexing. (#GH123033)
988+
987989

988990
Bug Fixes to AST Handling
989991
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4021,7 +4021,7 @@ class EnumDecl : public TagDecl {
40214021
QualType getIntegerType() const {
40224022
if (!IntegerType)
40234023
return QualType();
4024-
if (const Type *T = IntegerType.dyn_cast<const Type*>())
4024+
if (const Type *T = dyn_cast<const Type *>(IntegerType))
40254025
return QualType(T, 0);
40264026
return cast<TypeSourceInfo *>(IntegerType)->getType().getUnqualifiedType();
40274027
}

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4795,6 +4795,12 @@ def HLSLWaveActiveCountBits : LangBuiltin<"HLSL_LANG"> {
47954795
let Prototype = "unsigned int(bool)";
47964796
}
47974797

4798+
def HLSLWaveActiveSum : LangBuiltin<"HLSL_LANG"> {
4799+
let Spellings = ["__builtin_hlsl_wave_active_sum"];
4800+
let Attributes = [NoThrow, Const];
4801+
let Prototype = "void (...)";
4802+
}
4803+
47984804
def HLSLWaveGetLaneIndex : LangBuiltin<"HLSL_LANG"> {
47994805
let Spellings = ["__builtin_hlsl_wave_get_lane_index"];
48004806
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9303,7 +9303,7 @@ def err_typecheck_expect_scalar_or_vector : Error<
93039303
"invalid operand of type %0 where %1 or "
93049304
"a vector of such type is required">;
93059305
def err_typecheck_expect_any_scalar_or_vector : Error<
9306-
"invalid operand of type %0 where a scalar or vector is required">;
9306+
"invalid operand of type %0%select{| where a scalar or vector is required}1">;
93079307
def err_typecheck_expect_flt_or_vector : Error<
93089308
"invalid operand of type %0 where floating, complex or "
93099309
"a vector of such types is required">;

clang/include/clang/Basic/arm_sve.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,13 +1954,13 @@ let SVETargetGuard = "sve2,lut", SMETargetGuard = "sme2,lut" in {
19541954
def SVLUTI4_B : SInst<"svluti4_lane[_{d}]", "dd[i", "cUc", MergeNone, "aarch64_sve_luti4_lane", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_1>]>;
19551955
def SVLUTI4_H : SInst<"svluti4_lane[_{d}]", "dd[i", "sUsh", MergeNone, "aarch64_sve_luti4_lane", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
19561956

1957-
def SVLUTI4_x2 : SInst<"svluti4_lane[_{d}]_x2", "d2.d[i", "sUsh", MergeNone, "aarch64_sve_luti4_lane_x2", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
1957+
def SVLUTI4_x2 : SInst<"svluti4_lane[_{d}_x2]", "d2.d[i", "sUsh", MergeNone, "aarch64_sve_luti4_lane_x2", [VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
19581958
}
19591959

19601960
let SVETargetGuard = "sve2,lut,bf16", SMETargetGuard = "sme2,lut,bf16" in {
19611961
def SVLUTI2_BF16 : SInst<"svluti2_lane[_{d}]", "dd[i", "b", MergeNone, "aarch64_sve_luti2_lane", [ VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_7>]>;
19621962
def SVLUTI4_BF16 : SInst<"svluti4_lane[_{d}]", "dd[i", "b", MergeNone, "aarch64_sve_luti4_lane", [ VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
1963-
def SVLUTI4_BF16_x2 : SInst<"svluti4_lane[_{d}]_x2", "d2.d[i", "b", MergeNone, "aarch64_sve_luti4_lane_x2", [ VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
1963+
def SVLUTI4_BF16_x2 : SInst<"svluti4_lane[_{d}_x2]", "d2.d[i", "b", MergeNone, "aarch64_sve_luti4_lane_x2", [ VerifyRuntimeMode], [ImmCheck<2, ImmCheck0_3>]>;
19641964
}
19651965

19661966
////////////////////////////////////////////////////////////////////////////////

clang/include/clang/Lex/Lexer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,8 @@ class Lexer : public PreprocessorLexer {
554554
/// Returns the next token, or std::nullopt if the location is inside a macro.
555555
static std::optional<Token> findNextToken(SourceLocation Loc,
556556
const SourceManager &SM,
557-
const LangOptions &LangOpts);
557+
const LangOptions &LangOpts,
558+
bool IncludeComments = false);
558559

559560
/// Checks that the given token is the first token that occurs after
560561
/// the given location (this excludes comments and whitespace). Returns the

clang/lib/AST/ASTContext.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6248,16 +6248,18 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr,
62486248
Canonical = getCanonicalType(Expansions[Index]);
62496249
} else {
62506250
llvm::FoldingSetNodeID ID;
6251-
PackIndexingType::Profile(ID, *this, Pattern, IndexExpr, FullySubstituted);
6251+
PackIndexingType::Profile(ID, *this, Pattern.getCanonicalType(), IndexExpr,
6252+
FullySubstituted);
62526253
void *InsertPos = nullptr;
62536254
PackIndexingType *Canon =
62546255
DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
62556256
if (!Canon) {
62566257
void *Mem = Allocate(
62576258
PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
62586259
TypeAlignment);
6259-
Canon = new (Mem) PackIndexingType(*this, QualType(), Pattern, IndexExpr,
6260-
FullySubstituted, Expansions);
6260+
Canon = new (Mem)
6261+
PackIndexingType(*this, QualType(), Pattern.getCanonicalType(),
6262+
IndexExpr, FullySubstituted, Expansions);
62616263
DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
62626264
}
62636265
Canonical = QualType(Canon, 0);

0 commit comments

Comments
 (0)