From 6e207dd939057b30296d5858fe9b03f47aa6a685 Mon Sep 17 00:00:00 2001 From: YexuanXiao Date: Sat, 14 Jun 2025 05:34:11 +0800 Subject: [PATCH 1/2] Try add PredefinedSugarType --- clang/include/clang/AST/ASTContext.h | 2 + clang/include/clang/AST/RecursiveASTVisitor.h | 4 ++ clang/include/clang/AST/Type.h | 35 +++++++++++++++++ clang/include/clang/AST/TypeLoc.h | 4 ++ clang/include/clang/AST/TypeProperties.td | 12 ++++++ clang/include/clang/Basic/TypeNodes.td | 1 + .../clang/Serialization/TypeBitCodes.def | 1 + clang/lib/AST/ASTContext.cpp | 21 +++++++++- clang/lib/AST/ASTImporter.cpp | 6 +++ clang/lib/AST/ASTStructuralEquivalence.cpp | 8 ++++ clang/lib/AST/ItaniumMangle.cpp | 4 ++ clang/lib/AST/TypePrinter.cpp | 10 +++++ clang/lib/CodeGen/CGDebugInfo.cpp | 3 +- clang/lib/CodeGen/CodeGenFunction.cpp | 1 + clang/lib/Sema/SemaExpr.cpp | 3 ++ clang/lib/Sema/TreeTransform.h | 28 +++++++++++++ clang/lib/Serialization/ASTReader.cpp | 5 +++ clang/lib/Serialization/ASTWriter.cpp | 6 +++ clang/test/AST/ast-dump-expr-json.c | 9 ++--- clang/test/AST/ast-dump-expr-json.cpp | 9 ++--- clang/test/AST/ast-dump-stmt-json.cpp | 39 +++++++------------ clang/test/AST/ast-dump-types-errors-json.cpp | 3 +- clang/tools/libclang/CIndex.cpp | 5 +++ 23 files changed, 176 insertions(+), 43 deletions(-) diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 1e161b18f9a6d..bf54a49234266 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1530,6 +1530,8 @@ class ASTContext : public RefCountedBase { /// and bit count. QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const; + QualType getPredefinedSugarType(uint32_t KD, QualType UnderlyingType) const; + /// Gets the struct used to keep track of the extended descriptor for /// pointer to blocks. QualType getBlockDescriptorExtendedType() const; diff --git a/clang/include/clang/AST/RecursiveASTVisitor.h b/clang/include/clang/AST/RecursiveASTVisitor.h index a11157c006f92..3f54089bb489b 100644 --- a/clang/include/clang/AST/RecursiveASTVisitor.h +++ b/clang/include/clang/AST/RecursiveASTVisitor.h @@ -1210,6 +1210,8 @@ DEF_TRAVERSE_TYPE(BitIntType, {}) DEF_TRAVERSE_TYPE(DependentBitIntType, { TRY_TO(TraverseStmt(T->getNumBitsExpr())); }) +DEF_TRAVERSE_TYPE(PredefinedSugarType, {}) + #undef DEF_TRAVERSE_TYPE // ----------------- TypeLoc traversal ----------------- @@ -1526,6 +1528,8 @@ DEF_TRAVERSE_TYPELOC(DependentBitIntType, { TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr())); }) +DEF_TRAVERSE_TYPELOC(PredefinedSugarType, {}) + #undef DEF_TRAVERSE_TYPELOC // ----------------- Decl traversal ----------------- diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index a6c26a07800c3..e4f4052e5555f 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -8054,6 +8054,41 @@ class DependentBitIntType final : public Type, public llvm::FoldingSetNode { } }; +class PredefinedSugarType final : public Type { +public: + enum Kind { SizeT, SignedSizeT, PtrdiffT }; + friend class ASTContext; + +private: + Kind K; + QualType Underlying; + PredefinedSugarType(Kind KD, QualType UnderlyingType) + : Type(PredefinedSugar, UnderlyingType->getCanonicalTypeInternal(), + TypeDependence::None), + K(KD), Underlying(UnderlyingType) {} + +public: + bool isSugared() const { return true; } + QualType desugar() const { return Underlying; } + Kind getKind() const { return K; } + + StringRef getName() const { + switch (K) { + case SizeT: + return "__size_t"; + case SignedSizeT: + return "__signed_size_t"; + case PtrdiffT: + return "__ptrdiff_t"; + } + llvm_unreachable(""); + } + + static bool classof(const Type *T) { + return T->getTypeClass() == PredefinedSugar; + } +}; + /// A qualifier set is used to build a set of qualifiers. class QualifierCollector : public Qualifiers { public: diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 53c7ea8c65df2..d2569c4f95135 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -2767,6 +2767,10 @@ class DependentBitIntTypeLoc final : public InheritingConcreteTypeLoc {}; +class PredefinedSugarTypeLoc final + : public InheritingConcreteTypeLoc {}; + class ObjCProtocolLoc { ObjCProtocolDecl *Protocol = nullptr; SourceLocation Loc = SourceLocation(); diff --git a/clang/include/clang/AST/TypeProperties.td b/clang/include/clang/AST/TypeProperties.td index 6e44bce893e79..6aed935b7c6ce 100644 --- a/clang/include/clang/AST/TypeProperties.td +++ b/clang/include/clang/AST/TypeProperties.td @@ -1028,3 +1028,15 @@ let Class = DependentBitIntType in { return ctx.getDependentBitIntType(isUnsigned, numBitsExpr); }]>; } + +let Class = PredefinedSugarType in { + def : Property<"underlying", QualType> { + let Read = [{ node->desugar() }]; + } + def : Property<"k", UInt32> { + let Read = [{ static_cast(node->getKind()) }]; + } + def : Creator<[{ + return ctx.getPredefinedSugarType(k, underlying); + }]>; +} diff --git a/clang/include/clang/Basic/TypeNodes.td b/clang/include/clang/Basic/TypeNodes.td index 567b8a5ca5a4d..164b3f5727048 100644 --- a/clang/include/clang/Basic/TypeNodes.td +++ b/clang/include/clang/Basic/TypeNodes.td @@ -117,3 +117,4 @@ def PipeType : TypeNode; def AtomicType : TypeNode; def BitIntType : TypeNode; def DependentBitIntType : TypeNode, AlwaysDependent; +def PredefinedSugarType : TypeNode, NeverCanonical; \ No newline at end of file diff --git a/clang/include/clang/Serialization/TypeBitCodes.def b/clang/include/clang/Serialization/TypeBitCodes.def index b8cde2e370960..613eb6af2005a 100644 --- a/clang/include/clang/Serialization/TypeBitCodes.def +++ b/clang/include/clang/Serialization/TypeBitCodes.def @@ -69,5 +69,6 @@ TYPE_BIT_CODE(CountAttributed, COUNT_ATTRIBUTED, 57) TYPE_BIT_CODE(ArrayParameter, ARRAY_PARAMETER, 58) TYPE_BIT_CODE(HLSLAttributedResource, HLSLRESOURCE_ATTRIBUTED, 59) TYPE_BIT_CODE(HLSLInlineSpirv, HLSL_INLINE_SPIRV, 60) +TYPE_BIT_CODE(PredefinedSugar, PREDEFINED_SUGAR, 61) #undef TYPE_BIT_CODE diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index a57c84b00442e..228bdac4dfbee 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2528,8 +2528,13 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = static_cast(Width); } } + break; + case Type::PredefinedSugar: + return getTypeInfo(cast(T)->desugar().getTypePtr()); + break; + case Type::Pipe: Width = Target->getPointerWidth(LangAS::opencl_global); Align = Target->getPointerAlign(LangAS::opencl_global); @@ -5148,6 +5153,14 @@ QualType ASTContext::getDependentBitIntType(bool IsUnsigned, return QualType(New, 0); } +QualType ASTContext::getPredefinedSugarType(uint32_t KD, + QualType UnderlyingType) const { + auto *New = new (*this, alignof(PredefinedSugarType)) PredefinedSugarType( + static_cast(KD), UnderlyingType); + Types.push_back(New); + return QualType(New, 0); +} + #ifndef NDEBUG static bool NeedsInjectedClassNameType(const RecordDecl *D) { if (!isa(D)) return false; @@ -6743,8 +6756,9 @@ QualType ASTContext::getTagDeclType(const TagDecl *Decl) const { QualType ASTContext::getSizeType() const { if (SizeType.isNull()) { if (!getLangOpts().HLSL) - SizeType = getTypedefType(buildImplicitTypedef( - getFromTargetType(Target->getSizeType()), "__size_t")); + SizeType = + getPredefinedSugarType(PredefinedSugarType::Kind::SizeT, + getFromTargetType(Target->getSizeType())); else SizeType = getFromTargetType(Target->getSizeType()); } @@ -14573,6 +14587,9 @@ static QualType getCommonSugarTypeNode(ASTContext &Ctx, const Type *X, DX->isCountInBytes(), DX->isOrNull(), CDX); } + case Type::PredefinedSugar: { + return QualType(); + } } llvm_unreachable("Unhandled Type Class"); } diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index 003bad225e30c..b765c3282b3e5 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -1894,6 +1894,12 @@ ExpectedType clang::ASTNodeImporter::VisitDependentBitIntType( *ToNumBitsExprOrErr); } +ExpectedType clang::ASTNodeImporter::VisitPredefinedSugarType( + const clang::PredefinedSugarType *T) { + return Importer.getToContext().getPredefinedSugarType(T->getKind(), + T->desugar()); +} + ExpectedType clang::ASTNodeImporter::VisitDependentSizedMatrixType( const clang::DependentSizedMatrixType *T) { Error Err = Error::success(); diff --git a/clang/lib/AST/ASTStructuralEquivalence.cpp b/clang/lib/AST/ASTStructuralEquivalence.cpp index 704de8156132c..80d9a81032a27 100644 --- a/clang/lib/AST/ASTStructuralEquivalence.cpp +++ b/clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1480,6 +1480,14 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, return false; break; } + case Type::PredefinedSugar: { + const auto *TP1 = cast(T1); + const auto *TP2 = cast(T2); + + if (TP1->getKind() != TP2->getKind()) + return false; + break; + } } // end switch return true; diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp index ecf5be220439b..17ac833fe839f 100644 --- a/clang/lib/AST/ItaniumMangle.cpp +++ b/clang/lib/AST/ItaniumMangle.cpp @@ -2523,6 +2523,10 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty, mangleSourceNameWithAbiTags(cast(Ty)->getDecl()); break; + case Type::PredefinedSugar: + mangleType(cast(Ty)->desugar()); + break; + case Type::UnresolvedUsing: mangleSourceNameWithAbiTags( cast(Ty)->getDecl()); diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp index 330cfcd962825..23682a01acae8 100644 --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -248,6 +248,7 @@ bool TypePrinter::canPrefixQualifiers(const Type *T, case Type::BTFTagAttributed: case Type::HLSLAttributedResource: case Type::HLSLInlineSpirv: + case Type::PredefinedSugar: CanPrefixQualifiers = true; break; @@ -1417,6 +1418,15 @@ void TypePrinter::printDependentBitIntBefore(const DependentBitIntType *T, void TypePrinter::printDependentBitIntAfter(const DependentBitIntType *T, raw_ostream &OS) {} +void TypePrinter::printPredefinedSugarBefore(const PredefinedSugarType *T, + raw_ostream &OS) { + OS << T->getName(); + spaceBeforePlaceHolder(OS); +} + +void TypePrinter::printPredefinedSugarAfter(const PredefinedSugarType *T, + raw_ostream &OS) {} + /// Appends the given scope to the end of a string. void TypePrinter::AppendScope(DeclContext *DC, raw_ostream &OS, DeclarationName NameInScope) { diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index fbcc330aca6bb..b98762e2e4f5a 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -4047,7 +4047,8 @@ llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit) { return CreateType(cast(Ty), Unit); case Type::HLSLInlineSpirv: return CreateType(cast(Ty), Unit); - + case Type::PredefinedSugar: + return getOrCreateType(cast(Ty)->desugar(), Unit); case Type::CountAttributed: case Type::Auto: case Type::Attributed: diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 3302abad87d65..944fd79e930c6 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2485,6 +2485,7 @@ void CodeGenFunction::EmitVariablyModifiedType(QualType type) { case Type::ObjCObjectPointer: case Type::BitInt: case Type::HLSLInlineSpirv: + case Type::PredefinedSugar: llvm_unreachable("type class is never variably-modified!"); case Type::Elaborated: diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 9c322deb55e00..68f1094bcb10c 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -4646,6 +4646,9 @@ static void captureVariablyModifiedType(ASTContext &Context, QualType T, case Type::Atomic: T = cast(Ty)->getValueType(); break; + case Type::PredefinedSugar: + T = cast(Ty)->desugar(); + break; } } while (!T.isNull() && T->isVariablyModifiedType()); } diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h index c8d29f0a625f8..2612aa1ab8b75 100644 --- a/clang/lib/Sema/TreeTransform.h +++ b/clang/lib/Sema/TreeTransform.h @@ -30,6 +30,7 @@ #include "clang/AST/StmtOpenACC.h" #include "clang/AST/StmtOpenMP.h" #include "clang/AST/StmtSYCL.h" +#include "clang/AST/TypeLoc.h" #include "clang/Basic/DiagnosticParse.h" #include "clang/Basic/OpenMPKinds.h" #include "clang/Sema/Designator.h" @@ -1278,6 +1279,9 @@ class TreeTransform { QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc); + QualType RebuildPredefinedSugarType(uint32_t K, QualType Underlying, + SourceLocation Loc); + /// Build a new template name given a nested name specifier, a flag /// indicating whether the "template" keyword was provided, and the template /// that the template name refers to. @@ -7246,6 +7250,24 @@ QualType TreeTransform::TransformDependentBitIntType( return Result; } +template +QualType TreeTransform::TransformPredefinedSugarType( + TypeLocBuilder &TLB, PredefinedSugarTypeLoc TL) { + const PredefinedSugarType *EIT = TL.getTypePtr(); + QualType Result = TL.getType(); + + if (getDerived().AlwaysRebuild()) { + Result = getDerived().RebuildPredefinedSugarType( + EIT->getKind(), EIT->desugar(), TL.getNameLoc()); + if (Result.isNull()) + return QualType(); + } + + PredefinedSugarTypeLoc NewTL = TLB.push(Result); + NewTL.setNameLoc(TL.getNameLoc()); + return Result; +} + /// Simple iterator that traverses the template arguments in a /// container that provides a \c getArgLoc() member function. /// @@ -17432,6 +17454,12 @@ QualType TreeTransform::RebuildDependentBitIntType( return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc); } +template +QualType TreeTransform::RebuildPredefinedSugarType( + uint32_t K, QualType Underlying, SourceLocation Loc) { + return SemaRef.Context.getPredefinedSugarType(K, Underlying); +} + template TemplateName TreeTransform::RebuildTemplateName(CXXScopeSpec &SS, diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp index acda5a7c879dd..adbb3493e25dd 100644 --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -7453,11 +7453,16 @@ void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) { void TypeLocReader::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) { TL.setNameLoc(readSourceLocation()); } + void TypeLocReader::VisitDependentBitIntTypeLoc( clang::DependentBitIntTypeLoc TL) { TL.setNameLoc(readSourceLocation()); } +void TypeLocReader::VisitPredefinedSugarTypeLoc(PredefinedSugarTypeLoc TL) { + TL.setNameLoc(readSourceLocation()); +} + void ASTRecordReader::readTypeLoc(TypeLoc TL, LocSeq *ParentSeq) { LocSeq::State Seq(ParentSeq); TypeLocReader TLR(*this, Seq); diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index ab1b5b333e06a..1f5beaaaf8101 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -702,11 +702,17 @@ void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) { void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) { addSourceLocation(TL.getNameLoc()); } + void TypeLocWriter::VisitDependentBitIntTypeLoc( clang::DependentBitIntTypeLoc TL) { addSourceLocation(TL.getNameLoc()); } +void TypeLocWriter::VisitPredefinedSugarTypeLoc( + clang::PredefinedSugarTypeLoc TL) { + addSourceLocation(TL.getNameLoc()); +} + void ASTWriter::WriteTypeAbbrevs() { using namespace llvm; diff --git a/clang/test/AST/ast-dump-expr-json.c b/clang/test/AST/ast-dump-expr-json.c index e42b626a8eb16..ecb6191c52200 100644 --- a/clang/test/AST/ast-dump-expr-json.c +++ b/clang/test/AST/ast-dump-expr-json.c @@ -3912,8 +3912,7 @@ void PrimaryExpressions(int a) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "name": "sizeof", @@ -3967,8 +3966,7 @@ void PrimaryExpressions(int a) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "name": "sizeof", @@ -3994,8 +3992,7 @@ void PrimaryExpressions(int a) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "name": "alignof", diff --git a/clang/test/AST/ast-dump-expr-json.cpp b/clang/test/AST/ast-dump-expr-json.cpp index 51afd3f85c3c9..997f734eb303a 100644 --- a/clang/test/AST/ast-dump-expr-json.cpp +++ b/clang/test/AST/ast-dump-expr-json.cpp @@ -1546,8 +1546,7 @@ void TestNonADLCall3() { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "name": "Ts" @@ -1885,8 +1884,7 @@ void TestNonADLCall3() { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "IntegralCast", @@ -1964,8 +1962,7 @@ void TestNonADLCall3() { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "IntegralCast", diff --git a/clang/test/AST/ast-dump-stmt-json.cpp b/clang/test/AST/ast-dump-stmt-json.cpp index f34cd206fece0..661facc4f712c 100644 --- a/clang/test/AST/ast-dump-stmt-json.cpp +++ b/clang/test/AST/ast-dump-stmt-json.cpp @@ -1147,8 +1147,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "IntegralCast", @@ -1460,8 +1459,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1521,8 +1519,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1605,8 +1602,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1666,8 +1662,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1858,8 +1853,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1913,8 +1907,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -2077,8 +2070,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -2132,8 +2124,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -3900,8 +3891,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "name": "sizeof", @@ -3976,8 +3966,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "IntegralCast", @@ -4108,8 +4097,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "name": "sizeof", @@ -4184,8 +4172,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "castKind": "IntegralCast", diff --git a/clang/test/AST/ast-dump-types-errors-json.cpp b/clang/test/AST/ast-dump-types-errors-json.cpp index 78e4c7dfd2994..d9f918f6c3d72 100644 --- a/clang/test/AST/ast-dump-types-errors-json.cpp +++ b/clang/test/AST/ast-dump-types-errors-json.cpp @@ -61,8 +61,7 @@ using TestContainsErrors = int[sizeof(undef())]; // CHECK-NEXT: }, // CHECK-NEXT: "type": { // CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t", -// CHECK-NEXT: "typeAliasDeclId": "0x{{.*}}" +// CHECK-NEXT: "qualType": "__size_t" // CHECK-NEXT: }, // CHECK-NEXT: "valueCategory": "prvalue", // CHECK-NEXT: "name": "sizeof", diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 3068621d9c004..076a72b167cfe 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -32,6 +32,7 @@ #include "clang/AST/OpenMPClause.h" #include "clang/AST/OperationKinds.h" #include "clang/AST/StmtVisitor.h" +#include "clang/AST/Type.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticCategories.h" #include "clang/Basic/DiagnosticIDs.h" @@ -1683,6 +1684,10 @@ bool CursorVisitor::VisitTypedefTypeLoc(TypedefTypeLoc TL) { return Visit(MakeCursorTypeRef(TL.getTypedefNameDecl(), TL.getNameLoc(), TU)); } +bool CursorVisitor::VisitPredefinedSugarTypeLoc(PredefinedSugarTypeLoc TL) { + return false; +} + bool CursorVisitor::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) { return Visit(MakeCursorTypeRef(TL.getDecl(), TL.getNameLoc(), TU)); } From 151903284f480b4f057e352e9d698c2f61441b81 Mon Sep 17 00:00:00 2001 From: YexuanXiao Date: Sat, 14 Jun 2025 10:24:57 +0800 Subject: [PATCH 2/2] Fix tests --- clang/lib/CodeGen/CodeGenFunction.cpp | 2 +- clang/lib/Sema/SemaExprCXX.cpp | 3 +- clang/test/AST/ast-dump-expr-json.cpp | 12 ++--- clang/test/AST/ast-dump-expr.cpp | 12 ++--- clang/test/AST/ast-dump-stmt-json.cpp | 50 ++++++++----------- .../unavailable_aligned_allocation.cpp | 24 ++++----- 6 files changed, 48 insertions(+), 55 deletions(-) diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 944fd79e930c6..23fe8e33af531 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -721,7 +721,7 @@ static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) { (MD->getNumParams() != 1 && MD->getNumParams() != 2)) return false; - if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType()) + if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getCanonicalSizeType()) return false; if (MD->getNumParams() == 2) { diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index 2546ab5c0a342..fbb4efae2b676 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/lib/Sema/SemaExprCXX.cpp @@ -3404,7 +3404,8 @@ void Sema::DeclareGlobalNewDelete() { GlobalNewDeleteDeclared = true; QualType VoidPtr = Context.getPointerType(Context.VoidTy); - QualType SizeT = Context.getSizeType(); + // FIXME: Why is 'Canonical'SizeType needed here? + QualType SizeT = Context.getCanonicalSizeType(); auto DeclareGlobalAllocationFunctions = [&](OverloadedOperatorKind Kind, QualType Return, QualType Param) { diff --git a/clang/test/AST/ast-dump-expr-json.cpp b/clang/test/AST/ast-dump-expr-json.cpp index 997f734eb303a..8fda06f87e2ee 100644 --- a/clang/test/AST/ast-dump-expr-json.cpp +++ b/clang/test/AST/ast-dump-expr-json.cpp @@ -1729,7 +1729,7 @@ void TestNonADLCall3() { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: }, @@ -1758,7 +1758,7 @@ void TestNonADLCall3() { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: }, @@ -1788,7 +1788,7 @@ void TestNonADLCall3() { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ @@ -1863,7 +1863,7 @@ void TestNonADLCall3() { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new[]", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ @@ -1941,7 +1941,7 @@ void TestNonADLCall3() { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new[]", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ @@ -2338,7 +2338,7 @@ void TestNonADLCall3() { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator delete", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (void *, __size_t) noexcept" +// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ diff --git a/clang/test/AST/ast-dump-expr.cpp b/clang/test/AST/ast-dump-expr.cpp index 92adb3d7a5c38..246463caee2a3 100644 --- a/clang/test/AST/ast-dump-expr.cpp +++ b/clang/test/AST/ast-dump-expr.cpp @@ -126,23 +126,23 @@ void UnaryExpressions(int *p) { // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' ::new int; - // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' global Function 0x{{[^ ]*}} 'operator new' 'void *(__size_t)' + // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' global Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)' new (int); - // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(__size_t)' + // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)' new int{12}; - // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(__size_t)' + // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' Function 0x{{[^ ]*}} 'operator new' 'void *(unsigned long)' // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} 'int' // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 12 new int[2]; - // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(__size_t)' + // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(unsigned long)' // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 2 new int[2]{1, 2}; - // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(__size_t)' + // CHECK: CXXNewExpr 0x{{[^ ]*}} 'int *' array Function 0x{{[^ ]*}} 'operator new[]' 'void *(unsigned long)' // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: IntegerLiteral 0x{{[^ ]*}} 'int' 2 // CHECK-NEXT: InitListExpr 0x{{[^ ]*}} 'int[2]' @@ -164,7 +164,7 @@ void UnaryExpressions(int *p) { // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' ::delete p; - // CHECK: CXXDeleteExpr 0x{{[^ ]*}} 'void' global Function 0x{{[^ ]*}} 'operator delete' 'void (void *, __size_t) noexcept' + // CHECK: CXXDeleteExpr 0x{{[^ ]*}} 'void' global Function 0x{{[^ ]*}} 'operator delete' 'void (void *, unsigned long) noexcept' // CHECK-NEXT: ImplicitCastExpr // CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *' diff --git a/clang/test/AST/ast-dump-stmt-json.cpp b/clang/test/AST/ast-dump-stmt-json.cpp index 661facc4f712c..1da8be975c82f 100644 --- a/clang/test/AST/ast-dump-stmt-json.cpp +++ b/clang/test/AST/ast-dump-stmt-json.cpp @@ -963,7 +963,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -994,7 +994,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator delete", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (void *, __size_t) noexcept" +// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ @@ -1126,7 +1126,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new[]", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ @@ -1338,7 +1338,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator new", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: } // CHECK-NEXT: } // CHECK-NEXT: } @@ -1370,7 +1370,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "kind": "FunctionDecl", // CHECK-NEXT: "name": "operator delete", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (void *, __size_t) noexcept" +// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ @@ -1445,7 +1445,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator new", // CHECK-NEXT: "mangledName": "_Znwm", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -1458,8 +1458,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1505,7 +1504,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator new", // CHECK-NEXT: "mangledName": "_ZnwmSt11align_val_t", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t, std::align_val_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long, std::align_val_t)" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -1518,8 +1517,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1588,7 +1586,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator new[]", // CHECK-NEXT: "mangledName": "_Znam", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long)" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -1601,8 +1599,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1648,7 +1645,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator new[]", // CHECK-NEXT: "mangledName": "_ZnamSt11align_val_t", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void *(__size_t, std::align_val_t)" +// CHECK-NEXT: "qualType": "void *(unsigned long, std::align_val_t)" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -1661,8 +1658,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1826,7 +1822,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator delete", // CHECK-NEXT: "mangledName": "_ZdlPvm", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (void *, __size_t) noexcept" +// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -1852,8 +1848,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -1880,7 +1875,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator delete", // CHECK-NEXT: "mangledName": "_ZdlPvmSt11align_val_t", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (void *, __size_t, std::align_val_t) noexcept" +// CHECK-NEXT: "qualType": "void (void *, unsigned long, std::align_val_t) noexcept" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -1906,8 +1901,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -2043,7 +2037,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator delete[]", // CHECK-NEXT: "mangledName": "_ZdaPvm", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (void *, __size_t) noexcept" +// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -2069,8 +2063,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { @@ -2097,7 +2090,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: "name": "operator delete[]", // CHECK-NEXT: "mangledName": "_ZdaPvmSt11align_val_t", // CHECK-NEXT: "type": { -// CHECK-NEXT: "qualType": "void (void *, __size_t, std::align_val_t) noexcept" +// CHECK-NEXT: "qualType": "void (void *, unsigned long, std::align_val_t) noexcept" // CHECK-NEXT: }, // CHECK-NEXT: "inner": [ // CHECK-NEXT: { @@ -2123,8 +2116,7 @@ void TestDependentGenericSelectionExpr(Ty T) { // CHECK-NEXT: }, // CHECK-NEXT: "isImplicit": true, // CHECK-NEXT: "type": { -// CHECK-NEXT: "desugaredQualType": "unsigned long", -// CHECK-NEXT: "qualType": "__size_t" +// CHECK-NEXT: "qualType": "unsigned long" // CHECK-NEXT: } // CHECK-NEXT: }, // CHECK-NEXT: { diff --git a/clang/test/SemaCXX/unavailable_aligned_allocation.cpp b/clang/test/SemaCXX/unavailable_aligned_allocation.cpp index 56c564f170271..45fdec606ad1b 100644 --- a/clang/test/SemaCXX/unavailable_aligned_allocation.cpp +++ b/clang/test/SemaCXX/unavailable_aligned_allocation.cpp @@ -65,12 +65,12 @@ void testOveraligned() { #ifdef NO_ERRORS // expected-no-diagnostics #else -// expected-error-re@-16 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is {{only|not}} available on}} +// expected-error-re@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}} // expected-note@-17 {{if you supply your own aligned allocation functions}} // expected-error-re@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}} // expected-note@-19 {{if you supply your own aligned allocation functions}} -// expected-error-re@-20 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is {{only|not}} available on}} +// expected-error-re@-20 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}} // expected-note@-21 {{if you supply your own aligned allocation functions}} // expected-error-re@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}} // expected-note@-23 {{if you supply your own aligned allocation functions}} @@ -83,12 +83,12 @@ void testOveraligned() { // expected-error-re@-28 {{aligned deallocation function of type 'void (void *, std::align_val_t, const std::nothrow_t &) noexcept' is {{only|not}} available on}} // expected-note@-29 {{if you supply your own aligned allocation functions}} -// expected-error-re@-29 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is {{only|not}} available on}} +// expected-error-re@-29 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}} // expected-note@-30 {{if you supply your own aligned allocation functions}} // expected-error-re@-31 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}} // expected-note@-32 {{if you supply your own aligned allocation functions}} -// expected-error-re@-33 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is {{only|not}} available on}} +// expected-error-re@-33 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}} // expected-note@-34 {{if you supply your own aligned allocation functions}} // expected-error-re@-35 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}} // expected-note@-36 {{if you supply your own aligned allocation functions}} @@ -111,19 +111,19 @@ void testOveralignedCheckOS() { // expected-no-diagnostics #else #if defined(IOS) -// expected-error@-7 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is only available on iOS 11 or newer}} +// expected-error@-7 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on iOS 11 or newer}} // expected-error@-8 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on iOS 11 or newer}}} #elif defined(TVOS) -// expected-error@-10 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is only available on tvOS 11 or newer}}} +// expected-error@-10 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on tvOS 11 or newer}}} // expected-error@-11 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on tvOS 11 or newer}}} #elif defined(WATCHOS) -// expected-error@-13 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is only available on watchOS 4 or newer}}} +// expected-error@-13 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on watchOS 4 or newer}}} // expected-error@-14 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}} #elif defined(MACOS) -// expected-error@-16 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is only available on macOS 10.13 or newer}}} +// expected-error@-16 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is only available on macOS 10.13 or newer}}} // expected-error@-17 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}} #elif defined(ZOS) -// expected-error@-19 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is not available on z/OS}}} +// expected-error@-19 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is not available on z/OS}}} // expected-error@-20 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is not available on z/OS}}} #endif @@ -181,19 +181,19 @@ void testExplicitOperatorNewDeleteOveraligned() { #ifdef NO_ERRORS // expected-no-diagnostics #else -// expected-error-re@-11 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is {{only|not}} available on}} +// expected-error-re@-11 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}} // expected-note@-12 {{if you supply your own aligned allocation functions}} // expected-error-re@-13 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}} // expected-note@-14 {{if you supply your own aligned allocation functions}} -// expected-error-re@-15 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is {{only|not}} available on}} +// expected-error-re@-15 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}} // expected-note@-16 {{if you supply your own aligned allocation functions}} // expected-error-re@-17 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}} // expected-note@-18 {{if you supply your own aligned allocation functions}} -// expected-error-re@-19 {{aligned allocation function of type 'void *(__size_t, enum std::align_val_t)' is {{only|not}} available on}} +// expected-error-re@-19 {{aligned allocation function of type 'void *(unsigned long, enum std::align_val_t)' is {{only|not}} available on}} // expected-note@-20 {{if you supply your own aligned allocation functions}} // expected-error-re@-21 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}