https://github.com/apolloww updated https://github.com/llvm/llvm-project/pull/79182
>From a542d63f472d799eb2d041c82cac402cfb8dec1a Mon Sep 17 00:00:00 2001 From: Wei Wang <apollo.mobil...@gmail.com> Date: Tue, 23 Jan 2024 10:01:57 -0800 Subject: [PATCH 1/2] [clang] Make sure the same UsingType is searched and inserted --- clang/lib/AST/ASTContext.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5eb7aa3664569dd..d312ef61fb15d4a 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4672,12 +4672,6 @@ QualType ASTContext::getTypedefType(const TypedefNameDecl *Decl, QualType ASTContext::getUsingType(const UsingShadowDecl *Found, QualType Underlying) const { llvm::FoldingSetNodeID ID; - UsingType::Profile(ID, Found, Underlying); - - void *InsertPos = nullptr; - if (UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos)) - return QualType(T, 0); - const Type *TypeForDecl = cast<TypeDecl>(Found->getTargetDecl())->getTypeForDecl(); @@ -4687,6 +4681,13 @@ QualType ASTContext::getUsingType(const UsingShadowDecl *Found, if (Underlying.getTypePtr() == TypeForDecl) Underlying = QualType(); + UsingType::Profile(ID, Found, Underlying); + + void *InsertPos = nullptr; + if (UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos)) { + return QualType(T, 0); + } + void *Mem = Allocate(UsingType::totalSizeToAlloc<QualType>(!Underlying.isNull()), alignof(UsingType)); >From 6dba099a2e1f06feb65248678a57bd00a3d4d0ae Mon Sep 17 00:00:00 2001 From: Wei Wang <apollo.mobil...@gmail.com> Date: Tue, 23 Jan 2024 19:58:24 -0800 Subject: [PATCH 2/2] update UsingType profile implementation --- clang/include/clang/AST/Type.h | 5 ++--- clang/lib/AST/ASTContext.cpp | 13 ++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index ea425791fc97f05..3d411051084c71b 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -4729,13 +4729,12 @@ class UsingType final : public Type, bool typeMatchesDecl() const { return !UsingBits.hasTypeDifferentFromDecl; } void Profile(llvm::FoldingSetNodeID &ID) { - Profile(ID, Found, typeMatchesDecl() ? QualType() : getUnderlyingType()); + Profile(ID, Found, getUnderlyingType()); } static void Profile(llvm::FoldingSetNodeID &ID, const UsingShadowDecl *Found, QualType Underlying) { ID.AddPointer(Found); - if (!Underlying.isNull()) - Underlying.Profile(ID); + Underlying.Profile(ID); } static bool classof(const Type *T) { return T->getTypeClass() == Using; } }; diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index d312ef61fb15d4a..5eb7aa3664569dd 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -4672,6 +4672,12 @@ QualType ASTContext::getTypedefType(const TypedefNameDecl *Decl, QualType ASTContext::getUsingType(const UsingShadowDecl *Found, QualType Underlying) const { llvm::FoldingSetNodeID ID; + UsingType::Profile(ID, Found, Underlying); + + void *InsertPos = nullptr; + if (UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos)) + return QualType(T, 0); + const Type *TypeForDecl = cast<TypeDecl>(Found->getTargetDecl())->getTypeForDecl(); @@ -4681,13 +4687,6 @@ QualType ASTContext::getUsingType(const UsingShadowDecl *Found, if (Underlying.getTypePtr() == TypeForDecl) Underlying = QualType(); - UsingType::Profile(ID, Found, Underlying); - - void *InsertPos = nullptr; - if (UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos)) { - return QualType(T, 0); - } - void *Mem = Allocate(UsingType::totalSizeToAlloc<QualType>(!Underlying.isNull()), alignof(UsingType)); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits