Skip to content

Commit c232c71

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I10e62201bd8794d01b32d0146a72ab862b39cebe
2 parents c164257 + 536d78c commit c232c71

File tree

24 files changed

+796
-485
lines changed

24 files changed

+796
-485
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 48 additions & 36 deletions
Large diffs are not rendered by default.

clang/lib/AST/Interp/ByteCodeExprGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ bool ByteCodeExprGen<Emitter>::VisitCompoundAssignOperator(
14681468
std::optional<PrimType> LHSComputationT =
14691469
classify(E->getComputationLHSType());
14701470
std::optional<PrimType> LT = classify(LHS->getType());
1471-
std::optional<PrimType> RT = classify(E->getComputationResultType());
1471+
std::optional<PrimType> RT = classify(RHS->getType());
14721472
std::optional<PrimType> ResultT = classify(E->getType());
14731473

14741474
if (!LT || !RT || !ResultT || !LHSComputationT)

clang/lib/AST/Interp/Descriptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static void moveArrayDesc(Block *B, const std::byte *Src, std::byte *Dst,
139139
static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
140140
bool IsActive, const Descriptor *D) {
141141
const bool IsUnion = D->ElemRecord->isUnion();
142-
auto CtorSub = [=](unsigned SubOff, Descriptor *F, bool IsBase) {
142+
auto CtorSub = [=](unsigned SubOff, const Descriptor *F, bool IsBase) {
143143
auto *Desc = reinterpret_cast<InlineDescriptor *>(Ptr + SubOff) - 1;
144144
Desc->Offset = SubOff;
145145
Desc->Desc = F;
@@ -161,7 +161,7 @@ static void ctorRecord(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
161161
}
162162

163163
static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) {
164-
auto DtorSub = [=](unsigned SubOff, Descriptor *F) {
164+
auto DtorSub = [=](unsigned SubOff, const Descriptor *F) {
165165
if (auto Fn = F->DtorFn)
166166
Fn(B, Ptr + SubOff, F);
167167
};

clang/lib/AST/Interp/Program.cpp

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
247247
unsigned VirtSize = 0;
248248

249249
// Helper to get a base descriptor.
250-
auto GetBaseDesc = [this](const RecordDecl *BD, Record *BR) -> Descriptor * {
250+
auto GetBaseDesc = [this](const RecordDecl *BD,
251+
const Record *BR) -> const Descriptor * {
251252
if (!BR)
252253
return nullptr;
253254
return allocateDescriptor(BD, BR, std::nullopt, /*isConst=*/false,
@@ -258,31 +259,39 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
258259
// Reserve space for base classes.
259260
Record::BaseList Bases;
260261
Record::VirtualBaseList VirtBases;
261-
if (auto *CD = dyn_cast<CXXRecordDecl>(RD)) {
262+
if (const auto *CD = dyn_cast<CXXRecordDecl>(RD)) {
263+
262264
for (const CXXBaseSpecifier &Spec : CD->bases()) {
263265
if (Spec.isVirtual())
264266
continue;
265267

266-
const RecordDecl *BD = Spec.getType()->castAs<RecordType>()->getDecl();
267-
Record *BR = getOrCreateRecord(BD);
268-
if (Descriptor *Desc = GetBaseDesc(BD, BR)) {
269-
BaseSize += align(sizeof(InlineDescriptor));
270-
Bases.push_back({BD, BaseSize, Desc, BR});
271-
BaseSize += align(BR->getSize());
272-
continue;
268+
// In error cases, the base might not be a RecordType.
269+
if (const auto *RT = Spec.getType()->getAs<RecordType>()) {
270+
const RecordDecl *BD = RT->getDecl();
271+
const Record *BR = getOrCreateRecord(BD);
272+
273+
if (const Descriptor *Desc = GetBaseDesc(BD, BR)) {
274+
BaseSize += align(sizeof(InlineDescriptor));
275+
Bases.push_back({BD, BaseSize, Desc, BR});
276+
BaseSize += align(BR->getSize());
277+
continue;
278+
}
273279
}
274280
return nullptr;
275281
}
276282

277283
for (const CXXBaseSpecifier &Spec : CD->vbases()) {
278-
const RecordDecl *BD = Spec.getType()->castAs<RecordType>()->getDecl();
279-
Record *BR = getOrCreateRecord(BD);
280284

281-
if (Descriptor *Desc = GetBaseDesc(BD, BR)) {
282-
VirtSize += align(sizeof(InlineDescriptor));
283-
VirtBases.push_back({BD, VirtSize, Desc, BR});
284-
VirtSize += align(BR->getSize());
285-
continue;
285+
if (const auto *RT = Spec.getType()->getAs<RecordType>()) {
286+
const RecordDecl *BD = RT->getDecl();
287+
const Record *BR = getOrCreateRecord(BD);
288+
289+
if (const Descriptor *Desc = GetBaseDesc(BD, BR)) {
290+
VirtSize += align(sizeof(InlineDescriptor));
291+
VirtBases.push_back({BD, VirtSize, Desc, BR});
292+
VirtSize += align(BR->getSize());
293+
continue;
294+
}
286295
}
287296
return nullptr;
288297
}
@@ -298,7 +307,7 @@ Record *Program::getOrCreateRecord(const RecordDecl *RD) {
298307
QualType FT = FD->getType();
299308
const bool IsConst = FT.isConstQualified();
300309
const bool IsMutable = FD->isMutable();
301-
Descriptor *Desc;
310+
const Descriptor *Desc;
302311
if (std::optional<PrimType> T = Ctx.classify(FT)) {
303312
Desc = createDescriptor(FD, *T, std::nullopt, IsConst,
304313
/*isTemporary=*/false, IsMutable);

clang/lib/AST/Interp/Record.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ class Record final {
2828
struct Field {
2929
const FieldDecl *Decl;
3030
unsigned Offset;
31-
Descriptor *Desc;
31+
const Descriptor *Desc;
3232
bool isBitField() const { return Decl->isBitField(); }
3333
};
3434

3535
/// Describes a base class.
3636
struct Base {
3737
const RecordDecl *Decl;
3838
unsigned Offset;
39-
Descriptor *Desc;
40-
Record *R;
39+
const Descriptor *Desc;
40+
const Record *R;
4141
};
4242

4343
/// Mapping from identifiers to field descriptors.

clang/lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ static bool attributeHasIdentifierArg(const IdentifierInfo &II) {
291291

292292
/// Determine whether the given attribute has an identifier argument.
293293
static ParsedAttributeArgumentsProperties
294-
attributeStringLiteralListArg(const IdentifierInfo &II) {
294+
attributeStringLiteralListArg(const llvm::Triple &T, const IdentifierInfo &II) {
295295
#define CLANG_ATTR_STRING_LITERAL_ARG_LIST
296296
return llvm::StringSwitch<uint32_t>(normalizeAttrName(II.getName()))
297297
#include "clang/Parse/AttrParserStringSwitches.inc"
@@ -550,7 +550,7 @@ unsigned Parser::ParseAttributeArgsCommon(
550550

551551
ExprVector ParsedExprs;
552552
ParsedAttributeArgumentsProperties ArgProperties =
553-
attributeStringLiteralListArg(*AttrName);
553+
attributeStringLiteralListArg(getTargetInfo().getTriple(), *AttrName);
554554
if (ParseAttributeArgumentList(*AttrName, ParsedExprs, ArgProperties)) {
555555
SkipUntil(tok::r_paren, StopAtSemi);
556556
return 0;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 -verify -std=c++98 %s -fexperimental-new-constant-interpreter
2+
// RUN: %clang_cc1 -verify -std=c++11 %s -fexperimental-new-constant-interpreter
3+
// RUN: %clang_cc1 -verify -std=c++14 %s -fexperimental-new-constant-interpreter
4+
// RUN: %clang_cc1 -verify -std=c++17 %s -fexperimental-new-constant-interpreter
5+
// RUN: %clang_cc1 -verify -std=c++20 %s -fexperimental-new-constant-interpreter
6+
// RUN: %clang_cc1 -verify -std=c++23 %s -fexperimental-new-constant-interpreter
7+
// RUN: %clang_cc1 -verify -std=c++2c %s -fexperimental-new-constant-interpreter
8+
9+
// https://github.com/llvm/llvm-project/issues/49103
10+
11+
template<class> struct A; // expected-note 0+ {{}}
12+
struct S : __make_integer_seq<A, int, 42> { }; // expected-error 0+ {{}}
13+
S s;

clang/test/AST/Interp/shifts.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,12 @@ namespace shifts {
188188
// ref-cxx17-error {{not an integral constant expression}} \
189189
// ref-cxx17-note {{in call to 'foo(2)'}}
190190
};
191+
192+
namespace LongInt {
193+
constexpr int f() {
194+
int a = 1;
195+
a <<= (long)0;
196+
return 1;
197+
}
198+
static_assert(f() == 1, "");
199+
};

clang/test/Sema/attr-function-return.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ __attribute__((function_return("thunk-extern"))) void w(void) {}
1313
// expected-warning@+1 {{'function_return' attribute argument not supported: invalid}}
1414
__attribute__((function_return("invalid"))) void v(void) {}
1515

16-
// expected-error@+1 {{'function_return' attribute requires a string}}
16+
// expected-error@+1 {{expected string literal as argument of 'function_return' attribute}}
1717
__attribute__((function_return(5))) void a(void) {}
1818

1919
// expected-error@+1 {{'function_return' attribute takes one argument}}

clang/test/Sema/callingconv-iamcu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ int __attribute__((pcs("aapcs", "aapcs"))) pcs1(void); // expected-error {{'pcs'
3636
int __attribute__((pcs())) pcs2(void); // expected-error {{'pcs' attribute takes one argument}}
3737
int __attribute__((pcs(pcs1))) pcs3(void); // expected-error {{'pcs' attribute requires a string}} \
3838
// expected-error {{invalid PCS type}}
39-
int __attribute__((pcs(0))) pcs4(void); // expected-error {{'pcs' attribute requires a string}}
39+
int __attribute__((pcs(0))) pcs4(void); // expected-error {{expected string literal as argument of 'pcs' attribute}}
4040
/* These are ignored because the target is i386 and not ARM */
4141
int __attribute__((pcs("aapcs"))) pcs5(void); // expected-warning {{'pcs' calling convention is not supported for this target}}
4242
int __attribute__((pcs("aapcs-vfp"))) pcs6(void); // expected-warning {{'pcs' calling convention is not supported for this target}}

0 commit comments

Comments
 (0)