[clang] [clang] Migrate AST/Sema FoldingSet users to typed lookup/insert. NFC (PR #219766)
Fangrui Song via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 30 12:01:56 PDT 2026
https://github.com/MaskRay updated https://github.com/llvm/llvm-project/pull/219766
>From 8297948c19b8dea287fb4fef08552b1baa9338ad Mon Sep 17 00:00:00 2001
From: Fangrui Song <i at maskray.me>
Date: Sat, 29 Aug 2026 01:02:35 -0700
Subject: [PATCH] [clang] Migrate AST/Sema FoldingSet users to typed
lookup/insert. NFC
---
clang/include/clang/AST/ASTContext.h | 2 +-
clang/lib/AST/ASTContext.cpp | 526 ++++++++++++--------------
clang/lib/AST/DeclarationName.cpp | 31 +-
clang/lib/AST/NestedNameSpecifier.cpp | 6 +-
clang/lib/Sema/SemaConcept.cpp | 8 +-
clang/lib/Sema/SemaLookup.cpp | 6 +-
6 files changed, 269 insertions(+), 310 deletions(-)
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);
- VectorTypes.InsertNode(New, InsertPos);
+ VectorTypes.insert(New, Token);
Types.push_back(New);
return QualType(New, 0);
}
@@ -4768,9 +4753,8 @@ QualType ASTContext::getDependentVectorType(QualType VecType, Expr *SizeExpr,
llvm::FoldingSetNodeID ID;
DependentVectorType::Profile(ID, *this, getCanonicalType(VecType), SizeExpr,
VecKind);
- void *InsertPos = nullptr;
- DependentVectorType *Canon =
- DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ DependentVectorType *Canon = DependentVectorTypes.lookup(ID, Token);
DependentVectorType *New;
if (Canon) {
@@ -4782,12 +4766,11 @@ QualType ASTContext::getDependentVectorType(QualType VecType, Expr *SizeExpr,
New = new (*this, alignof(DependentVectorType))
DependentVectorType(VecType, QualType(), SizeExpr, AttrLoc, VecKind);
- DependentVectorType *CanonCheck =
- DependentVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
+ DependentVectorType *CanonCheck = DependentVectorTypes.lookup(ID, Token);
assert(!CanonCheck &&
"Dependent-sized vector_size canonical type broken");
(void)CanonCheck;
- DependentVectorTypes.InsertNode(New, InsertPos);
+ DependentVectorTypes.insert(New, Token);
} else {
QualType CanonTy = getDependentVectorType(CanonVecTy, SizeExpr,
SourceLocation(), VecKind);
@@ -4813,8 +4796,8 @@ QualType ASTContext::getExtVectorType(QualType vecType,
llvm::FoldingSetNodeID ID;
VectorType::Profile(ID, vecType, NumElts, Type::ExtVector,
VectorKind::Generic);
- 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,
@@ -4824,12 +4807,12 @@ QualType ASTContext::getExtVectorType(QualType vecType,
Canonical = getExtVectorType(getCanonicalType(vecType), NumElts);
// 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(ExtVectorType))
ExtVectorType(vecType, NumElts, Canonical);
- VectorTypes.InsertNode(New, InsertPos);
+ VectorTypes.insert(New, Token);
Types.push_back(New);
return QualType(New, 0);
}
@@ -4842,9 +4825,9 @@ ASTContext::getDependentSizedExtVectorType(QualType vecType,
DependentSizedExtVectorType::Profile(ID, *this, getCanonicalType(vecType),
SizeExpr);
- void *InsertPos = nullptr;
- DependentSizedExtVectorType *Canon
- = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ DependentSizedExtVectorType *Canon =
+ DependentSizedExtVectorTypes.lookup(ID, Token);
DependentSizedExtVectorType *New;
if (Canon) {
// We already have a canonical version of this array type; use it as
@@ -4858,11 +4841,11 @@ ASTContext::getDependentSizedExtVectorType(QualType vecType,
New = new (*this, alignof(DependentSizedExtVectorType))
DependentSizedExtVectorType(vecType, QualType(), SizeExpr, AttrLoc);
- DependentSizedExtVectorType *CanonCheck
- = DependentSizedExtVectorTypes.FindNodeOrInsertPos(ID, InsertPos);
+ DependentSizedExtVectorType *CanonCheck =
+ DependentSizedExtVectorTypes.lookup(ID, Token);
assert(!CanonCheck && "Dependent-sized ext_vector canonical type broken");
(void)CanonCheck;
- DependentSizedExtVectorTypes.InsertNode(New, InsertPos);
+ DependentSizedExtVectorTypes.insert(New, Token);
} else {
QualType CanonExtTy = getDependentSizedExtVectorType(CanonVecTy, SizeExpr,
SourceLocation());
@@ -4886,8 +4869,8 @@ QualType ASTContext::getConstantMatrixType(QualType ElementTy, unsigned NumRows,
assert(NumRows > 0 && NumRows <= LangOpts.MaxMatrixDimension &&
NumColumns > 0 && NumColumns <= LangOpts.MaxMatrixDimension &&
"need valid matrix dimensions");
- void *InsertPos = nullptr;
- if (ConstantMatrixType *MTP = MatrixTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (ConstantMatrixType *MTP = MatrixTypes.lookup(ID, Token))
return QualType(MTP, 0);
QualType Canonical;
@@ -4895,14 +4878,14 @@ QualType ASTContext::getConstantMatrixType(QualType ElementTy, unsigned NumRows,
Canonical =
getConstantMatrixType(getCanonicalType(ElementTy), NumRows, NumColumns);
- ConstantMatrixType *NewIP = MatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
+ ConstantMatrixType *NewIP = MatrixTypes.lookup(ID, Token);
assert(!NewIP && "Matrix type shouldn't already exist in the map");
(void)NewIP;
}
auto *New = new (*this, alignof(ConstantMatrixType))
ConstantMatrixType(ElementTy, NumRows, NumColumns, Canonical);
- MatrixTypes.InsertNode(New, InsertPos);
+ MatrixTypes.insert(New, Token);
Types.push_back(New);
return QualType(New, 0);
}
@@ -4916,9 +4899,8 @@ QualType ASTContext::getDependentSizedMatrixType(QualType ElementTy,
DependentSizedMatrixType::Profile(ID, *this, CanonElementTy, RowExpr,
ColumnExpr);
- void *InsertPos = nullptr;
- DependentSizedMatrixType *Canon =
- DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ DependentSizedMatrixType *Canon = DependentSizedMatrixTypes.lookup(ID, Token);
if (!Canon) {
Canon = new (*this, alignof(DependentSizedMatrixType))
@@ -4926,10 +4908,10 @@ QualType ASTContext::getDependentSizedMatrixType(QualType ElementTy,
ColumnExpr, AttrLoc);
#ifndef NDEBUG
DependentSizedMatrixType *CanonCheck =
- DependentSizedMatrixTypes.FindNodeOrInsertPos(ID, InsertPos);
+ DependentSizedMatrixTypes.lookup(ID, Token);
assert(!CanonCheck && "Dependent-sized matrix canonical type broken");
#endif
- DependentSizedMatrixTypes.InsertNode(Canon, InsertPos);
+ DependentSizedMatrixTypes.insert(Canon, Token);
Types.push_back(Canon);
}
@@ -4955,19 +4937,19 @@ QualType ASTContext::getDependentAddressSpaceType(QualType PointeeType,
QualType canonPointeeType = getCanonicalType(PointeeType);
- void *insertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
llvm::FoldingSetNodeID ID;
DependentAddressSpaceType::Profile(ID, *this, canonPointeeType,
AddrSpaceExpr);
DependentAddressSpaceType *canonTy =
- DependentAddressSpaceTypes.FindNodeOrInsertPos(ID, insertPos);
+ DependentAddressSpaceTypes.lookup(ID, Token);
if (!canonTy) {
canonTy = new (*this, alignof(DependentAddressSpaceType))
DependentAddressSpaceType(canonPointeeType, QualType(), AddrSpaceExpr,
AttrLoc);
- DependentAddressSpaceTypes.InsertNode(canonTy, insertPos);
+ DependentAddressSpaceTypes.insert(canonTy, Token);
Types.push_back(canonTy);
}
@@ -5005,9 +4987,8 @@ ASTContext::getFunctionNoProtoType(QualType ResultTy,
llvm::FoldingSetNodeID ID;
FunctionNoProtoType::Profile(ID, ResultTy, Info);
- void *InsertPos = nullptr;
- if (FunctionNoProtoType *FT =
- FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (FunctionNoProtoType *FT = FunctionNoProtoTypes.lookup(ID, Token))
return QualType(FT, 0);
QualType Canonical;
@@ -5016,15 +4997,14 @@ ASTContext::getFunctionNoProtoType(QualType ResultTy,
getFunctionNoProtoType(getCanonicalFunctionResultType(ResultTy), Info);
// Get the new insert position for the node we care about.
- FunctionNoProtoType *NewIP =
- FunctionNoProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
+ FunctionNoProtoType *NewIP = FunctionNoProtoTypes.lookup(ID, Token);
assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
}
auto *New = new (*this, alignof(FunctionNoProtoType))
FunctionNoProtoType(ResultTy, Canonical, Info);
Types.push_back(New);
- FunctionNoProtoTypes.InsertNode(New, InsertPos);
+ FunctionNoProtoTypes.insert(New, Token);
return QualType(New, 0);
}
@@ -5091,9 +5071,8 @@ QualType ASTContext::getFunctionTypeInternal(
QualType Canonical;
bool Unique = false;
- void *InsertPos = nullptr;
- if (FunctionProtoType *FPT =
- FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos)) {
+ llvm::FoldingSetInsertToken Token;
+ if (FunctionProtoType *FPT = FunctionProtoTypes.lookup(ID, Token)) {
QualType Existing = QualType(FPT, 0);
// If we find a pre-existing equivalent FunctionProtoType, we can just reuse
@@ -5190,8 +5169,7 @@ QualType ASTContext::getFunctionTypeInternal(
getFunctionTypeInternal(CanResultTy, CanonicalArgs, CanonicalEPI, true);
// Get the new insert position for the node we care about.
- FunctionProtoType *NewIP =
- FunctionProtoTypes.FindNodeOrInsertPos(ID, InsertPos);
+ FunctionProtoType *NewIP = FunctionProtoTypes.lookup(ID, Token);
assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
}
@@ -5218,7 +5196,7 @@ QualType ASTContext::getFunctionTypeInternal(
new (FTP) FunctionProtoType(ResultTy, ArgArray, Canonical, newEPI);
Types.push_back(FTP);
if (!Unique)
- FunctionProtoTypes.InsertNode(FTP, InsertPos);
+ FunctionProtoTypes.insert(FTP, Token);
if (!EPI.FunctionEffects.empty())
AnyFunctionEffects = true;
return QualType(FTP, 0);
@@ -5228,8 +5206,8 @@ QualType ASTContext::getPipeType(QualType T, bool ReadOnly) const {
llvm::FoldingSetNodeID ID;
PipeType::Profile(ID, T, ReadOnly);
- void *InsertPos = nullptr;
- if (PipeType *PT = PipeTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (PipeType *PT = PipeTypes.lookup(ID, Token))
return QualType(PT, 0);
// If the pipe element type isn't canonical, this won't be a canonical type
@@ -5239,13 +5217,13 @@ QualType ASTContext::getPipeType(QualType T, bool ReadOnly) const {
Canonical = getPipeType(getCanonicalType(T), ReadOnly);
// Get the new insert position for the node we care about.
- PipeType *NewIP = PipeTypes.FindNodeOrInsertPos(ID, InsertPos);
+ PipeType *NewIP = PipeTypes.lookup(ID, Token);
assert(!NewIP && "Shouldn't be in the map!");
(void)NewIP;
}
auto *New = new (*this, alignof(PipeType)) PipeType(T, Canonical, ReadOnly);
Types.push_back(New);
- PipeTypes.InsertNode(New, InsertPos);
+ PipeTypes.insert(New, Token);
return QualType(New, 0);
}
@@ -5267,12 +5245,12 @@ QualType ASTContext::getBitIntType(bool IsUnsigned, unsigned NumBits) const {
llvm::FoldingSetNodeID ID;
BitIntType::Profile(ID, IsUnsigned, NumBits);
- void *InsertPos = nullptr;
- if (BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (BitIntType *EIT = BitIntTypes.lookup(ID, Token))
return QualType(EIT, 0);
auto *New = new (*this, alignof(BitIntType)) BitIntType(IsUnsigned, NumBits);
- BitIntTypes.InsertNode(New, InsertPos);
+ BitIntTypes.insert(New, Token);
Types.push_back(New);
return QualType(New, 0);
}
@@ -5283,14 +5261,13 @@ QualType ASTContext::getDependentBitIntType(bool IsUnsigned,
llvm::FoldingSetNodeID ID;
DependentBitIntType::Profile(ID, *this, IsUnsigned, NumBitsExpr);
- void *InsertPos = nullptr;
- if (DependentBitIntType *Existing =
- DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (DependentBitIntType *Existing = DependentBitIntTypes.lookup(ID, Token))
return QualType(Existing, 0);
auto *New = new (*this, alignof(DependentBitIntType))
DependentBitIntType(IsUnsigned, NumBitsExpr);
- DependentBitIntTypes.InsertNode(New, InsertPos);
+ DependentBitIntTypes.insert(New, Token);
Types.push_back(New);
return QualType(New, 0);
@@ -5408,9 +5385,9 @@ ASTContext::getTypedefType(ElaboratedTypeKeyword Keyword,
TypedefType::Profile(ID, Keyword, Qualifier, Decl,
*TypeMatchesDeclOrNone ? QualType() : UnderlyingType);
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
if (FoldingSetPlaceholder<TypedefType> *Placeholder =
- TypedefTypes.FindNodeOrInsertPos(ID, InsertPos))
+ TypedefTypes.lookup(ID, Token))
return QualType(Placeholder->getType(), 0);
void *Mem =
@@ -5423,7 +5400,7 @@ ASTContext::getTypedefType(ElaboratedTypeKeyword Keyword,
UnderlyingType, !*TypeMatchesDeclOrNone);
auto *Placeholder = new (NewType->getFoldingSetPlaceholder())
FoldingSetPlaceholder<TypedefType>();
- TypedefTypes.InsertNode(Placeholder, InsertPos);
+ TypedefTypes.insert(Placeholder, Token);
Types.push_back(NewType);
return QualType(NewType, 0);
}
@@ -5444,8 +5421,8 @@ QualType ASTContext::getUsingType(ElaboratedTypeKeyword Keyword,
llvm::FoldingSetNodeID ID;
UsingType::Profile(ID, Keyword, Qualifier, D, UnderlyingType);
- void *InsertPos = nullptr;
- if (const UsingType *T = UsingTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (const UsingType *T = UsingTypes.lookup(ID, Token))
return QualType(T, 0);
assert(!UnderlyingType.hasLocalQualifiers());
@@ -5459,7 +5436,7 @@ QualType ASTContext::getUsingType(ElaboratedTypeKeyword Keyword,
alignof(UsingType));
UsingType *T = new (Mem) UsingType(Keyword, Qualifier, D, UnderlyingType);
Types.push_back(T);
- UsingTypes.InsertNode(T, InsertPos);
+ UsingTypes.insert(T, Token);
return QualType(T, 0);
}
@@ -5608,16 +5585,15 @@ QualType ASTContext::getTagType(ElaboratedTypeKeyword Keyword,
TagTypeFoldingSetPlaceholder::Profile(ID, Keyword, Qualifier, NonInjectedTD,
OwnsTag, IsInjected);
- void *InsertPos = nullptr;
- if (TagTypeFoldingSetPlaceholder *T =
- TagTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (TagTypeFoldingSetPlaceholder *T = TagTypes.lookup(ID, Token))
return QualType(T->getTagType(), 0);
const Type *CanonicalType = getCanonicalTagType(NonInjectedTD).getTypePtr();
TagType *T =
getTagTypeInternal(Keyword, Qualifier, NonInjectedTD, OwnsTag, IsInjected,
CanonicalType, /*WithFoldingSetNode=*/true);
- TagTypes.InsertNode(TagTypeFoldingSetPlaceholder::fromTagType(T), InsertPos);
+ TagTypes.insert(TagTypeFoldingSetPlaceholder::fromTagType(T), Token);
return QualType(T, 0);
}
@@ -5715,18 +5691,18 @@ bool ASTContext::isRepresentableIntegerValue(llvm::APSInt &Value, QualType T) {
UnresolvedUsingType *ASTContext::getUnresolvedUsingTypeInternal(
ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier,
- const UnresolvedUsingTypenameDecl *D, void *InsertPos,
+ const UnresolvedUsingTypenameDecl *D, llvm::FoldingSetInsertToken Token,
const Type *CanonicalType) const {
void *Mem = Allocate(
UnresolvedUsingType::totalSizeToAlloc<
FoldingSetPlaceholder<UnresolvedUsingType>, NestedNameSpecifier>(
- !!InsertPos, !!Qualifier),
+ !!Token, !!Qualifier),
alignof(UnresolvedUsingType));
auto *T = new (Mem) UnresolvedUsingType(Keyword, Qualifier, D, CanonicalType);
- if (InsertPos) {
+ if (Token) {
auto *Placeholder = new (T->getFoldingSetPlaceholder())
FoldingSetPlaceholder<TypedefType>();
- TypedefTypes.InsertNode(Placeholder, InsertPos);
+ TypedefTypes.insert(Placeholder, Token);
}
Types.push_back(T);
return T;
@@ -5738,10 +5714,10 @@ CanQualType ASTContext::getCanonicalUnresolvedUsingType(
if (D->TypeForDecl)
return D->TypeForDecl->getCanonicalTypeUnqualified();
- const Type *CanonicalType = getUnresolvedUsingTypeInternal(
- ElaboratedTypeKeyword::None,
- /*Qualifier=*/std::nullopt, D,
- /*InsertPos=*/nullptr, /*CanonicalType=*/nullptr);
+ const Type *CanonicalType =
+ getUnresolvedUsingTypeInternal(ElaboratedTypeKeyword::None,
+ /*Qualifier=*/std::nullopt, D,
+ /*Token=*/{}, /*CanonicalType=*/nullptr);
D->TypeForDecl = CanonicalType;
return CanQualType::CreateUnsafe(QualType(CanonicalType, 0));
}
@@ -5758,7 +5734,7 @@ ASTContext::getUnresolvedUsingType(ElaboratedTypeKeyword Keyword,
const Type *T =
getUnresolvedUsingTypeInternal(ElaboratedTypeKeyword::None,
/*Qualifier=*/std::nullopt, D,
- /*InsertPos=*/nullptr, CanonicalType);
+ /*Token=*/{}, CanonicalType);
D->TypeForDecl = T;
return QualType(T, 0);
}
@@ -5766,15 +5742,15 @@ ASTContext::getUnresolvedUsingType(ElaboratedTypeKeyword Keyword,
llvm::FoldingSetNodeID ID;
UnresolvedUsingType::Profile(ID, Keyword, Qualifier, D);
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
if (FoldingSetPlaceholder<UnresolvedUsingType> *Placeholder =
- UnresolvedUsingTypes.FindNodeOrInsertPos(ID, InsertPos))
+ UnresolvedUsingTypes.lookup(ID, Token))
return QualType(Placeholder->getType(), 0);
- assert(InsertPos);
+ assert(Token);
const Type *CanonicalType = getCanonicalUnresolvedUsingType(D).getTypePtr();
- const Type *T = getUnresolvedUsingTypeInternal(Keyword, Qualifier, D,
- InsertPos, CanonicalType);
+ const Type *T = getUnresolvedUsingTypeInternal(Keyword, Qualifier, D, Token,
+ CanonicalType);
return QualType(T, 0);
}
@@ -5786,8 +5762,8 @@ QualType ASTContext::getAttributedType(attr::Kind attrKind,
AttributedType::Profile(id, *this, attrKind, modifiedType, equivalentType,
attr);
- void *insertPos = nullptr;
- AttributedType *type = AttributedTypes.FindNodeOrInsertPos(id, insertPos);
+ llvm::FoldingSetInsertToken Token;
+ AttributedType *type = AttributedTypes.lookup(id, Token);
if (type) return QualType(type, 0);
assert(!attr || attr->getKind() == attrKind);
@@ -5797,7 +5773,7 @@ QualType ASTContext::getAttributedType(attr::Kind attrKind,
AttributedType(canon, attrKind, attr, modifiedType, equivalentType);
Types.push_back(type);
- AttributedTypes.InsertNode(type, insertPos);
+ AttributedTypes.insert(type, Token);
return QualType(type, 0);
}
@@ -5834,9 +5810,8 @@ QualType ASTContext::getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
llvm::FoldingSetNodeID ID;
BTFTagAttributedType::Profile(ID, Wrapped, BTFAttr);
- void *InsertPos = nullptr;
- BTFTagAttributedType *Ty =
- BTFTagAttributedTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ BTFTagAttributedType *Ty = BTFTagAttributedTypes.lookup(ID, Token);
if (Ty)
return QualType(Ty, 0);
@@ -5845,7 +5820,7 @@ QualType ASTContext::getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
BTFTagAttributedType(Canon, Wrapped, BTFAttr);
Types.push_back(Ty);
- BTFTagAttributedTypes.InsertNode(Ty, InsertPos);
+ BTFTagAttributedTypes.insert(Ty, Token);
return QualType(Ty, 0);
}
@@ -5873,10 +5848,9 @@ QualType ASTContext::getOverflowBehaviorType(
"Cannot have underlying types that are themselves OBTs");
llvm::FoldingSetNodeID ID;
OverflowBehaviorType::Profile(ID, Underlying, Kind);
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
- if (OverflowBehaviorType *OBT =
- OverflowBehaviorTypes.FindNodeOrInsertPos(ID, InsertPos)) {
+ if (OverflowBehaviorType *OBT = OverflowBehaviorTypes.lookup(ID, Token)) {
return QualType(OBT, 0);
}
@@ -5885,7 +5859,7 @@ QualType ASTContext::getOverflowBehaviorType(
SplitQualType canonSplit = getCanonicalType(Underlying).split();
Canonical = getOverflowBehaviorType(Kind, QualType(canonSplit.Ty, 0));
Canonical = getQualifiedType(Canonical, canonSplit.Quals);
- assert(!OverflowBehaviorTypes.FindNodeOrInsertPos(ID, InsertPos) &&
+ assert(!OverflowBehaviorTypes.lookup(ID, Token) &&
"Shouldn't be in the map");
}
@@ -5893,7 +5867,7 @@ QualType ASTContext::getOverflowBehaviorType(
OverflowBehaviorType(Canonical, Underlying, Kind);
Types.push_back(Ty);
- OverflowBehaviorTypes.InsertNode(Ty, InsertPos);
+ OverflowBehaviorTypes.insert(Ty, Token);
return QualType(Ty, 0);
}
@@ -5904,9 +5878,9 @@ QualType ASTContext::getHLSLAttributedResourceType(
llvm::FoldingSetNodeID ID;
HLSLAttributedResourceType::Profile(ID, *this, Wrapped, Contained, Attrs);
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
HLSLAttributedResourceType *Ty =
- HLSLAttributedResourceTypes.FindNodeOrInsertPos(ID, InsertPos);
+ HLSLAttributedResourceTypes.lookup(ID, Token);
if (Ty)
return QualType(Ty, 0);
@@ -5914,7 +5888,7 @@ QualType ASTContext::getHLSLAttributedResourceType(
HLSLAttributedResourceType(Wrapped, Contained, Attrs);
Types.push_back(Ty);
- HLSLAttributedResourceTypes.InsertNode(Ty, InsertPos);
+ HLSLAttributedResourceTypes.insert(Ty, Token);
return QualType(Ty, 0);
}
@@ -5925,9 +5899,8 @@ QualType ASTContext::getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size,
llvm::FoldingSetNodeID ID;
HLSLInlineSpirvType::Profile(ID, Opcode, Size, Alignment, Operands);
- void *InsertPos = nullptr;
- HLSLInlineSpirvType *Ty =
- HLSLInlineSpirvTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ HLSLInlineSpirvType *Ty = HLSLInlineSpirvTypes.lookup(ID, Token);
if (Ty)
return QualType(Ty, 0);
@@ -5938,7 +5911,7 @@ QualType ASTContext::getHLSLInlineSpirvType(uint32_t Opcode, uint32_t Size,
Ty = new (Mem) HLSLInlineSpirvType(Opcode, Size, Alignment, Operands);
Types.push_back(Ty);
- HLSLInlineSpirvTypes.InsertNode(Ty, InsertPos);
+ HLSLInlineSpirvTypes.insert(Ty, Token);
return QualType(Ty, 0);
}
@@ -5952,9 +5925,9 @@ QualType ASTContext::getSubstTemplateTypeParmType(QualType Replacement,
llvm::FoldingSetNodeID ID;
SubstTemplateTypeParmType::Profile(ID, Replacement, AssociatedDecl, Index,
PackIndex, Final);
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
SubstTemplateTypeParmType *SubstParm =
- SubstTemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
+ SubstTemplateTypeParmTypes.lookup(ID, Token);
if (!SubstParm) {
void *Mem = Allocate(SubstTemplateTypeParmType::totalSizeToAlloc<QualType>(
@@ -5963,7 +5936,7 @@ QualType ASTContext::getSubstTemplateTypeParmType(QualType Replacement,
SubstParm = new (Mem) SubstTemplateTypeParmType(Replacement, AssociatedDecl,
Index, PackIndex, Final);
Types.push_back(SubstParm);
- SubstTemplateTypeParmTypes.InsertNode(SubstParm, InsertPos);
+ SubstTemplateTypeParmTypes.insert(SubstParm, Token);
}
return QualType(SubstParm, 0);
@@ -5981,9 +5954,9 @@ ASTContext::getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
llvm::FoldingSetNodeID ID;
SubstTemplateTypeParmPackType::Profile(ID, AssociatedDecl, Index, Final,
ArgPack);
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
if (SubstTemplateTypeParmPackType *SubstParm =
- SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos))
+ SubstTemplateTypeParmPackTypes.lookup(ID, Token))
return QualType(SubstParm, 0);
QualType Canon;
@@ -5994,7 +5967,7 @@ ASTContext::getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
Canon = getSubstTemplateTypeParmPackType(
AssociatedDecl->getCanonicalDecl(), Index, Final, CanonArgPack);
[[maybe_unused]] const auto *Nothing =
- SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos);
+ SubstTemplateTypeParmPackTypes.lookup(ID, Token);
assert(!Nothing);
}
}
@@ -6003,7 +5976,7 @@ ASTContext::getSubstTemplateTypeParmPackType(Decl *AssociatedDecl,
SubstTemplateTypeParmPackType(Canon, AssociatedDecl, Index, Final,
ArgPack);
Types.push_back(SubstParm);
- SubstTemplateTypeParmPackTypes.InsertNode(SubstParm, InsertPos);
+ SubstTemplateTypeParmPackTypes.insert(SubstParm, Token);
return QualType(SubstParm, 0);
}
@@ -6018,26 +5991,25 @@ ASTContext::getSubstBuiltinTemplatePack(const TemplateArgument &ArgPack) {
llvm::FoldingSetNodeID ID;
SubstBuiltinTemplatePackType::Profile(ID, ArgPack);
- void *InsertPos = nullptr;
- if (auto *T =
- SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (auto *T = SubstBuiltinTemplatePackTypes.lookup(ID, Token))
return QualType(T, 0);
QualType Canon;
TemplateArgument CanonArgPack = getCanonicalTemplateArgument(ArgPack);
if (!CanonArgPack.structurallyEquals(ArgPack)) {
Canon = getSubstBuiltinTemplatePack(CanonArgPack);
- // Refresh InsertPos, in case the recursive call above caused rehashing,
+ // Refresh Token, in case the recursive call above caused rehashing,
// which would invalidate the bucket pointer.
[[maybe_unused]] const auto *Nothing =
- SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos);
+ SubstBuiltinTemplatePackTypes.lookup(ID, Token);
assert(!Nothing);
}
auto *PackType = new (*this, alignof(SubstBuiltinTemplatePackType))
SubstBuiltinTemplatePackType(Canon, ArgPack);
Types.push_back(PackType);
- SubstBuiltinTemplatePackTypes.InsertNode(PackType, InsertPos);
+ SubstBuiltinTemplatePackTypes.insert(PackType, Token);
return QualType(PackType, 0);
}
@@ -6052,9 +6024,8 @@ ASTContext::getTemplateTypeParmType(int Depth, int Index, bool ParameterPack,
llvm::FoldingSetNodeID ID;
TemplateTypeParmType::Profile(ID, Depth, Index, ParameterPack, TTPDecl);
- void *InsertPos = nullptr;
- TemplateTypeParmType *TypeParm
- = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ TemplateTypeParmType *TypeParm = TemplateTypeParmTypes.lookup(ID, Token);
if (TypeParm)
return QualType(TypeParm, 0);
@@ -6064,8 +6035,7 @@ ASTContext::getTemplateTypeParmType(int Depth, int Index, bool ParameterPack,
TypeParm = new (*this, alignof(TemplateTypeParmType))
TemplateTypeParmType(Depth, Index, ParameterPack, TTPDecl, Canon);
- TemplateTypeParmType *TypeCheck
- = TemplateTypeParmTypes.FindNodeOrInsertPos(ID, InsertPos);
+ TemplateTypeParmType *TypeCheck = TemplateTypeParmTypes.lookup(ID, Token);
assert(!TypeCheck && "Template type parameter canonical type broken");
(void)TypeCheck;
} else
@@ -6073,7 +6043,7 @@ ASTContext::getTemplateTypeParmType(int Depth, int Index, bool ParameterPack,
Depth, Index, ParameterPack, /*TTPDecl=*/nullptr, /*Canon=*/QualType());
Types.push_back(TypeParm);
- TemplateTypeParmTypes.InsertNode(TypeParm, InsertPos);
+ TemplateTypeParmTypes.insert(TypeParm, Token);
return QualType(TypeParm, 0);
}
@@ -6154,8 +6124,8 @@ QualType ASTContext::getCanonicalTemplateSpecializationType(
llvm::FoldingSetNodeID ID;
TemplateSpecializationType::Profile(ID, Keyword, Template, Args, QualType(),
*this);
- void *InsertPos = nullptr;
- if (auto *T = TemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (auto *T = TemplateSpecializationTypes.lookup(ID, Token))
return QualType(T, 0);
void *Mem = Allocate(sizeof(TemplateSpecializationType) +
@@ -6167,7 +6137,7 @@ QualType ASTContext::getCanonicalTemplateSpecializationType(
assert(Spec->isDependentType() &&
"canonical template specialization must be dependent");
Types.push_back(Spec);
- TemplateSpecializationTypes.InsertNode(Spec, InsertPos);
+ TemplateSpecializationTypes.insert(Spec, Token);
return QualType(Spec, 0);
}
@@ -6226,22 +6196,22 @@ ASTContext::getParenType(QualType InnerType) const {
llvm::FoldingSetNodeID ID;
ParenType::Profile(ID, InnerType);
- void *InsertPos = nullptr;
- ParenType *T = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ ParenType *T = ParenTypes.lookup(ID, Token);
if (T)
return QualType(T, 0);
QualType Canon = InnerType;
if (!Canon.isCanonical()) {
Canon = getCanonicalType(InnerType);
- ParenType *CheckT = ParenTypes.FindNodeOrInsertPos(ID, InsertPos);
+ ParenType *CheckT = ParenTypes.lookup(ID, Token);
assert(!CheckT && "Paren canonical type broken");
(void)CheckT;
}
T = new (*this, alignof(ParenType)) ParenType(InnerType, Canon);
Types.push_back(T);
- ParenTypes.InsertNode(T, InsertPos);
+ ParenTypes.insert(T, Token);
return QualType(T, 0);
}
@@ -6264,9 +6234,8 @@ QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
llvm::FoldingSetNodeID ID;
DependentNameType::Profile(ID, Keyword, NNS, Name);
- void *InsertPos = nullptr;
- if (DependentNameType *T =
- DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (DependentNameType *T = DependentNameTypes.lookup(ID, Token))
return QualType(T, 0);
ElaboratedTypeKeyword CanonKeyword =
@@ -6277,7 +6246,7 @@ QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
if (CanonKeyword != Keyword || CanonNNS != NNS) {
Canon = getDependentNameType(CanonKeyword, CanonNNS, Name);
[[maybe_unused]] DependentNameType *T =
- DependentNameTypes.FindNodeOrInsertPos(ID, InsertPos);
+ DependentNameTypes.lookup(ID, Token);
assert(!T && "broken canonicalization");
assert(Canon.isCanonical());
}
@@ -6285,7 +6254,7 @@ QualType ASTContext::getDependentNameType(ElaboratedTypeKeyword Keyword,
DependentNameType *T = new (*this, alignof(DependentNameType))
DependentNameType(Keyword, NNS, Name, Canon);
Types.push_back(T);
- DependentNameTypes.InsertNode(T, InsertPos);
+ DependentNameTypes.insert(T, Token);
return QualType(T, 0);
}
@@ -6348,8 +6317,8 @@ QualType ASTContext::getPackExpansionType(QualType Pattern,
llvm::FoldingSetNodeID ID;
PackExpansionType::Profile(ID, Pattern, NumExpansions);
- void *InsertPos = nullptr;
- PackExpansionType *T = PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ PackExpansionType *T = PackExpansionTypes.lookup(ID, Token);
if (T)
return QualType(T, 0);
@@ -6360,13 +6329,13 @@ QualType ASTContext::getPackExpansionType(QualType Pattern,
// Find the insert position again, in case we inserted an element into
// PackExpansionTypes and invalidated our insert position.
- PackExpansionTypes.FindNodeOrInsertPos(ID, InsertPos);
+ PackExpansionTypes.lookup(ID, Token);
}
T = new (*this, alignof(PackExpansionType))
PackExpansionType(Pattern, Canon, NumExpansions);
Types.push_back(T);
- PackExpansionTypes.InsertNode(T, InsertPos);
+ PackExpansionTypes.insert(T, Token);
return QualType(T, 0);
}
@@ -6425,8 +6394,8 @@ QualType ASTContext::getObjCObjectType(
// Look in the folding set for an existing type.
llvm::FoldingSetNodeID ID;
ObjCObjectTypeImpl::Profile(ID, baseType, typeArgs, protocols, isKindOf);
- void *InsertPos = nullptr;
- if (ObjCObjectType *QT = ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (ObjCObjectType *QT = ObjCObjectTypes.lookup(ID, Token))
return QualType(QT, 0);
// Determine the type arguments to be used for canonicalization,
@@ -6471,8 +6440,8 @@ QualType ASTContext::getObjCObjectType(
canonical = getObjCObjectType(getCanonicalType(baseType), canonTypeArgs,
canonProtocols, isKindOf);
- // Regenerate InsertPos.
- ObjCObjectTypes.FindNodeOrInsertPos(ID, InsertPos);
+ // Regenerate Token.
+ ObjCObjectTypes.lookup(ID, Token);
}
unsigned size = sizeof(ObjCObjectTypeImpl);
@@ -6484,7 +6453,7 @@ QualType ASTContext::getObjCObjectType(
isKindOf);
Types.push_back(T);
- ObjCObjectTypes.InsertNode(T, InsertPos);
+ ObjCObjectTypes.insert(T, Token);
return QualType(T, 0);
}
@@ -6568,9 +6537,8 @@ ASTContext::getObjCTypeParamType(const ObjCTypeParamDecl *Decl,
// Look in the folding set for an existing type.
llvm::FoldingSetNodeID ID;
ObjCTypeParamType::Profile(ID, Decl, Decl->getUnderlyingType(), protocols);
- void *InsertPos = nullptr;
- if (ObjCTypeParamType *TypeParam =
- ObjCTypeParamTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (ObjCTypeParamType *TypeParam = ObjCTypeParamTypes.lookup(ID, Token))
return QualType(TypeParam, 0);
// We canonicalize to the underlying type.
@@ -6589,7 +6557,7 @@ ASTContext::getObjCTypeParamType(const ObjCTypeParamDecl *Decl,
auto *newType = new (mem) ObjCTypeParamType(Decl, Canonical, protocols);
Types.push_back(newType);
- ObjCTypeParamTypes.InsertNode(newType, InsertPos);
+ ObjCTypeParamTypes.insert(newType, Token);
return QualType(newType, 0);
}
@@ -6676,9 +6644,8 @@ QualType ASTContext::getObjCObjectPointerType(QualType ObjectT) const {
llvm::FoldingSetNodeID ID;
ObjCObjectPointerType::Profile(ID, ObjectT);
- void *InsertPos = nullptr;
- if (ObjCObjectPointerType *QT =
- ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (ObjCObjectPointerType *QT = ObjCObjectPointerTypes.lookup(ID, Token))
return QualType(QT, 0);
// Find the canonical object type.
@@ -6686,8 +6653,8 @@ QualType ASTContext::getObjCObjectPointerType(QualType ObjectT) const {
if (!ObjectT.isCanonical()) {
Canonical = getObjCObjectPointerType(getCanonicalType(ObjectT));
- // Regenerate InsertPos.
- ObjCObjectPointerTypes.FindNodeOrInsertPos(ID, InsertPos);
+ // Regenerate Token.
+ ObjCObjectPointerTypes.lookup(ID, Token);
}
// No match.
@@ -6697,7 +6664,7 @@ QualType ASTContext::getObjCObjectPointerType(QualType ObjectT) const {
new (Mem) ObjCObjectPointerType(Canonical, ObjectT);
Types.push_back(QType);
- ObjCObjectPointerTypes.InsertNode(QType, InsertPos);
+ ObjCObjectPointerTypes.insert(QType, Token);
return QualType(QType, 0);
}
@@ -6737,9 +6704,8 @@ QualType ASTContext::getTypeOfExprType(Expr *tofExpr, TypeOfKind Kind) const {
DependentTypeOfExprType::Profile(ID, *this, tofExpr,
Kind == TypeOfKind::Unqualified);
- void *InsertPos = nullptr;
- DependentTypeOfExprType *Canon =
- DependentTypeOfExprTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ DependentTypeOfExprType *Canon = DependentTypeOfExprTypes.lookup(ID, Token);
if (Canon) {
// We already have a "canonical" version of an identical, dependent
// typeof(expr) type. Use that as our canonical type.
@@ -6749,7 +6715,7 @@ QualType ASTContext::getTypeOfExprType(Expr *tofExpr, TypeOfKind Kind) const {
// Build a new, canonical typeof(expr) type.
Canon = new (*this, alignof(DependentTypeOfExprType))
DependentTypeOfExprType(*this, tofExpr, Kind);
- DependentTypeOfExprTypes.InsertNode(Canon, InsertPos);
+ DependentTypeOfExprTypes.insert(Canon, Token);
toe = Canon;
}
} else {
@@ -6815,15 +6781,14 @@ QualType ASTContext::getDecltypeType(Expr *E, QualType UnderlyingType) const {
llvm::FoldingSetNodeID ID;
DependentDecltypeType::Profile(ID, *this, E);
- void *InsertPos = nullptr;
- if (DependentDecltypeType *Canon =
- DependentDecltypeTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (DependentDecltypeType *Canon = DependentDecltypeTypes.lookup(ID, Token))
return QualType(Canon, 0);
// Build a new, canonical decltype(expr) type.
auto *DT =
new (*this, alignof(DependentDecltypeType)) DependentDecltypeType(E);
- DependentDecltypeTypes.InsertNode(DT, InsertPos);
+ DependentDecltypeTypes.insert(DT, Token);
Types.push_back(DT);
return QualType(DT, 0);
}
@@ -6844,9 +6809,8 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr,
llvm::FoldingSetNodeID ID;
PackIndexingType::Profile(ID, *this, Pattern.getCanonicalType(), IndexExpr,
FullySubstituted, Expansions);
- void *InsertPos = nullptr;
- PackIndexingType *Canon =
- DependentPackIndexingTypes.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ PackIndexingType *Canon = DependentPackIndexingTypes.lookup(ID, Token);
if (!Canon) {
void *Mem = Allocate(
PackIndexingType::totalSizeToAlloc<QualType>(Expansions.size()),
@@ -6854,7 +6818,7 @@ QualType ASTContext::getPackIndexingType(QualType Pattern, Expr *IndexExpr,
Canon =
new (Mem) PackIndexingType(QualType(), Pattern.getCanonicalType(),
IndexExpr, FullySubstituted, Expansions);
- DependentPackIndexingTypes.InsertNode(Canon, InsertPos);
+ DependentPackIndexingTypes.insert(Canon, Token);
}
Canonical = QualType(Canon, 0);
}
@@ -6877,9 +6841,8 @@ ASTContext::getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
llvm::FoldingSetNodeID ID;
UnaryTransformType::Profile(ID, BaseType, UnderlyingType, Kind);
- void *InsertPos = nullptr;
- if (UnaryTransformType *UT =
- UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (UnaryTransformType *UT = UnaryTransformTypes.lookup(ID, Token))
return QualType(UT, 0);
QualType CanonType;
@@ -6895,14 +6858,14 @@ ASTContext::getUnaryTransformType(QualType BaseType, QualType UnderlyingType,
// Find the insertion position again.
[[maybe_unused]] UnaryTransformType *UT =
- UnaryTransformTypes.FindNodeOrInsertPos(ID, InsertPos);
+ UnaryTransformTypes.lookup(ID, Token);
assert(!UT && "broken canonicalization");
}
}
auto *UT = new (*this, alignof(UnaryTransformType))
UnaryTransformType(BaseType, UnderlyingType, Kind, CanonType);
- UnaryTransformTypes.InsertNode(UT, InsertPos);
+ UnaryTransformTypes.insert(UT, Token);
Types.push_back(UT);
return QualType(UT, 0);
}
@@ -6987,12 +6950,12 @@ QualType ASTContext::getDeducedTemplateSpecializationType(
DeducedKind DK, QualType DeducedAsType, ElaboratedTypeKeyword Keyword,
TemplateName Template) const {
// Look in the folding set for an existing type.
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
llvm::FoldingSetNodeID ID;
DeducedTemplateSpecializationType::Profile(ID, DK, DeducedAsType, Keyword,
Template);
if (DeducedTemplateSpecializationType *DTST =
- DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos))
+ DeducedTemplateSpecializationTypes.lookup(ID, Token))
return QualType(DTST, 0);
if (DK == DeducedKind::Deduced) {
@@ -7008,7 +6971,7 @@ QualType ASTContext::getDeducedTemplateSpecializationType(
DK, QualType(), ElaboratedTypeKeyword::None, CanonTemplateName);
// Find the insertion position again.
[[maybe_unused]] DeducedTemplateSpecializationType *DTST =
- DeducedTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
+ DeducedTemplateSpecializationTypes.lookup(ID, Token);
assert(!DTST && "broken canonicalization");
}
}
@@ -7022,7 +6985,7 @@ QualType ASTContext::getDeducedTemplateSpecializationType(
assert(ID == TempID && "ID does not match");
#endif
Types.push_back(DTST);
- DeducedTemplateSpecializationTypes.InsertNode(DTST, InsertPos);
+ DeducedTemplateSpecializationTypes.insert(DTST, Token);
return QualType(DTST, 0);
}
@@ -7034,8 +6997,8 @@ QualType ASTContext::getAtomicType(QualType T) const {
llvm::FoldingSetNodeID ID;
AtomicType::Profile(ID, T);
- void *InsertPos = nullptr;
- if (AtomicType *AT = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (AtomicType *AT = AtomicTypes.lookup(ID, Token))
return QualType(AT, 0);
// If the atomic value type isn't canonical, this won't be a canonical type
@@ -7045,12 +7008,12 @@ QualType ASTContext::getAtomicType(QualType T) const {
Canonical = getAtomicType(getCanonicalType(T));
// Get the new insert position for the node we care about.
- AtomicType *NewIP = AtomicTypes.FindNodeOrInsertPos(ID, InsertPos);
+ AtomicType *NewIP = AtomicTypes.lookup(ID, Token);
assert(!NewIP && "Shouldn't be in the map!"); (void)NewIP;
}
auto *New = new (*this, alignof(AtomicType)) AtomicType(T, Canonical);
Types.push_back(New);
- AtomicTypes.InsertNode(New, InsertPos);
+ AtomicTypes.insert(New, Token);
return QualType(New, 0);
}
@@ -10568,13 +10531,12 @@ TemplateName ASTContext::getQualifiedTemplateName(NestedNameSpecifier Qualifier,
llvm::FoldingSetNodeID ID;
QualifiedTemplateName::Profile(ID, Qualifier, TemplateKeyword, Template);
- void *InsertPos = nullptr;
- QualifiedTemplateName *QTN =
- QualifiedTemplateNames.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ QualifiedTemplateName *QTN = QualifiedTemplateNames.lookup(ID, Token);
if (!QTN) {
QTN = new (*this, alignof(QualifiedTemplateName))
QualifiedTemplateName(Qualifier, TemplateKeyword, Template);
- QualifiedTemplateNames.InsertNode(QTN, InsertPos);
+ QualifiedTemplateNames.insert(QTN, Token);
}
return TemplateName(QTN);
@@ -10587,14 +10549,13 @@ ASTContext::getDependentTemplateName(const DependentTemplateStorage &S) const {
llvm::FoldingSetNodeID ID;
S.Profile(ID);
- void *InsertPos = nullptr;
- if (DependentTemplateName *QTN =
- DependentTemplateNames.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (DependentTemplateName *QTN = DependentTemplateNames.lookup(ID, Token))
return TemplateName(QTN);
DependentTemplateName *QTN =
new (*this, alignof(DependentTemplateName)) DependentTemplateName(S);
- DependentTemplateNames.InsertNode(QTN, InsertPos);
+ DependentTemplateNames.insert(QTN, Token);
return TemplateName(QTN);
}
@@ -10607,14 +10568,14 @@ TemplateName ASTContext::getSubstTemplateTemplateParm(TemplateName Replacement,
SubstTemplateTemplateParmStorage::Profile(ID, Replacement, AssociatedDecl,
Index, PackIndex, Final);
- void *insertPos = nullptr;
- SubstTemplateTemplateParmStorage *subst
- = SubstTemplateTemplateParms.FindNodeOrInsertPos(ID, insertPos);
+ llvm::FoldingSetInsertToken Token;
+ SubstTemplateTemplateParmStorage *subst =
+ SubstTemplateTemplateParms.lookup(ID, Token);
if (!subst) {
subst = new (*this) SubstTemplateTemplateParmStorage(
Replacement, AssociatedDecl, Index, PackIndex, Final);
- SubstTemplateTemplateParms.InsertNode(subst, insertPos);
+ SubstTemplateTemplateParms.insert(subst, Token);
}
return TemplateName(subst);
@@ -10629,14 +10590,14 @@ ASTContext::getSubstTemplateTemplateParmPack(const TemplateArgument &ArgPack,
SubstTemplateTemplateParmPackStorage::Profile(ID, Self, ArgPack,
AssociatedDecl, Index, Final);
- void *InsertPos = nullptr;
- SubstTemplateTemplateParmPackStorage *Subst
- = SubstTemplateTemplateParmPacks.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ SubstTemplateTemplateParmPackStorage *Subst =
+ SubstTemplateTemplateParmPacks.lookup(ID, Token);
if (!Subst) {
Subst = new (*this) SubstTemplateTemplateParmPackStorage(
ArgPack.pack_elements(), AssociatedDecl, Index, Final);
- SubstTemplateTemplateParmPacks.InsertNode(Subst, InsertPos);
+ SubstTemplateTemplateParmPacks.insert(Subst, Token);
}
return TemplateName(Subst);
@@ -10653,15 +10614,14 @@ ASTContext::getDeducedTemplateName(TemplateName Underlying,
llvm::FoldingSetNodeID ID;
DeducedTemplateStorage::Profile(ID, *this, Underlying, DefaultArgs);
- void *InsertPos = nullptr;
- DeducedTemplateStorage *DTS =
- DeducedTemplates.FindNodeOrInsertPos(ID, InsertPos);
+ llvm::FoldingSetInsertToken Token;
+ DeducedTemplateStorage *DTS = DeducedTemplates.lookup(ID, Token);
if (!DTS) {
void *Mem = Allocate(sizeof(DeducedTemplateStorage) +
sizeof(TemplateArgument) * DefaultArgs.Args.size(),
alignof(DeducedTemplateStorage));
DTS = new (Mem) DeducedTemplateStorage(Underlying, DefaultArgs);
- DeducedTemplates.InsertNode(DTS, InsertPos);
+ DeducedTemplates.insert(DTS, Token);
}
return TemplateName(DTS);
}
@@ -13944,13 +13904,13 @@ ASTContext::getMSGuidDecl(MSGuidDecl::Parts Parts) const {
llvm::FoldingSetNodeID ID;
MSGuidDecl::Profile(ID, Parts);
- void *InsertPos;
- if (MSGuidDecl *Existing = MSGuidDecls.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (MSGuidDecl *Existing = MSGuidDecls.lookup(ID, Token))
return Existing;
QualType GUIDType = getMSGuidType().withConst();
MSGuidDecl *New = MSGuidDecl::Create(*this, GUIDType, Parts);
- MSGuidDecls.InsertNode(New, InsertPos);
+ MSGuidDecls.insert(New, Token);
return New;
}
@@ -13960,14 +13920,14 @@ ASTContext::getUnnamedGlobalConstantDecl(QualType Ty,
llvm::FoldingSetNodeID ID;
UnnamedGlobalConstantDecl::Profile(ID, Ty, APVal);
- void *InsertPos;
+ llvm::FoldingSetInsertToken Token;
if (UnnamedGlobalConstantDecl *Existing =
- UnnamedGlobalConstantDecls.FindNodeOrInsertPos(ID, InsertPos))
+ UnnamedGlobalConstantDecls.lookup(ID, Token))
return Existing;
UnnamedGlobalConstantDecl *New =
UnnamedGlobalConstantDecl::Create(*this, Ty, APVal);
- UnnamedGlobalConstantDecls.InsertNode(New, InsertPos);
+ UnnamedGlobalConstantDecls.insert(New, Token);
return New;
}
@@ -13982,13 +13942,13 @@ ASTContext::getTemplateParamObjectDecl(QualType T, const APValue &V) const {
llvm::FoldingSetNodeID ID;
TemplateParamObjectDecl::Profile(ID, T, V);
- void *InsertPos;
+ llvm::FoldingSetInsertToken Token;
if (TemplateParamObjectDecl *Existing =
- TemplateParamObjectDecls.FindNodeOrInsertPos(ID, InsertPos))
+ TemplateParamObjectDecls.lookup(ID, Token))
return Existing;
TemplateParamObjectDecl *New = TemplateParamObjectDecl::Create(*this, T, V);
- TemplateParamObjectDecls.InsertNode(New, InsertPos);
+ TemplateParamObjectDecls.insert(New, Token);
return New;
}
diff --git a/clang/lib/AST/DeclarationName.cpp b/clang/lib/AST/DeclarationName.cpp
index 9a89a66f3f63a..105d2935d0c63 100644
--- a/clang/lib/AST/DeclarationName.cpp
+++ b/clang/lib/AST/DeclarationName.cpp
@@ -291,12 +291,12 @@ DeclarationNameTable::getCXXDeductionGuideName(TemplateDecl *Template) {
llvm::FoldingSetNodeID ID;
ID.AddPointer(Template);
- void *InsertPos = nullptr;
- if (auto *Name = CXXDeductionGuideNames.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (auto *Name = CXXDeductionGuideNames.lookup(ID, Token))
return DeclarationName(Name);
auto *Name = new (Ctx) detail::CXXDeductionGuideNameExtra(Template);
- CXXDeductionGuideNames.InsertNode(Name, InsertPos);
+ CXXDeductionGuideNames.insert(Name, Token);
return DeclarationName(Name);
}
@@ -306,13 +306,13 @@ DeclarationName DeclarationNameTable::getCXXConstructorName(CanQualType Ty) {
// Do we already have this C++ constructor name ?
llvm::FoldingSetNodeID ID;
ID.AddPointer(Ty.getAsOpaquePtr());
- void *InsertPos = nullptr;
- if (auto *Name = CXXConstructorNames.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (auto *Name = CXXConstructorNames.lookup(ID, Token))
return {Name, DeclarationName::StoredCXXConstructorName};
// We have to create it.
auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
- CXXConstructorNames.InsertNode(SpecialName, InsertPos);
+ CXXConstructorNames.insert(SpecialName, Token);
return {SpecialName, DeclarationName::StoredCXXConstructorName};
}
@@ -322,13 +322,13 @@ DeclarationName DeclarationNameTable::getCXXDestructorName(CanQualType Ty) {
// Do we already have this C++ destructor name ?
llvm::FoldingSetNodeID ID;
ID.AddPointer(Ty.getAsOpaquePtr());
- void *InsertPos = nullptr;
- if (auto *Name = CXXDestructorNames.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (auto *Name = CXXDestructorNames.lookup(ID, Token))
return {Name, DeclarationName::StoredCXXDestructorName};
// We have to create it.
auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
- CXXDestructorNames.InsertNode(SpecialName, InsertPos);
+ CXXDestructorNames.insert(SpecialName, Token);
return {SpecialName, DeclarationName::StoredCXXDestructorName};
}
@@ -337,14 +337,13 @@ DeclarationNameTable::getCXXConversionFunctionName(CanQualType Ty) {
// Do we already have this C++ conversion function name ?
llvm::FoldingSetNodeID ID;
ID.AddPointer(Ty.getAsOpaquePtr());
- void *InsertPos = nullptr;
- if (auto *Name =
- CXXConversionFunctionNames.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (auto *Name = CXXConversionFunctionNames.lookup(ID, Token))
return {Name, DeclarationName::StoredCXXConversionFunctionName};
// We have to create it.
auto *SpecialName = new (Ctx) detail::CXXSpecialNameExtra(Ty);
- CXXConversionFunctionNames.InsertNode(SpecialName, InsertPos);
+ CXXConversionFunctionNames.insert(SpecialName, Token);
return {SpecialName, DeclarationName::StoredCXXConversionFunctionName};
}
@@ -368,12 +367,12 @@ DeclarationNameTable::getCXXLiteralOperatorName(const IdentifierInfo *II) {
llvm::FoldingSetNodeID ID;
ID.AddPointer(II);
- void *InsertPos = nullptr;
- if (auto *Name = CXXLiteralOperatorNames.FindNodeOrInsertPos(ID, InsertPos))
+ llvm::FoldingSetInsertToken Token;
+ if (auto *Name = CXXLiteralOperatorNames.lookup(ID, Token))
return DeclarationName(Name);
auto *LiteralName = new (Ctx) detail::CXXLiteralOperatorIdName(II);
- CXXLiteralOperatorNames.InsertNode(LiteralName, InsertPos);
+ CXXLiteralOperatorNames.insert(LiteralName, Token);
return DeclarationName(LiteralName);
}
diff --git a/clang/lib/AST/NestedNameSpecifier.cpp b/clang/lib/AST/NestedNameSpecifier.cpp
index c217e5dfa98b2..b668a61021800 100644
--- a/clang/lib/AST/NestedNameSpecifier.cpp
+++ b/clang/lib/AST/NestedNameSpecifier.cpp
@@ -41,13 +41,13 @@ NestedNameSpecifier::MakeNamespaceAndPrefixStorage(
llvm::FoldingSetNodeID ID;
NamespaceAndPrefixStorage::Profile(ID, Namespace, Prefix);
- void *InsertPos = nullptr;
+ llvm::FoldingSetInsertToken Token;
NamespaceAndPrefixStorage *S =
- Ctx.NamespaceAndPrefixStorages.FindNodeOrInsertPos(ID, InsertPos);
+ Ctx.NamespaceAndPrefixStorages.lookup(ID, Token);
if (!S) {
S = new (Ctx, alignof(NamespaceAndPrefixStorage))
NamespaceAndPrefixStorage(Namespace, Prefix);
- Ctx.NamespaceAndPrefixStorages.InsertNode(S, InsertPos);
+ Ctx.NamespaceAndPrefixStorages.insert(S, Token);
}
return S;
}
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index d2b7759e95244..51c635c2e4198 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1341,8 +1341,8 @@ bool Sema::CheckConstraintSatisfaction(
llvm::FoldingSetNodeID ID;
ConstraintSatisfaction::Profile(ID, Context, Owner, FlattenedArgs);
- void *InsertPos;
- if (auto *Cached = SatisfactionCache.FindNodeOrInsertPos(ID, InsertPos)) {
+ llvm::FoldingSetInsertToken Token;
+ if (auto *Cached = SatisfactionCache.lookup(ID, Token)) {
OutSatisfaction = *Cached;
return false;
}
@@ -1356,7 +1356,7 @@ bool Sema::CheckConstraintSatisfaction(
return true;
}
- if (auto *Cached = SatisfactionCache.FindNodeOrInsertPos(ID, InsertPos)) {
+ if (auto *Cached = SatisfactionCache.lookup(ID, Token)) {
// The evaluation of this constraint resulted in us trying to re-evaluate it
// recursively. This isn't really possible, except we try to form a
// RecoveryExpr as a part of the evaluation. If this is the case, just
@@ -1371,7 +1371,7 @@ bool Sema::CheckConstraintSatisfaction(
// Else we can simply add this satisfaction to the list.
OutSatisfaction = *Satisfaction;
- // We cannot use InsertPos here because CheckConstraintSatisfaction might have
+ // We cannot use Token here because CheckConstraintSatisfaction might have
// invalidated it.
// Note that entries of SatisfactionCache are deleted in Sema's destructor.
SatisfactionCache.InsertNode(Satisfaction.release());
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index fe2763213280f..43419c46dd2bf 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3411,9 +3411,9 @@ Sema::LookupSpecialMember(CXXRecordDecl *RD, CXXSpecialMemberKind SM,
ID.AddInteger(ConstThis);
ID.AddInteger(VolatileThis);
- void *InsertPoint;
+ llvm::FoldingSetInsertToken Token;
SpecialMemberOverloadResultEntry *Result =
- SpecialMemberCache.FindNodeOrInsertPos(ID, InsertPoint);
+ SpecialMemberCache.lookup(ID, Token);
// This was already cached
if (Result)
@@ -3421,7 +3421,7 @@ Sema::LookupSpecialMember(CXXRecordDecl *RD, CXXSpecialMemberKind SM,
Result = BumpAlloc.Allocate<SpecialMemberOverloadResultEntry>();
Result = new (Result) SpecialMemberOverloadResultEntry(ID);
- SpecialMemberCache.InsertNode(Result, InsertPoint);
+ SpecialMemberCache.insert(Result, Token);
if (SM == CXXSpecialMemberKind::Destructor) {
if (RD->needsImplicitDestructor()) {
More information about the cfe-commits
mailing list