Skip to content

Commit 3f631fa

Browse files
authored
Merge pull request llvm#651 from AMD-Lightning-Internal/amd/merge/upstream_merge_20250213183028
merge main into amd-staging
2 parents c8f7889 + 176ace6 commit 3f631fa

File tree

135 files changed

+3159
-6459
lines changed

Some content is hidden

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

135 files changed

+3159
-6459
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ ABI Changes in This Version
5454
AST Dumping Potentially Breaking Changes
5555
----------------------------------------
5656

57+
- Added support for dumping template arguments of structural value kinds.
58+
5759
Clang Frontend Potentially Breaking Changes
5860
-------------------------------------------
5961

@@ -145,6 +147,9 @@ Improvements to Coverage Mapping
145147
Bug Fixes in This Version
146148
-------------------------
147149

150+
- Clang now outputs correct values when #embed data contains bytes with negative
151+
signed char values (#GH102798).
152+
148153
Bug Fixes to Compiler Builtins
149154
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
150155

@@ -252,6 +257,9 @@ clang-format
252257
libclang
253258
--------
254259

260+
- Fixed a buffer overflow in ``CXString`` implementation. The fix may result in
261+
increased memory allocation.
262+
255263
Code Completion
256264
---------------
257265

clang/include/clang/AST/JSONNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ class JSONNodeDumper
345345
void VisitDeclarationTemplateArgument(const TemplateArgument &TA);
346346
void VisitNullPtrTemplateArgument(const TemplateArgument &TA);
347347
void VisitIntegralTemplateArgument(const TemplateArgument &TA);
348+
void VisitStructuralValueTemplateArgument(const TemplateArgument &TA);
348349
void VisitTemplateTemplateArgument(const TemplateArgument &TA);
349350
void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA);
350351
void VisitExpressionTemplateArgument(const TemplateArgument &TA);

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class TextNodeDumper
249249
void VisitDeclarationTemplateArgument(const TemplateArgument &TA);
250250
void VisitNullPtrTemplateArgument(const TemplateArgument &TA);
251251
void VisitIntegralTemplateArgument(const TemplateArgument &TA);
252+
void VisitStructuralValueTemplateArgument(const TemplateArgument &TA);
252253
void VisitTemplateTemplateArgument(const TemplateArgument &TA);
253254
void VisitTemplateExpansionTemplateArgument(const TemplateArgument &TA);
254255
void VisitExpressionTemplateArgument(const TemplateArgument &TA);

clang/lib/AST/JSONNodeDumper.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,10 @@ void JSONNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &TA) {
17051705
void JSONNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) {
17061706
JOS.attribute("value", TA.getAsIntegral().getSExtValue());
17071707
}
1708+
void JSONNodeDumper::VisitStructuralValueTemplateArgument(
1709+
const TemplateArgument &TA) {
1710+
Visit(TA.getAsStructuralValue(), TA.getStructuralValueType());
1711+
}
17081712
void JSONNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument &TA) {
17091713
// FIXME: cannot just call dump() on the argument, as that doesn't specify
17101714
// the output format.

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,12 @@ void TextNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) {
12261226
dumpTemplateArgument(TA);
12271227
}
12281228

