Skip to content

Commit 4f79c8b

Browse files
committed
Align code with the community change 91cdd35
1 parent d6ecc46 commit 4f79c8b

File tree

6 files changed

+41
-41
lines changed

6 files changed

+41
-41
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6367,7 +6367,7 @@ void CodeGenModule::addGlobalIntelFPGAAnnotation(const VarDecl *VD,
63676367
auto RT = VD->getType()->castAs<RecordType>();
63686368

63696369
auto Gen = [&AnnotStr, this](const RecordType *Ty, auto &&Gen) -> void {
6370-
const CXXRecordDecl *RD = cast<CXXRecordDecl>(Ty->getDecl());
6370+
const CXXRecordDecl *RD = cast<CXXRecordDecl>(Ty->getOriginalDecl());
63716371

63726372
// Iterate over the fields of the struct.
63736373
for (const auto *Field : RD->fields()) {

clang/lib/CodeGen/Targets/SPIR.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ ABIArgInfo CommonSPIRABIInfo::classifyRegcallReturnType(QualType RetTy) const {
100100
return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
101101

102102
if (const RecordType *RT = RetTy->getAs<RecordType>()) {
103-
const RecordDecl *RD = RT->getDecl();
103+
const RecordDecl *RD = RT->getOriginalDecl();
104104
if (RD->hasFlexibleArrayMember())
105105
return classifyReturnType(RetTy);
106106
}
@@ -150,7 +150,7 @@ ABIArgInfo CommonSPIRABIInfo::classifyRegcallArgumentType(QualType Ty) const {
150150
return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
151151

152152
if (const RecordType *RT = Ty->getAs<RecordType>()) {
153-
const RecordDecl *RD = RT->getDecl();
153+
const RecordDecl *RD = RT->getOriginalDecl();
154154
if (RD->hasFlexibleArrayMember())
155155
return classifyArgumentType(Ty);
156156
}

clang/lib/CodeGen/Targets/X86.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static ABIArgInfo classifyOpenCL(QualType Ty, ASTContext &Context) {
916916
return ABIArgInfo::getIgnore();
917917

918918
if (const EnumType *EnumTy = Ty->getAs<EnumType>())
919-
Ty = EnumTy->getDecl()->getIntegerType();
919+
Ty = EnumTy->getOriginalDecl()->getIntegerType();
920920

921921
if (const RecordType *RT = Ty->getAs<RecordType>())
922922
return ABIArgInfo::getIndirect(Context.getTypeAlignInChars(RT),

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ class DiagDeviceFunction : public RecursiveASTVisitor<DiagDeviceFunction> {
764764

765765
// Skip checking the size expr, since a constant array type loc's size expr is
766766
// a constant expression.
767-
bool TraverseConstantArrayTypeLoc(const ConstantArrayTypeLoc &) {
767+
bool TraverseConstantArrayTypeLoc(const ConstantArrayTypeLoc &, bool) {
768768
return true;
769769
}
770770

@@ -1112,7 +1112,7 @@ class MarkWIScopeFnVisitor : public RecursiveASTVisitor<MarkWIScopeFnVisitor> {
11121112
if (!Callee)
11131113
// not a direct call - continue search
11141114
return true;
1115-
QualType Ty = Ctx.getRecordType(Call->getRecordDecl());
1115+
QualType Ty = Ctx.getCanonicalTagType(Call->getRecordDecl());
11161116
if (!SemaSYCL::isSyclType(Ty, SYCLTypeAttr::group))
11171117
// not a member of sycl::group - continue search
11181118
return true;
@@ -1336,7 +1336,7 @@ static ParmVarDecl *getSyclKernelHandlerArg(FunctionDecl *KernelCallerFunc) {
13361336
static bool isReadOnlyAccessor(const TemplateArgument &AccessModeArg) {
13371337
const auto *AccessModeArgEnumType =
13381338
AccessModeArg.getIntegralType()->castAs<EnumType>();
1339-
const EnumDecl *ED = AccessModeArgEnumType->getDecl();
1339+
const EnumDecl *ED = AccessModeArgEnumType->getOriginalDecl();
13401340

13411341
auto ReadOnly =
13421342
llvm::find_if(ED->enumerators(), [&](const EnumConstantDecl *E) {
@@ -2530,7 +2530,8 @@ class SyclKernelPointerHandler : public SyclKernelFieldHandler {
25302530
const CXXBaseSpecifier &BS) {
25312531
TypeSourceInfo *TInfo =
25322532
SemaSYCLRef.getASTContext().getTrivialTypeSourceInfo(
2533-
QualType(RD->getTypeForDecl(), 0), SourceLocation());
2533+
SemaSYCLRef.getASTContext().getCanonicalTagType(RD),
2534+
SourceLocation());
25342535
CXXBaseSpecifier *ModifiedBase = SemaSYCLRef.SemaRef.CheckBaseSpecifier(
25352536
const_cast<CXXRecordDecl *>(Parent), SourceRange(), BS.isVirtual(),
25362537
BS.getAccessSpecifier(), TInfo, SourceLocation());
@@ -2583,10 +2584,10 @@ class SyclKernelPointerHandler : public SyclKernelFieldHandler {
25832584
// Add this record as a field of it's parent record if it is not an
25842585
// array element.
25852586
if (!isArrayElement(FD, Ty))
2586-
addField(FD, QualType(ModifiedRD->getTypeForDecl(), 0));
2587+
addField(FD, SemaSYCLRef.getASTContext().getCanonicalTagType(ModifiedRD));
25872588
else
25882589
ModifiedArrayElementsOrArray.push_back(
2589-
QualType(ModifiedRD->getTypeForDecl(), 0));
2590+
SemaSYCLRef.getASTContext().getCanonicalTagType(ModifiedRD));
25902591

25912592
return true;
25922593
}
@@ -2713,7 +2714,7 @@ class SyclKernelPointerHandler : public SyclKernelFieldHandler {
27132714
if (!ModifiedBases.empty())
27142715
ModifiedRD->setBases(ModifiedBases.data(), ModifiedBases.size());
27152716

2716-
return QualType(ModifiedRD->getTypeForDecl(), 0);
2717+
return SemaSYCLRef.getASTContext().getCanonicalTagType(ModifiedRD);
27172718
}
27182719
QualType getNewArrayType() {
27192720
return ModifiedArrayElementsOrArray.pop_back_val();
@@ -3085,7 +3086,7 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
30853086
// struct are wrapped in a generated '__wrapper_class'.
30863087
if (StructDepth) {
30873088
RecordDecl *WrappedPointer = wrapField(FD, ModTy);
3088-
ModTy = SemaSYCLRef.getASTContext().getRecordType(WrappedPointer);
3089+
ModTy = SemaSYCLRef.getASTContext().getCanonicalTagType(WrappedPointer);
30893090
}
30903091

30913092
addParam(FD, ModTy);
@@ -3107,7 +3108,7 @@ class SyclKernelDeclCreator : public SyclKernelFieldHandler {
31073108

31083109
// Arrays are wrapped in a struct since they cannot be passed directly.
31093110
RecordDecl *WrappedArray = wrapField(FD, ArrayTy);
3110-
addParam(FD, SemaSYCLRef.getASTContext().getRecordType(WrappedArray));
3111+
addParam(FD, SemaSYCLRef.getASTContext().getCanonicalTagType(WrappedArray));
31113112
return true;
31123113
}
31133114

@@ -3939,14 +3940,16 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
39393940
const ASTRecordLayout &Info =
39403941
SemaSYCLRef.getASTContext().getASTRecordLayout(RD);
39413942
uint64_t NumInitExprs = Info.getFieldCount() + RD->getNumBases();
3942-
addCollectionInitListExpr(QualType(RD->getTypeForDecl(), 0), NumInitExprs);
3943+
addCollectionInitListExpr(
3944+
SemaSYCLRef.getASTContext().getCanonicalTagType(RD), NumInitExprs);
39433945
}
39443946

39453947
InitListExpr *createInitListExpr(const CXXRecordDecl *RD) {
39463948
const ASTRecordLayout &Info =
39473949
SemaSYCLRef.getASTContext().getASTRecordLayout(RD);
39483950
uint64_t NumInitExprs = Info.getFieldCount() + RD->getNumBases();
3949-
return createInitListExpr(QualType(RD->getTypeForDecl(), 0), NumInitExprs);
3951+
return createInitListExpr(
3952+
SemaSYCLRef.getASTContext().getCanonicalTagType(RD), NumInitExprs);
39503953
}
39513954

39523955
InitListExpr *createInitListExpr(QualType InitTy, uint64_t NumChildInits) {
@@ -3981,7 +3984,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
39813984

39823985
VarDecl *VD = VarDecl::Create(
39833986
Ctx, DC, KernelObj->getLocation(), KernelObj->getLocation(), Ident,
3984-
QualType(KernelObj->getTypeForDecl(), 0), TSInfo, SC_None);
3987+
Ctx.getCanonicalTagType(KernelObj), TSInfo, SC_None);
39853988
return VD;
39863989
}
39873990

@@ -4175,7 +4178,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
41754178
DeclRefExpr *KernelObjCloneRef = DeclRefExpr::Create(
41764179
S.getASTContext(), NestedNameSpecifierLoc(), KernelCallerSrcLoc,
41774180
KernelObjClone, false, DeclarationNameInfo(),
4178-
QualType(KernelObj->getTypeForDecl(), 0), VK_LValue);
4181+
S.getASTContext().getCanonicalTagType(KernelObj), VK_LValue);
41794182
MemberExprBases.push_back(KernelObjCloneRef);
41804183
}
41814184
}
@@ -4292,7 +4295,7 @@ class SyclKernelBodyCreator : public SyclKernelFieldHandler {
42924295
++StructDepth;
42934296

42944297
CXXCastPath BasePath;
4295-
QualType DerivedTy(RD->getTypeForDecl(), 0);
4298+
QualType DerivedTy = SemaSYCLRef.getASTContext().getCanonicalTagType(RD);
42964299
QualType BaseTy = BS.getType();
42974300
SemaSYCLRef.SemaRef.CheckDerivedToBaseConversion(
42984301
DerivedTy, BaseTy, KernelCallerSrcLoc, SourceRange(), &BasePath,
@@ -4792,9 +4795,11 @@ class SyclKernelIntHeaderCreator : public SyclKernelFieldHandler {
47924795
: SyclKernelFieldHandler(S), Header(H) {
47934796

47944797
// The header needs to access the kernel object size.
4795-
int64_t ObjSize = SemaSYCLRef.getASTContext()
4796-
.getTypeSizeInChars(KernelObj->getTypeForDecl())
4797-
.getQuantity();
4798+
int64_t ObjSize =
4799+
SemaSYCLRef.getASTContext()
4800+
.getTypeSizeInChars(
4801+
SemaSYCLRef.getASTContext().getCanonicalTagType(KernelObj))
4802+
.getQuantity();
47984803
Header.startKernel(KernelFunc, NameType, KernelObj->getLocation(), IsESIMD,
47994804
IsSYCLUnnamedKernel(S, KernelFunc), ObjSize);
48004805
}
@@ -5144,7 +5149,7 @@ class SYCLKernelNameTypeVisitor
51445149
}
51455150

51465151
void VisitTagType(const TagType *TT) {
5147-
return DiagnoseKernelNameType(TT->getDecl());
5152+
return DiagnoseKernelNameType(TT->getOriginalDecl());
51485153
}
51495154

51505155
void DiagnoseKernelNameType(const NamedDecl *DeclNamed) {
@@ -6269,7 +6274,7 @@ class SYCLFwdDeclEmitter
62696274
}
62706275

62716276
void VisitTagType(const TagType *T) {
6272-
TagDecl *TD = T->getDecl();
6277+
TagDecl *TD = T->getOriginalDecl();
62736278
if (const auto *TSD = dyn_cast<ClassTemplateSpecializationDecl>(TD)) {
62746279
// - first, recurse into template parameters and emit needed forward
62756280
// declarations
@@ -6423,7 +6428,7 @@ class SYCLKernelNameTypePrinter
64236428
}
64246429

64256430
void VisitTagType(const TagType *T) {
6426-
TagDecl *RD = T->getDecl();
6431+
TagDecl *RD = T->getOriginalDecl();
64276432
if (const auto *TSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) {
64286433

64296434
// Print template class name
@@ -6469,8 +6474,8 @@ class SYCLKernelNameTypePrinter
64696474
if (const EnumType *ET = T->getAs<EnumType>()) {
64706475
const llvm::APSInt &Val = TA.getAsIntegral();
64716476
OS << "static_cast<";
6472-
ET->getDecl()->printQualifiedName(OS, Policy,
6473-
/*WithGlobalNsPrefix*/ true);
6477+
ET->getOriginalDecl()->printQualifiedName(OS, Policy,
6478+
/*WithGlobalNsPrefix*/ true);
64746479
OS << ">(" << Val << ")";
64756480
} else {
64766481
TA.print(Policy, OS, false /* IncludeType */);
@@ -6774,14 +6779,7 @@ class FreeFunctionPrinter {
67746779
QualType T = Param->getType();
67756780
QualType CT = T.getCanonicalType();
67766781

6777-
auto *ET = dyn_cast<ElaboratedType>(T.getTypePtr());
6778-
if (!ET) {
6779-
ParmListOstream << T.getAsString(Policy);
6780-
continue;
6781-
}
6782-
6783-
auto *TST =
6784-
dyn_cast<TemplateSpecializationType>(ET->getNamedType().getTypePtr());
6782+
auto *TST = dyn_cast<TemplateSpecializationType>(T.getTypePtr());
67856783
auto *CTST = dyn_cast<TemplateSpecializationType>(CT.getTypePtr());
67866784
if (!TST || !CTST) {
67876785
ParmListOstream << T.getAsString(Policy);

clang/lib/Sema/SemaSYCLDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ bool isDeviceAspectType(const QualType Ty) {
659659
if (!ET)
660660
return false;
661661

662-
if (const auto *Attr = ET->getDecl()->getAttr<SYCLTypeAttr>())
662+
if (const auto *Attr = ET->getOriginalDecl()->getAttr<SYCLTypeAttr>())
663663
return Attr->getType() == SYCLTypeAttr::aspect;
664664

665665
return false;

libclc/utils/libclc-remangler/LibclcRemangler.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ clang::QualType getBaseType(StringRef Name, clang::ASTContext *AST,
270270
auto *DC = AST->getTranslationUnitDecl();
271271
auto *ED = EnumDecl::Create(*AST, DC, SourceLocation(), SourceLocation(),
272272
&II, nullptr, false, false, true);
273-
Res = AST->getEnumType(ED);
273+
Res = AST->getCanonicalTagType(ED);
274274
}
275275
return Res;
276276
}
@@ -620,18 +620,20 @@ class Remangler {
620620
StringRef(KNN->DataStr).split("__spv::").second.str();
621621
auto *II = &AST->Idents.get(StructName, tok::TokenKind::identifier);
622622
RD = RecordDecl::Create(*AST, TagTypeKind::Struct, SpvNamespace, SL, SL, II);
623-
auto *NNS = NestedNameSpecifier::Create(*AST, nullptr, SpvNamespace);
624-
auto RecordQT = AST->getRecordType(RD);
625-
NNS = NestedNameSpecifier::Create(*AST, NNS, RecordQT.getTypePtr());
623+
NestedNameSpecifier NNS =
624+
NestedNameSpecifier(*AST, SpvNamespace, /*Prefix=*/std::nullopt);
625+
auto RecordQT = AST->getCanonicalTagType(RD);
626+
NNS = NestedNameSpecifier(RecordQT->getTypePtr());
626627
auto &EnumName =
627628
AST->Idents.get(Res.getBaseTypeIdentifier()->getName());
628629
// We need to recreate the enum, now that we have access to all the
629630
// namespace/class info.
630631
auto *ED =
631632
EnumDecl::Create(*AST, RD, SourceLocation(), SourceLocation(),
632633
&EnumName, nullptr, false, false, true);
633-
Res = AST->getEnumType(ED);
634-
Res = AST->getElaboratedType(ElaboratedTypeKeyword::None, NNS, Res);
634+
Res = AST->getCanonicalTagType(ED);
635+
Res = AST->getTagType(ElaboratedTypeKeyword::None, NNS, ED,
636+
/*OwnsTag=*/false);
635637
// Store the elaborated type for reuse, this is important as clang uses
636638
// substitutions for ET based on the object not the name enclosed in.
637639
NestedNamesQTMap[N] = Res;

0 commit comments

Comments
 (0)