llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Fangrui Song (MaskRay) <details> <summary>Changes</summary> --- Patch is 73.62 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/219766.diff 6 Files Affected: - (modified) clang/include/clang/AST/ASTContext.h (+1-1) - (modified) clang/lib/AST/ASTContext.cpp (+243-283) - (modified) clang/lib/AST/DeclarationName.cpp (+15-16) - (modified) clang/lib/AST/NestedNameSpecifier.cpp (+3-3) - (modified) clang/lib/Sema/SemaConcept.cpp (+4-4) - (modified) clang/lib/Sema/SemaLookup.cpp (+3-3) ``````````diff diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 97ceb4bbdbcef..18b32dbd7d65b 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -1960,7 +1960,7 @@ class ASTContext : public RefCountedBase<ASTContext> { private: UnresolvedUsingType *getUnresolvedUsingTypeInternal( ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, - const UnresolvedUsingTypenameDecl *D, void *InsertPos, + const UnresolvedUsingTypenameDecl *D, llvm::FoldingSetInsertToken Token, const Type *CanonicalType) const; TagType *getTagTypeInternal(ElaboratedTypeKeyword Keyword, diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 8b3315eca1cdc..cf49e2baa1817 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -726,9 +726,9 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( // Check if we already have a canonical template template parameter. llvm::FoldingSetNodeID ID; CanonicalTemplateTemplateParm::Profile(ID, *this, TTP); - void *InsertPos = nullptr; - CanonicalTemplateTemplateParm *Canonical - = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos); + llvm::FoldingSetInsertToken Token; + CanonicalTemplateTemplateParm *Canonical = + CanonTemplateTemplateParms.lookup(ID, Token); if (Canonical) return Canonical->getParam(); @@ -796,13 +796,13 @@ ASTContext::getCanonicalTemplateTemplateParmDecl( /*RequiresClause=*/nullptr)); // Get the new insert position for the node we care about. - Canonical = CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos); + Canonical = CanonTemplateTemplateParms.lookup(ID, Token); assert(!Canonical && "Shouldn't be in the map!"); (void)Canonical; // Create the canonical template template parameter entry. Canonical = new (*this) CanonicalTemplateTemplateParm(CanonTTP); - CanonTemplateTemplateParms.InsertNode(Canonical, InsertPos); + CanonTemplateTemplateParms.insert(Canonical, Token); return CanonTTP; } @@ -811,9 +811,9 @@ ASTContext::findCanonicalTemplateTemplateParmDeclInternal( TemplateTemplateParmDecl *TTP) const { llvm::FoldingSetNodeID ID; CanonicalTemplateTemplateParm::Profile(ID, *this, TTP); - void *InsertPos = nullptr; + llvm::FoldingSetInsertToken Token; CanonicalTemplateTemplateParm *Canonical = - CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos); + CanonTemplateTemplateParms.lookup(ID, Token); return Canonical ? Canonical->getParam() : nullptr; } @@ -822,12 +822,11 @@ ASTContext::insertCanonicalTemplateTemplateParmDeclInternal( TemplateTemplateParmDecl *CanonTTP) const { llvm::FoldingSetNodeID ID; CanonicalTemplateTemplateParm::Profile(ID, *this, CanonTTP); - void *InsertPos = nullptr; - if (auto *Existing = - CanonTemplateTemplateParms.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (auto *Existing = CanonTemplateTemplateParms.lookup(ID, Token)) return Existing->getParam(); - CanonTemplateTemplateParms.InsertNode( - new (*this) CanonicalTemplateTemplateParm(CanonTTP), InsertPos); + CanonTemplateTemplateParms.insert( + new (*this) CanonicalTemplateTemplateParm(CanonTTP), Token); return CanonTTP; } @@ -3291,8 +3290,8 @@ ASTContext::getExtQualType(const Type *baseType, Qualifiers quals) const { // Check if we've already instantiated this type. llvm::FoldingSetNodeID ID; ExtQuals::Profile(ID, baseType, quals); - void *insertPos = nullptr; - if (ExtQuals *eq = ExtQualNodes.FindNodeOrInsertPos(ID, insertPos)) { + llvm::FoldingSetInsertToken Token; + if (ExtQuals *eq = ExtQualNodes.lookup(ID, Token)) { assert(eq->getQualifiers() == quals); return QualType(eq, fastQuals); } @@ -3305,11 +3304,11 @@ ASTContext::getExtQualType(const Type *baseType, Qualifiers quals) const { canon = getExtQualType(canonSplit.Ty, canonSplit.Quals); // Re-find the insert position. - (void) ExtQualNodes.FindNodeOrInsertPos(ID, insertPos); + (void)ExtQualNodes.lookup(ID, Token); } auto *eq = new (*this, alignof(ExtQuals)) ExtQuals(baseType, canon, quals); - ExtQualNodes.InsertNode(eq, insertPos); + ExtQualNodes.insert(eq, Token); return QualType(eq, fastQuals); } @@ -3763,9 +3762,8 @@ QualType ASTContext::getCountAttributedType( llvm::FoldingSetNodeID ID; CountAttributedType::Profile(ID, WrappedTy, CountExpr, CountInBytes, OrNull); - void *InsertPos = nullptr; - CountAttributedType *CATy = - CountAttributedTypes.FindNodeOrInsertPos(ID, InsertPos); + llvm::FoldingSetInsertToken Token; + CountAttributedType *CATy = CountAttributedTypes.lookup(ID, Token); if (CATy) return QualType(CATy, 0); @@ -3776,7 +3774,7 @@ QualType ASTContext::getCountAttributedType( new (CATy) CountAttributedType(WrappedTy, CanonTy, CountExpr, CountInBytes, OrNull, DependentDecls); Types.push_back(CATy); - CountAttributedTypes.InsertNode(CATy, InsertPos); + CountAttributedTypes.insert(CATy, Token); return QualType(CATy, 0); } @@ -3976,8 +3974,8 @@ QualType ASTContext::getComplexType(QualType T) const { llvm::FoldingSetNodeID ID; ComplexType::Profile(ID, T); - void *InsertPos = nullptr; - if (ComplexType *CT = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (ComplexType *CT = ComplexTypes.lookup(ID, Token)) return QualType(CT, 0); // If the pointee type isn't canonical, this won't be a canonical type either, @@ -3987,12 +3985,12 @@ QualType ASTContext::getComplexType(QualType T) const { Canonical = getComplexType(getCanonicalType(T)); // Get the new insert position for the node we care about. - ComplexType *NewIP = ComplexTypes.FindNodeOrInsertPos(ID, InsertPos); + ComplexType *NewIP = ComplexTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } auto *New = new (*this, alignof(ComplexType)) ComplexType(T, Canonical); Types.push_back(New); - ComplexTypes.InsertNode(New, InsertPos); + ComplexTypes.insert(New, Token); return QualType(New, 0); } @@ -4004,8 +4002,8 @@ QualType ASTContext::getPointerType(QualType T) const { llvm::FoldingSetNodeID ID; PointerType::Profile(ID, T); - void *InsertPos = nullptr; - if (PointerType *PT = PointerTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (PointerType *PT = PointerTypes.lookup(ID, Token)) return QualType(PT, 0); // If the pointee type isn't canonical, this won't be a canonical type either, @@ -4015,53 +4013,53 @@ QualType ASTContext::getPointerType(QualType T) const { Canonical = getPointerType(getCanonicalType(T)); // Get the new insert position for the node we care about. - PointerType *NewIP = PointerTypes.FindNodeOrInsertPos(ID, InsertPos); + PointerType *NewIP = PointerTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } auto *New = new (*this, alignof(PointerType)) PointerType(T, Canonical); Types.push_back(New); - PointerTypes.InsertNode(New, InsertPos); + PointerTypes.insert(New, Token); return QualType(New, 0); } QualType ASTContext::getAdjustedType(QualType Orig, QualType New) const { llvm::FoldingSetNodeID ID; AdjustedType::Profile(ID, Orig, New); - void *InsertPos = nullptr; - AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); + llvm::FoldingSetInsertToken Token; + AdjustedType *AT = AdjustedTypes.lookup(ID, Token); if (AT) return QualType(AT, 0); QualType Canonical = getCanonicalType(New); // Get the new insert position for the node we care about. - AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); + AT = AdjustedTypes.lookup(ID, Token); assert(!AT && "Shouldn't be in the map!"); AT = new (*this, alignof(AdjustedType)) AdjustedType(Type::Adjusted, Orig, New, Canonical); Types.push_back(AT); - AdjustedTypes.InsertNode(AT, InsertPos); + AdjustedTypes.insert(AT, Token); return QualType(AT, 0); } QualType ASTContext::getDecayedType(QualType Orig, QualType Decayed) const { llvm::FoldingSetNodeID ID; AdjustedType::Profile(ID, Orig, Decayed); - void *InsertPos = nullptr; - AdjustedType *AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); + llvm::FoldingSetInsertToken Token; + AdjustedType *AT = AdjustedTypes.lookup(ID, Token); if (AT) return QualType(AT, 0); QualType Canonical = getCanonicalType(Decayed); // Get the new insert position for the node we care about. - AT = AdjustedTypes.FindNodeOrInsertPos(ID, InsertPos); + AT = AdjustedTypes.lookup(ID, Token); assert(!AT && "Shouldn't be in the map!"); AT = new (*this, alignof(DecayedType)) DecayedType(Orig, Decayed, Canonical); Types.push_back(AT); - AdjustedTypes.InsertNode(AT, InsertPos); + AdjustedTypes.insert(AT, Token); return QualType(AT, 0); } @@ -4098,9 +4096,8 @@ QualType ASTContext::getArrayParameterType(QualType Ty) const { ATy->Profile(ID, *this, ATy->getElementType(), ATy->getZExtSize(), ATy->getSizeExpr(), ATy->getSizeModifier(), ATy->getIndexTypeQualifiers().getAsOpaqueValue()); - void *InsertPos = nullptr; - ArrayParameterType *AT = - ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos); + llvm::FoldingSetInsertToken Token; + ArrayParameterType *AT = ArrayParameterTypes.lookup(ID, Token); if (AT) return QualType(AT, 0); @@ -4109,14 +4106,14 @@ QualType ASTContext::getArrayParameterType(QualType Ty) const { Canonical = getArrayParameterType(getCanonicalType(Ty)); // Get the new insert position for the node we care about. - AT = ArrayParameterTypes.FindNodeOrInsertPos(ID, InsertPos); + AT = ArrayParameterTypes.lookup(ID, Token); assert(!AT && "Shouldn't be in the map!"); } AT = new (*this, alignof(ArrayParameterType)) ArrayParameterType(ATy, Canonical); Types.push_back(AT); - ArrayParameterTypes.InsertNode(AT, InsertPos); + ArrayParameterTypes.insert(AT, Token); return QualType(AT, 0); } @@ -4129,9 +4126,8 @@ QualType ASTContext::getBlockPointerType(QualType T) const { llvm::FoldingSetNodeID ID; BlockPointerType::Profile(ID, T); - void *InsertPos = nullptr; - if (BlockPointerType *PT = - BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (BlockPointerType *PT = BlockPointerTypes.lookup(ID, Token)) return QualType(PT, 0); // If the block pointee type isn't canonical, this won't be a canonical @@ -4141,14 +4137,13 @@ QualType ASTContext::getBlockPointerType(QualType T) const { Canonical = getBlockPointerType(getCanonicalType(T)); // Get the new insert position for the node we care about. - BlockPointerType *NewIP = - BlockPointerTypes.FindNodeOrInsertPos(ID, InsertPos); + BlockPointerType *NewIP = BlockPointerTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } auto *New = new (*this, alignof(BlockPointerType)) BlockPointerType(T, Canonical); Types.push_back(New); - BlockPointerTypes.InsertNode(New, InsertPos); + BlockPointerTypes.insert(New, Token); return QualType(New, 0); } @@ -4165,9 +4160,8 @@ ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const { llvm::FoldingSetNodeID ID; ReferenceType::Profile(ID, T, SpelledAsLValue); - void *InsertPos = nullptr; - if (LValueReferenceType *RT = - LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (LValueReferenceType *RT = LValueReferenceTypes.lookup(ID, Token)) return QualType(RT, 0); const auto *InnerRef = T->getAs<ReferenceType>(); @@ -4180,15 +4174,14 @@ ASTContext::getLValueReferenceType(QualType T, bool SpelledAsLValue) const { Canonical = getLValueReferenceType(getCanonicalType(PointeeType)); // Get the new insert position for the node we care about. - LValueReferenceType *NewIP = - LValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos); + LValueReferenceType *NewIP = LValueReferenceTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } auto *New = new (*this, alignof(LValueReferenceType)) LValueReferenceType(T, Canonical, SpelledAsLValue); Types.push_back(New); - LValueReferenceTypes.InsertNode(New, InsertPos); + LValueReferenceTypes.insert(New, Token); return QualType(New, 0); } @@ -4205,9 +4198,8 @@ QualType ASTContext::getRValueReferenceType(QualType T) const { llvm::FoldingSetNodeID ID; ReferenceType::Profile(ID, T, false); - void *InsertPos = nullptr; - if (RValueReferenceType *RT = - RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (RValueReferenceType *RT = RValueReferenceTypes.lookup(ID, Token)) return QualType(RT, 0); const auto *InnerRef = T->getAs<ReferenceType>(); @@ -4220,15 +4212,14 @@ QualType ASTContext::getRValueReferenceType(QualType T) const { Canonical = getRValueReferenceType(getCanonicalType(PointeeType)); // Get the new insert position for the node we care about. - RValueReferenceType *NewIP = - RValueReferenceTypes.FindNodeOrInsertPos(ID, InsertPos); + RValueReferenceType *NewIP = RValueReferenceTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } auto *New = new (*this, alignof(RValueReferenceType)) RValueReferenceType(T, Canonical); Types.push_back(New); - RValueReferenceTypes.InsertNode(New, InsertPos); + RValueReferenceTypes.insert(New, Token); return QualType(New, 0); } @@ -4246,9 +4237,8 @@ QualType ASTContext::getMemberPointerType(QualType T, llvm::FoldingSetNodeID ID; MemberPointerType::Profile(ID, T, Qualifier, Cls); - void *InsertPos = nullptr; - if (MemberPointerType *PT = - MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (MemberPointerType *PT = MemberPointerTypes.lookup(ID, Token)) return QualType(PT, 0); NestedNameSpecifier CanonicalQualifier = [&] { @@ -4267,13 +4257,13 @@ QualType ASTContext::getMemberPointerType(QualType T, assert(!cast<MemberPointerType>(Canonical)->isSugared()); // Get the new insert position for the node we care about. [[maybe_unused]] MemberPointerType *NewIP = - MemberPointerTypes.FindNodeOrInsertPos(ID, InsertPos); + MemberPointerTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); } auto *New = new (*this, alignof(MemberPointerType)) MemberPointerType(T, Qualifier, Canonical); Types.push_back(New); - MemberPointerTypes.InsertNode(New, InsertPos); + MemberPointerTypes.insert(New, Token); return QualType(New, 0); } @@ -4301,9 +4291,8 @@ QualType ASTContext::getConstantArrayType(QualType EltTy, ConstantArrayType::Profile(ID, *this, EltTy, ArySize.getZExtValue(), SizeExpr, ASM, IndexTypeQuals); - void *InsertPos = nullptr; - if (ConstantArrayType *ATP = - ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (ConstantArrayType *ATP = ConstantArrayTypes.lookup(ID, Token)) return QualType(ATP, 0); // If the element type isn't canonical or has qualifiers, or the array bound @@ -4318,14 +4307,13 @@ QualType ASTContext::getConstantArrayType(QualType EltTy, Canon = getQualifiedType(Canon, canonSplit.Quals); // Get the new insert position for the node we care about. - ConstantArrayType *NewIP = - ConstantArrayTypes.FindNodeOrInsertPos(ID, InsertPos); + ConstantArrayType *NewIP = ConstantArrayTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } auto *New = ConstantArrayType::Create(*this, EltTy, Canon, ArySize, SizeExpr, ASM, IndexTypeQuals); - ConstantArrayTypes.InsertNode(New, InsertPos); + ConstantArrayTypes.insert(New, Token); Types.push_back(New); return QualType(New, 0); } @@ -4508,15 +4496,14 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements, SplitQualType canonElementType = getCanonicalType(elementType).split(); - void *insertPos = nullptr; + llvm::FoldingSetInsertToken Token; llvm::FoldingSetNodeID ID; DependentSizedArrayType::Profile( ID, *this, numElements ? QualType(canonElementType.Ty, 0) : elementType, ASM, elementTypeQuals, numElements); // Look for an existing type with these properties. - DependentSizedArrayType *canonTy = - DependentSizedArrayTypes.FindNodeOrInsertPos(ID, insertPos); + DependentSizedArrayType *canonTy = DependentSizedArrayTypes.lookup(ID, Token); // Dependently-sized array types that do not have a specified number // of elements will have their sizes deduced from a dependent @@ -4528,7 +4515,7 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements, auto *newType = new (*this, alignof(DependentSizedArrayType)) DependentSizedArrayType(elementType, QualType(), numElements, ASM, elementTypeQuals); - DependentSizedArrayTypes.InsertNode(newType, insertPos); + DependentSizedArrayTypes.insert(newType, Token); Types.push_back(newType); return QualType(newType, 0); } @@ -4538,7 +4525,7 @@ ASTContext::getDependentSizedArrayType(QualType elementType, Expr *numElements, canonTy = new (*this, alignof(DependentSizedArrayType)) DependentSizedArrayType(QualType(canonElementType.Ty, 0), QualType(), numElements, ASM, elementTypeQuals); - DependentSizedArrayTypes.InsertNode(canonTy, insertPos); + DependentSizedArrayTypes.insert(canonTy, Token); Types.push_back(canonTy); } @@ -4567,9 +4554,8 @@ QualType ASTContext::getIncompleteArrayType(QualType elementType, llvm::FoldingSetNodeID ID; IncompleteArrayType::Profile(ID, elementType, ASM, elementTypeQuals); - void *insertPos = nullptr; - if (IncompleteArrayType *iat = - IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos)) + llvm::FoldingSetInsertToken Token; + if (IncompleteArrayType *iat = IncompleteArrayTypes.lookup(ID, Token)) return QualType(iat, 0); // If the element type isn't canonical, this won't be a canonical type @@ -4585,15 +4571,14 @@ QualType ASTContext::getIncompleteArrayType(QualType elementType, canon = getQualifiedType(canon, canonSplit.Quals); // Get the new insert position for the node we care about. - IncompleteArrayType *existing = - IncompleteArrayTypes.FindNodeOrInsertPos(ID, insertPos); + IncompleteArrayType *existing = IncompleteArrayTypes.lookup(ID, Token); assert(!existing && "Shouldn't be in the map!"); (void) existing; } auto *newType = new (*this, alignof(IncompleteArrayType)) IncompleteArrayType(elementType, canon, ASM, elementTypeQuals); - IncompleteArrayTypes.InsertNode(newType, insertPos); + IncompleteArrayTypes.insert(newType, Token); Types.push_back(newType); return QualType(newType, 0); } @@ -4741,8 +4726,8 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts, llvm::FoldingSetNodeID ID; VectorType::Profile(ID, vecType, NumElts, Type::Vector, VecKind); - void *InsertPos = nullptr; - if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos)) + llvm::FoldingSetInsertToken Token; + if (VectorType *VTP = VectorTypes.lookup(ID, Token)) return QualType(VTP, 0); // If the element type isn't canonical, this won't be a canonical type either, @@ -4752,12 +4737,12 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts, Canonical = getVectorType(getCanonicalType(vecType), NumElts, VecKind); // Get the new insert position for the node we care about. - VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos); + VectorType *NewIP = VectorTypes.lookup(ID, Token); assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP; } auto *New = new (*this, alignof(VectorType)) VectorType(vecType, NumElts, Canonical, VecKind); - VectorT... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/219766 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