1229+
void TextNodeDumper::VisitStructuralValueTemplateArgument(
1230+
const TemplateArgument &TA) {
1231+
OS << " structural value";
1232+
dumpTemplateArgument(TA);
1233+
}
1234+
12291235
void TextNodeDumper::dumpTemplateName(TemplateName TN, StringRef Label) {
12301236
AddChild(Label, [=] {
12311237
{

clang/lib/Frontend/PrintPreprocessedOutput.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,11 +974,10 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
974974
// Loop over the contents and print them as a comma-delimited list of
975975
// values.
976976
bool PrintComma = false;
977-
for (auto Iter = Data->BinaryData.begin(), End = Data->BinaryData.end();
978-
Iter != End; ++Iter) {
977+
for (unsigned char Byte : Data->BinaryData.bytes()) {
979978
if (PrintComma)
980979
*Callbacks->OS << ", ";
981-
*Callbacks->OS << static_cast<unsigned>(*Iter);
980+
*Callbacks->OS << static_cast<int>(Byte);
982981
PrintComma = true;
983982
}
984983
} else if (Tok.isAnnotation()) {

clang/test/AST/ast-dump-templates.cpp

Lines changed: 163 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-dump=json %s | FileCheck --check-prefix=JSON %s
2-
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-print %s > %t
1+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -ast-dump=json %s | FileCheck --check-prefix=JSON %s
2+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -ast-print %s > %t
33
// RUN: FileCheck < %t %s -check-prefix=CHECK1
44
// RUN: FileCheck < %t %s -check-prefix=CHECK2
5-
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -ast-dump %s | FileCheck --check-prefix=DUMP %s
5+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -ast-dump %s | FileCheck --check-prefix=DUMP %s
66

77
// Test with serialization:
8-
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++17 -emit-pch -o %t %s
9-
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -x c++ -std=c++17 -include-pch %t \
8+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -std=c++20 -emit-pch -o %t %s
9+
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -x c++ -std=c++20 -include-pch %t \
1010
// RUN: -ast-dump-all /dev/null \
1111
// RUN: | sed -e "s/ <undeserialized declarations>//" -e "s/ imported//" \
1212
// RUN: | FileCheck --strict-whitespace --check-prefix=DUMP %s
@@ -135,6 +135,17 @@ namespace test7 {
135135
// DUMP: ClassTemplateSpecializationDecl {{.*}} struct A definition explicit_instantiation_definition strict-pack-match{{$}}
136136
} // namespce test7
137137

138+
namespace test8 {
139+
template<_Complex int x>
140+
struct pr126341;
141+
template<>
142+
struct pr126341<{1, 2}>;
143+
// DUMP-LABEL: NamespaceDecl {{.*}} test8{{$}}
144+
// DUMP-NEXT: |-ClassTemplateDecl {{.*}} pr126341
145+
// DUMP: `-ClassTemplateSpecializationDecl {{.*}} pr126341
146+
// DUMP: `-TemplateArgument structural value '1+2i'
147+
} // namespace test8
148+
138149
// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py
139150

140151

@@ -486,6 +497,7 @@ namespace test7 {
486497
// JSON-NEXT: "trivial": true
487498
// JSON-NEXT: },
488499
// JSON-NEXT: "defaultCtor": {
500+
// JSON-NEXT: "defaultedIsConstexpr": true,
489501
// JSON-NEXT: "exists": true,
490502
// JSON-NEXT: "nonTrivial": true,
491503
// JSON-NEXT: "userProvided": true
@@ -819,6 +831,7 @@ namespace test7 {
819831
// JSON-NEXT: "trivial": true
820832
// JSON-NEXT: },
821833
// JSON-NEXT: "defaultCtor": {
834+
// JSON-NEXT: "defaultedIsConstexpr": true,
822835
// JSON-NEXT: "exists": true,
823836
// JSON-NEXT: "nonTrivial": true,
824837
// JSON-NEXT: "userProvided": true
@@ -1408,6 +1421,7 @@ namespace test7 {
14081421
// JSON-NEXT: "qualType": "void () noexcept"
14091422
// JSON-NEXT: },
14101423
// JSON-NEXT: "inline": true,
1424+
// JSON-NEXT: "constexpr": true,
14111425
// JSON-NEXT: "explicitlyDefaulted": "default"
14121426
// JSON-NEXT: }
14131427
// JSON-NEXT: ]
@@ -1454,6 +1468,7 @@ namespace test7 {
14541468
// JSON-NEXT: "trivial": true
14551469
// JSON-NEXT: },
14561470
// JSON-NEXT: "defaultCtor": {
1471+
// JSON-NEXT: "defaultedIsConstexpr": true,
14571472
// JSON-NEXT: "exists": true,
14581473
// JSON-NEXT: "nonTrivial": true,
14591474
// JSON-NEXT: "userProvided": true
@@ -2067,6 +2082,7 @@ namespace test7 {
20672082
// JSON-NEXT: "qualType": "void () noexcept"
20682083
// JSON-NEXT: },
20692084
// JSON-NEXT: "inline": true,
2085+
// JSON-NEXT: "constexpr": true,
20702086
// JSON-NEXT: "explicitlyDefaulted": "default"
20712087
// JSON-NEXT: }
20722088
// JSON-NEXT: ]
@@ -6158,6 +6174,148 @@ namespace test7 {
61586174
// JSON-NEXT: ]
61596175
// JSON-NEXT: }
61606176
// JSON-NEXT: ]
6177+
// JSON-NEXT: },
6178+
// JSON-NEXT: {
6179+
// JSON-NEXT: "id": "0x{{.*}}",
6180+
// JSON-NEXT: "kind": "NamespaceDecl",
6181+
// JSON-NEXT: "loc": {
6182+
// JSON-NEXT: "offset": 4339,
6183+
// JSON-NEXT: "line": 138,
6184+
// JSON-NEXT: "col": 11,
6185+
// JSON-NEXT: "tokLen": 5
6186+
// JSON-NEXT: },
6187+
// JSON-NEXT: "range": {
6188+
// JSON-NEXT: "begin": {
6189+
// JSON-NEXT: "offset": 4329,
6190+
// JSON-NEXT: "col": 1,
6191+
// JSON-NEXT: "tokLen": 9
6192+
// JSON-NEXT: },
6193+
// JSON-NEXT: "end": {
6194+
// JSON-NEXT: "offset": 4648,
6195+
// JSON-NEXT: "line": 147,
6196+
// JSON-NEXT: "col": 1,
6197+
// JSON-NEXT: "tokLen": 1
6198+
// JSON-NEXT: }
6199+
// JSON-NEXT: },
6200+
// JSON-NEXT: "name": "test8",
6201+
// JSON-NEXT: "inner": [
6202+
// JSON-NEXT: {
6203+
// JSON-NEXT: "id": "0x{{.*}}",
6204+
// JSON-NEXT: "kind": "ClassTemplateDecl",
6205+
// JSON-NEXT: "loc": {
6206+
// JSON-NEXT: "offset": 4379,
6207+
// JSON-NEXT: "line": 140,
6208+
// JSON-NEXT: "col": 8,
6209+
// JSON-NEXT: "tokLen": 8
6210+
// JSON-NEXT: },
6211+
// JSON-NEXT: "range": {
6212+
// JSON-NEXT: "begin": {
6213+
// JSON-NEXT: "offset": 4347,
6214+
// JSON-NEXT: "line": 139,
6215+
// JSON-NEXT: "col": 1,
6216+
// JSON-NEXT: "tokLen": 8
6217+
// JSON-NEXT: },
6218+
// JSON-NEXT: "end": {
6219+
// JSON-NEXT: "offset": 4379,
6220+
// JSON-NEXT: "line": 140,
6221+
// JSON-NEXT: "col": 8,
6222+
// JSON-NEXT: "tokLen": 8
6223+
// JSON-NEXT: }
6224+
// JSON-NEXT: },
6225+
// JSON-NEXT: "name": "pr126341",
6226+
// JSON-NEXT: "inner": [
6227+
// JSON-NEXT: {
6228+
// JSON-NEXT: "id": "0x{{.*}}",
6229+
// JSON-NEXT: "kind": "NonTypeTemplateParmDecl",
6230+
// JSON-NEXT: "loc": {
6231+
// JSON-NEXT: "offset": 4369,
6232+
// JSON-NEXT: "line": 139,
6233+
// JSON-NEXT: "col": 23,
6234+
// JSON-NEXT: "tokLen": 1
6235+
// JSON-NEXT: },
6236+
// JSON-NEXT: "range": {
6237+
// JSON-NEXT: "begin": {
6238+
// JSON-NEXT: "offset": 4356,
6239+
// JSON-NEXT: "col": 10,
6240+
// JSON-NEXT: "tokLen": 8
6241+
// JSON-NEXT: },
6242+
// JSON-NEXT: "end": {
6243+
// JSON-NEXT: "offset": 4369,
6244+
// JSON-NEXT: "col": 23,
6245+
// JSON-NEXT: "tokLen": 1
6246+
// JSON-NEXT: }
6247+
// JSON-NEXT: },
6248+
// JSON-NEXT: "name": "x",
6249+
// JSON-NEXT: "type": {
6250+
// JSON-NEXT: "qualType": "_Complex int"
6251+
// JSON-NEXT: },
6252+
// JSON-NEXT: "depth": 0,
6253+
// JSON-NEXT: "index": 0
6254+
// JSON-NEXT: },
6255+
// JSON-NEXT: {
6256+
// JSON-NEXT: "id": "0x{{.*}}",
6257+
// JSON-NEXT: "kind": "CXXRecordDecl",
6258+
// JSON-NEXT: "loc": {
6259+
// JSON-NEXT: "offset": 4379,
6260+
// JSON-NEXT: "line": 140,
6261+
// JSON-NEXT: "col": 8,
6262+
// JSON-NEXT: "tokLen": 8
6263+
// JSON-NEXT: },
6264+
// JSON-NEXT: "range": {
6265+
// JSON-NEXT: "begin": {
6266+
// JSON-NEXT: "offset": 4372,
6267+
// JSON-NEXT: "col": 1,
6268+
// JSON-NEXT: "tokLen": 6
6269+
// JSON-NEXT: },
6270+
// JSON-NEXT: "end": {
6271+
// JSON-NEXT: "offset": 4379,
6272+
// JSON-NEXT: "col": 8,
6273+
// JSON-NEXT: "tokLen": 8
6274+
// JSON-NEXT: }
6275+
// JSON-NEXT: },
6276+
// JSON-NEXT: "name": "pr126341",
6277+
// JSON-NEXT: "tagUsed": "struct"
6278+
// JSON-NEXT: },
6279+
// JSON-NEXT: {
6280+
// JSON-NEXT: "id": "0x{{.*}}",
6281+
// JSON-NEXT: "kind": "ClassTemplateSpecializationDecl",
6282+
// JSON-NEXT: "name": "pr126341"
6283+
// JSON-NEXT: }
6284+
// JSON-NEXT: ]
6285+
// JSON-NEXT: },
6286+
// JSON-NEXT: {
6287+
// JSON-NEXT: "id": "0x{{.*}}",
6288+
// JSON-NEXT: "kind": "ClassTemplateSpecializationDecl",
6289+
// JSON-NEXT: "loc": {
6290+
// JSON-NEXT: "offset": 4407,
6291+
// JSON-NEXT: "line": 142,
6292+
// JSON-NEXT: "col": 8,
6293+
// JSON-NEXT: "tokLen": 8
6294+
// JSON-NEXT: },
6295+
// JSON-NEXT: "range": {
6296+
// JSON-NEXT: "begin": {
6297+
// JSON-NEXT: "offset": 4389,
6298+
// JSON-NEXT: "line": 141,
6299+
// JSON-NEXT: "col": 1,
6300+
// JSON-NEXT: "tokLen": 8
6301+
// JSON-NEXT: },
6302+
// JSON-NEXT: "end": {
6303+
// JSON-NEXT: "offset": 4422,
6304+
// JSON-NEXT: "line": 142,
6305+
// JSON-NEXT: "col": 23,
6306+
// JSON-NEXT: "tokLen": 1
6307+
// JSON-NEXT: }
6308+
// JSON-NEXT: },
6309+
// JSON-NEXT: "name": "pr126341",
6310+
// JSON-NEXT: "tagUsed": "struct",
6311+
// JSON-NEXT: "inner": [
6312+
// JSON-NEXT: {
6313+
// JSON-NEXT: "kind": "TemplateArgument",
6314+
// JSON-NEXT: "value": "1+2i"
6315+
// JSON-NEXT: }
6316+
// JSON-NEXT: ]
6317+
// JSON-NEXT: }
6318+
// JSON-NEXT: ]
61616319
// JSON-NEXT: }
61626320
// JSON-NEXT: ]
61636321
// JSON-NEXT: }

clang/test/Analysis/live-stmts.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Disabling this flaky test, see https://github.com/llvm/llvm-project/pull/126913#issuecomment-2655850766
2+
// UNSUPPORTED: true
3+
14
// RUN: %clang_analyze_cc1 -w -analyzer-checker=debug.DumpLiveExprs %s 2>&1\
25
// RUN: | FileCheck %s
36

clang/test/CodeGen/allow-ubsan-check.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int div(int x, int y) {
8686
}
8787

8888
// CHECK-LABEL: define dso_local i32 @null(
89-
// CHECK-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
89+
// CHECK-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
9090
// CHECK-NEXT: [[ENTRY:.*:]]
9191
// CHECK-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
9292
//
@@ -102,7 +102,7 @@ int div(int x, int y) {
102102
// CHECK-NEXT: ret i32 [[TMP2]]
103103
//
104104
// TR-LABEL: define dso_local i32 @null(
105-
// TR-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
105+
// TR-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
106106
// TR-NEXT: [[ENTRY:.*:]]
107107
// TR-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
108108
// TR-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 29), !nosanitize [[META2]]
@@ -116,7 +116,7 @@ int div(int x, int y) {
116116
// TR-NEXT: ret i32 [[TMP2]]
117117
//
118118
// REC-LABEL: define dso_local i32 @null(
119-
// REC-SAME: ptr noundef readonly [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
119+
// REC-SAME: ptr noundef readonly captures(address_is_null) [[X:%.*]]) local_unnamed_addr #[[ATTR0]] {
120120
// REC-NEXT: [[ENTRY:.*:]]
121121
// REC-NEXT: [[TMP0:%.*]] = icmp eq ptr [[X]], null, !nosanitize [[META2]]
122122
// REC-NEXT: [[TMP1:%.*]] = tail call i1 @llvm.allow.ubsan.check(i8 29), !nosanitize [[META2]]

clang/test/CodeGenCXX/RelativeVTablesABI/dynamic-cast.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// RUN: %clang_cc1 %s -triple=aarch64-unknown-fuchsia -O3 -o - -emit-llvm | FileCheck %s
55

6-
// CHECK: define{{.*}} ptr @_Z6upcastP1B(ptr noundef readnone returned %b) local_unnamed_addr
6+
// CHECK: define{{.*}} ptr @_Z6upcastP1B(ptr noundef readnone returned captures(ret: address, provenance) %b) local_unnamed_addr
77
// CHECK-NEXT: entry:
88
// CHECK-NEXT: ret ptr %b
99
// CHECK-NEXT: }
@@ -22,12 +22,12 @@
2222

2323
// CHECK: declare ptr @__dynamic_cast(ptr, ptr, ptr, i64) local_unnamed_addr
2424

25-
// CHECK: define{{.*}} ptr @_Z8selfcastP1B(ptr noundef readnone returned %b) local_unnamed_addr
25+
// CHECK: define{{.*}} ptr @_Z8selfcastP1B(ptr noundef readnone returned captures(ret: address, provenance) %b) local_unnamed_addr
2626
// CHECK-NEXT: entry
2727
// CHECK-NEXT: ret ptr %b
2828
// CHECK-NEXT: }
2929

30-
// CHECK: define{{.*}} ptr @_Z9void_castP1B(ptr noundef readonly %b) local_unnamed_addr
30+
// CHECK: define{{.*}} ptr @_Z9void_castP1B(ptr noundef readonly captures(address_is_null, ret: address, provenance) %b) local_unnamed_addr
3131
// CHECK-NEXT: entry:
3232
// CHECK-NEXT: [[isnull:%[0-9]+]] = icmp eq ptr %b, null
3333
// CHECK-NEXT: br i1 [[isnull]], label %[[dynamic_cast_end:[a-z0-9._]+]], label %[[dynamic_cast_notnull:[a-z0-9._]+]]

0 commit comments

Comments
 (0)