Skip to content

Commit 9b9b90a

Browse files
committed
Fix other issues
1 parent 6a473e0 commit 9b9b90a

File tree

8 files changed

+27
-22
lines changed

8 files changed

+27
-22
lines changed

clang/include/clang/AST/ASTContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
15671567
/// and bit count.
15681568
QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const;
15691569

1570-
QualType getPredefinedSugarType(uint32_t KD) const;
1570+
QualType getPredefinedSugarType(PredefinedSugarType::Kind KD) const;
15711571

15721572
/// Gets the struct used to keep track of the extended descriptor for
15731573
/// pointer to blocks.

clang/include/clang/AST/Type.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8066,20 +8066,25 @@ class PredefinedSugarType final : public Type {
80668066
using Kind = PredefinedSugarKind;
80678067

80688068
private:
8069-
PredefinedSugarType(Kind KD, QualType UnderlyingType)
8070-
: Type(PredefinedSugar, UnderlyingType->getCanonicalTypeInternal(),
8071-
TypeDependence::None) {
8069+
PredefinedSugarType(Kind KD, const IdentifierInfo *IdentName,
8070+
QualType CanonicalType)
8071+
: Type(PredefinedSugar, CanonicalType, TypeDependence::None),
8072+
Name(IdentName) {
80728073
PredefinedSugarTypeBits.Kind = llvm::to_underlying(KD);
80738074
}
80748075

8076+
static StringRef getName(Kind KD);
8077+
8078+
const IdentifierInfo *Name;
8079+
80758080
public:
80768081
bool isSugared() const { return true; }
80778082

80788083
QualType desugar() const { return getCanonicalTypeInternal(); }
80798084

80808085
Kind getKind() const { return Kind(PredefinedSugarTypeBits.Kind); }
80818086

8082-
StringRef getName() const;
8087+
const IdentifierInfo *getIdentifier() const { return Name; }
80838088

80848089
static bool classof(const Type *T) {
80858090
return T->getTypeClass() == PredefinedSugar;

clang/include/clang/AST/TypeProperties.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,6 @@ let Class = PredefinedSugarType in {
10341034
let Read = [{ static_cast<uint32_t>(node->getKind()) }];
10351035
}
10361036
def : Creator<[{
1037-
return ctx.getPredefinedSugarType(kind);
1037+
return ctx.getPredefinedSugarType(static_cast<PredefinedSugarType::Kind>(kind));
10381038
}]>;
10391039
}

clang/lib/AST/ASTContext.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,10 +1524,9 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
15241524
// Using PredefinedSugarType makes these types as named sugar types rather
15251525
// than standard integer types, enabling better hints and diagnostics.
15261526
using Kind = PredefinedSugarType::Kind;
1527-
SizeType = getPredefinedSugarType(llvm::to_underlying(Kind::SizeT));
1528-
SignedSizeType =
1529-
getPredefinedSugarType(llvm::to_underlying(Kind::SignedSizeT));
1530-
PtrdiffType = getPredefinedSugarType(llvm::to_underlying(Kind::PtrdiffT));
1527+
SizeType = getPredefinedSugarType(Kind::SizeT);
1528+
SignedSizeType = getPredefinedSugarType(Kind::SignedSizeT);
1529+
PtrdiffType = getPredefinedSugarType(Kind::PtrdiffT);
15311530
} else {
15321531
SizeType = getFromTargetType(Target.getSizeType());
15331532
SignedSizeType = getFromTargetType(Target.getSignedSizeType());
@@ -5237,7 +5236,8 @@ QualType ASTContext::getDependentBitIntType(bool IsUnsigned,
52375236
return QualType(New, 0);
52385237
}
52395238

5240-
QualType ASTContext::getPredefinedSugarType(uint32_t KD) const {
5239+
QualType
5240+
ASTContext::getPredefinedSugarType(PredefinedSugarType::Kind KD) const {
52415241
using Kind = PredefinedSugarType::Kind;
52425242
auto getCanonicalType = [](const ASTContext &Ctx, Kind KDI) -> QualType {
52435243
switch (KDI) {
@@ -5250,8 +5250,9 @@ QualType ASTContext::getPredefinedSugarType(uint32_t KD) const {
52505250
}
52515251
llvm_unreachable("unexpected kind");
52525252
};
5253-
auto *New = new (*this, alignof(PredefinedSugarType)) PredefinedSugarType(
5254-
static_cast<Kind>(KD), getCanonicalType(*this, static_cast<Kind>(KD)));
5253+
auto *New = new (*this, alignof(PredefinedSugarType))
5254+
PredefinedSugarType(KD, &Idents.get(PredefinedSugarType::getName(KD)),
5255+
getCanonicalType(*this, static_cast<Kind>(KD)));
52555256
Types.push_back(New);
52565257
return QualType(New, 0);
52575258
}

clang/lib/AST/ASTImporter.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,8 +1895,7 @@ ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType(
18951895

18961896
ExpectedType clang::ASTNodeImporter::VisitPredefinedSugarType(
18971897
const clang::PredefinedSugarType *T) {
1898-
return Importer.getToContext().getPredefinedSugarType(
1899-
llvm::to_underlying(T->getKind()));
1898+
return Importer.getToContext().getPredefinedSugarType(T->getKind());
19001899
}
19011900

19021901
ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType(

clang/lib/AST/Type.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,8 +5623,8 @@ HLSLAttributedResourceType::findHandleTypeOnResource(const Type *RT) {
56235623
return nullptr;
56245624
}
56255625

5626-
StringRef PredefinedSugarType::getName() const {
5627-
switch (getKind()) {
5626+
StringRef PredefinedSugarType::getName(Kind KD) {
5627+
switch (KD) {
56285628
case Kind::SizeT:
56295629
return "__size_t";
56305630
case Kind::SignedSizeT:

clang/lib/AST/TypePrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,7 @@ void TypePrinter::printDependentBitIntAfter(const DependentBitIntType *T,
14201420

14211421
void TypePrinter::printPredefinedSugarBefore(const PredefinedSugarType *T,
14221422
raw_ostream &OS) {
1423-
OS << T->getName();
1423+
OS << T->getIdentifier()->getName();
14241424
spaceBeforePlaceHolder(OS);
14251425
}
14261426

clang/lib/Sema/TreeTransform.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ class TreeTransform {
12781278
QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
12791279
SourceLocation Loc);
12801280

1281-
QualType RebuildPredefinedSugarType(uint32_t K);
1281+
QualType RebuildPredefinedSugarType(PredefinedSugarType::Kind K);
12821282

12831283
/// Build a new template name given a nested name specifier, a flag
12841284
/// indicating whether the "template" keyword was provided, and the template
@@ -7257,8 +7257,7 @@ QualType TreeTransform<Derived>::TransformPredefinedSugarType(
72577257
QualType Result = TL.getType();
72587258

72597259
if (getDerived().AlwaysRebuild()) {
7260-
Result = getDerived().RebuildPredefinedSugarType(
7261-
llvm::to_underlying(EIT->getKind()));
7260+
Result = getDerived().RebuildPredefinedSugarType(EIT->getKind());
72627261
}
72637262

72647263
PredefinedSugarTypeLoc NewTL = TLB.push<PredefinedSugarTypeLoc>(Result);
@@ -17448,7 +17447,8 @@ QualType TreeTransform<Derived>::RebuildDependentBitIntType(
1744817447
}
1744917448

1745017449
template <typename Derived>
17451-
QualType TreeTransform<Derived>::RebuildPredefinedSugarType(uint32_t K) {
17450+
QualType TreeTransform<Derived>::RebuildPredefinedSugarType(
17451+
PredefinedSugarType::Kind K) {
1745217452
return SemaRef.Context.getPredefinedSugarType(K);
1745317453
}
1745417454

0 commit comments

Comments
 (0)