https://github.com/apolloww created https://github.com/llvm/llvm-project/pull/79182
When creating a new UsingType, the underlying type may change if it is a declaration. This creates an inconsistency between the type searched and type created. Move the update before search so that we always use the same type for search and creation. >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] [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)); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits