llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-static-analyzer-1

@llvm/pr-subscribers-clang-analysis

Author: Fangrui Song (MaskRay)

<details>
<summary>Changes</summary>

findSpecialization/AddSpecialization and their Decl.h wrappers stop
threading a `void *` through the AST, Sema, Serialization and CodeGen
callers. This is the last user of FoldingSet's `void *` insert position.

In PPMacroExpansion.cpp the token is named InsertToken, as Token there
means the lexer token.


---

Patch is 70.76 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/219844.diff


31 Files Affected:

- (modified) clang/include/clang/AST/Decl.h (+6-5) 
- (modified) clang/include/clang/AST/DeclTemplate.h (+29-20) 
- (modified) 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h (+3-3) 
- (modified) clang/lib/AST/ASTImporter.cpp (+18-19) 
- (modified) clang/lib/AST/ByteCode/Compiler.cpp (+2-2) 
- (modified) clang/lib/AST/Decl.cpp (+2-2) 
- (modified) clang/lib/AST/DeclTemplate.cpp (+45-46) 
- (modified) clang/lib/AST/ExprConstant.cpp (+2-2) 
- (modified) clang/lib/Analysis/AnalysisDeclContext.cpp (+3-3) 
- (modified) clang/lib/Analysis/LifetimeSafety/Loans.cpp (+6-8) 
- (modified) clang/lib/Analysis/PathDiagnostic.cpp (+9-9) 
- (modified) clang/lib/Analysis/RetainSummaryManager.cpp (+3-3) 
- (modified) clang/lib/Basic/IdentifierTable.cpp (+3-4) 
- (modified) clang/lib/CIR/CodeGen/CIRGenClass.cpp (+2-2) 
- (modified) clang/lib/CIR/CodeGen/CIRGenTypes.cpp (+3-3) 
- (modified) clang/lib/CodeGen/CGBlocks.cpp (+3-4) 
- (modified) clang/lib/CodeGen/CGCall.cpp (+3-3) 
- (modified) clang/lib/CodeGen/CGClass.cpp (+2-2) 
- (modified) clang/lib/Lex/PPMacroExpansion.cpp (+5-5) 
- (modified) clang/lib/Sema/HLSLExternalSemaSource.cpp (+1-1) 
- (modified) clang/lib/Sema/SemaCXXScopeSpec.cpp (+2-2) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+21-22) 
- (modified) clang/lib/Sema/SemaTemplateInstantiateDecl.cpp (+28-28) 
- (modified) clang/lib/Serialization/ASTReaderDecl.cpp (+17-15) 
- (modified) clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp (+18-20) 
- (modified) clang/lib/StaticAnalyzer/Core/BugReporter.cpp (+5-5) 
- (modified) clang/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (+4-4) 
- (modified) clang/lib/StaticAnalyzer/Core/MemRegion.cpp (+12-12) 
- (modified) clang/lib/StaticAnalyzer/Core/ProgramState.cpp (+4-4) 
- (modified) clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp (+3-3) 
- (modified) clang/unittests/AST/ExternalASTSourceTest.cpp (+1-1) 


``````````diff
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 92050d635e2e0..f239bbad2f17c 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -37,6 +37,7 @@
 #include "clang/Basic/Visibility.h"
 #include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/FoldingSet.h"
 #include "llvm/ADT/PointerIntPair.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/ADT/StringRef.h"
@@ -2228,7 +2229,7 @@ class FunctionDecl : public DeclaratorDecl,
   /// \param TemplateArgs the template arguments that produced this
   /// function template specialization from the template.
   ///
-  /// \param InsertPos If non-NULL, the position in the function template
+  /// \param Token If set, the insert token in the function template
   /// specialization set where the function template specialization data will
   /// be inserted.
   ///
@@ -2240,7 +2241,7 @@ class FunctionDecl : public DeclaratorDecl,
   /// specialization was first instantiated.
   void setFunctionTemplateSpecialization(
       ASTContext &C, FunctionTemplateDecl *Template,
-      TemplateArgumentList *TemplateArgs, void *InsertPos,
+      TemplateArgumentList *TemplateArgs, llvm::FoldingSetInsertToken Token,
       TemplateSpecializationKind TSK,
       const TemplateArgumentListInfo *TemplateArgsAsWritten,
       SourceLocation PointOfInstantiation);
@@ -3191,7 +3192,7 @@ class FunctionDecl : public DeclaratorDecl,
   /// \param TemplateArgs the template arguments that produced this
   /// function template specialization from the template.
   ///
-  /// \param InsertPos If non-NULL, the position in the function template
+  /// \param Token If set, the insert token in the function template
   /// specialization set where the function template specialization data will
   /// be inserted.
   ///
@@ -3203,12 +3204,12 @@ class FunctionDecl : public DeclaratorDecl,
   /// specialization was first instantiated.
   void setFunctionTemplateSpecialization(
       FunctionTemplateDecl *Template, TemplateArgumentList *TemplateArgs,
-      void *InsertPos,
+      llvm::FoldingSetInsertToken Token,
       TemplateSpecializationKind TSK = TSK_ImplicitInstantiation,
       TemplateArgumentListInfo *TemplateArgsAsWritten = nullptr,
       SourceLocation PointOfInstantiation = SourceLocation()) {
     setFunctionTemplateSpecialization(getASTContext(), Template, TemplateArgs,
-                                      InsertPos, TSK, TemplateArgsAsWritten,
+                                      Token, TSK, TemplateArgsAsWritten,
                                       PointOfInstantiation);
   }
 
diff --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index f5b26b0aab9ba..14b353d48c690 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -778,16 +778,19 @@ class RedeclarableTemplateDecl : public TemplateDecl,
   template <class EntryType, typename... ProfileArguments>
   typename SpecEntryTraits<EntryType>::DeclType *
   findSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
-                         void *&InsertPos, ProfileArguments... ProfileArgs);
+                         llvm::FoldingSetInsertToken &Token,
+                         ProfileArguments... ProfileArgs);
 
   template <class EntryType, typename... ProfileArguments>
   typename SpecEntryTraits<EntryType>::DeclType *
   findSpecializationLocally(llvm::FoldingSetVector<EntryType> &Specs,
-                            void *&InsertPos, ProfileArguments... ProfileArgs);
+                            llvm::FoldingSetInsertToken &Token,
+                            ProfileArguments... ProfileArgs);
 
   template <class Derived, class EntryType>
   void addSpecializationImpl(llvm::FoldingSetVector<EntryType> &Specs,
-                             EntryType *Entry, void *InsertPos);
+                             EntryType *Entry,
+                             llvm::FoldingSetInsertToken Token);
 
   struct CommonBase {
     CommonBase() : InstantiatedFromMember(nullptr, false) {}
@@ -983,10 +986,10 @@ class FunctionTemplateDecl : public 
RedeclarableTemplateDecl {
 
   /// Add a specialization of this function template.
   ///
-  /// \param InsertPos Insert position in the FoldingSetVector, must have been
-  ///        retrieved by an earlier call to findSpecialization().
-  void addSpecialization(FunctionTemplateSpecializationInfo* Info,
-                         void *InsertPos);
+  /// \param Token Insert token, must have been retrieved by an earlier call
+  ///        to findSpecialization().
+  void addSpecialization(FunctionTemplateSpecializationInfo *Info,
+                         llvm::FoldingSetInsertToken Token);
 
 public:
   friend class ASTDeclReader;
@@ -1029,7 +1032,7 @@ class FunctionTemplateDecl : public 
RedeclarableTemplateDecl {
   /// Return the specialization with the provided arguments if it exists,
   /// otherwise return the insertion point.
   FunctionDecl *findSpecialization(ArrayRef<TemplateArgument> Args,
-                                   void *&InsertPos);
+                                   llvm::FoldingSetInsertToken &Token);
 
   FunctionTemplateDecl *getCanonicalDecl() override {
     return cast<FunctionTemplateDecl>(
@@ -2338,11 +2341,13 @@ class ClassTemplateDecl : public 
RedeclarableTemplateDecl {
   /// Return the specialization with the provided arguments if it exists,
   /// otherwise return the insertion point.
   ClassTemplateSpecializationDecl *
-  findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
+  findSpecialization(ArrayRef<TemplateArgument> Args,
+                     llvm::FoldingSetInsertToken &Token);
 
   /// Insert the specified specialization knowing that it is not already
-  /// in. InsertPos must be obtained from findSpecialization.
-  void AddSpecialization(ClassTemplateSpecializationDecl *D, void *InsertPos);
+  /// in. Token must be obtained from findSpecialization.
+  void AddSpecialization(ClassTemplateSpecializationDecl *D,
+                         llvm::FoldingSetInsertToken Token);
 
   ClassTemplateDecl *getCanonicalDecl() override {
     return cast<ClassTemplateDecl>(
@@ -2382,12 +2387,13 @@ class ClassTemplateDecl : public 
RedeclarableTemplateDecl {
   /// exists, otherwise return the insertion point.
   ClassTemplatePartialSpecializationDecl *
   findPartialSpecialization(ArrayRef<TemplateArgument> Args,
-                            TemplateParameterList *TPL, void *&InsertPos);
+                            TemplateParameterList *TPL,
+                            llvm::FoldingSetInsertToken &Token);
 
   /// Insert the specified partial specialization knowing that it is not
-  /// already in. InsertPos must be obtained from findPartialSpecialization.
+  /// already in. Token must be obtained from findPartialSpecialization.
   void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D,
-                                void *InsertPos);
+                                llvm::FoldingSetInsertToken Token);
 
   /// Retrieve the partial specializations as an ordered list.
   void getPartialSpecializations(
@@ -3097,11 +3103,13 @@ class VarTemplateDecl : public RedeclarableTemplateDecl 
{
   /// Return the specialization with the provided arguments if it exists,
   /// otherwise return the insertion point.
   VarTemplateSpecializationDecl *
-  findSpecialization(ArrayRef<TemplateArgument> Args, void *&InsertPos);
+  findSpecialization(ArrayRef<TemplateArgument> Args,
+                     llvm::FoldingSetInsertToken &Token);
 
   /// Insert the specified specialization knowing that it is not already
-  /// in. InsertPos must be obtained from findSpecialization.
-  void AddSpecialization(VarTemplateSpecializationDecl *D, void *InsertPos);
+  /// in. Token must be obtained from findSpecialization.
+  void AddSpecialization(VarTemplateSpecializationDecl *D,
+                         llvm::FoldingSetInsertToken Token);
 
   VarTemplateDecl *getCanonicalDecl() override {
     return cast<VarTemplateDecl>(RedeclarableTemplateDecl::getCanonicalDecl());
@@ -3139,12 +3147,13 @@ class VarTemplateDecl : public RedeclarableTemplateDecl 
{
   /// exists, otherwise return the insertion point.
   VarTemplatePartialSpecializationDecl *
   findPartialSpecialization(ArrayRef<TemplateArgument> Args,
-                            TemplateParameterList *TPL, void *&InsertPos);
+                            TemplateParameterList *TPL,
+                            llvm::FoldingSetInsertToken &Token);
 
   /// Insert the specified partial specialization knowing that it is not
-  /// already in. InsertPos must be obtained from findPartialSpecialization.
+  /// already in. Token must be obtained from findPartialSpecialization.
   void AddPartialSpecialization(VarTemplatePartialSpecializationDecl *D,
-                                void *InsertPos);
+                                llvm::FoldingSetInsertToken Token);
 
   /// Retrieve the partial specializations as an ordered list.
   void getPartialSpecializations(
diff --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
index a5d49200a50cb..3fcc505e9f94e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/SymbolManager.h
@@ -675,11 +675,11 @@ template <typename T, typename... Args>
 const T *SymbolManager::acquire(Args &&...args) {
   llvm::FoldingSetNodeID profile;
   T::Profile(profile, args...);
-  void *InsertPos;
-  SymExpr *SD = DataSet.FindNodeOrInsertPos(profile, InsertPos);
+  llvm::FoldingSetInsertToken Token;
+  SymExpr *SD = DataSet.lookup(profile, Token);
   if (!SD) {
     SD = Alloc.make<T>(std::forward<Args>(args)...);
-    DataSet.InsertNode(SD, InsertPos);
+    DataSet.insert(SD, Token);
   }
   return cast<T>(SD);
 }
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 0ad4130ce252a..b684ba7ab0f29 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3727,8 +3727,8 @@ Error ASTNodeImporter::ImportTemplateInformation(
 
     TemplateSpecializationKind TSK = FTSInfo->getTemplateSpecializationKind();
     ToFD->setFunctionTemplateSpecialization(
-        std::get<0>(*FunctionAndArgsOrErr), ToTAList, /* InsertPos= */ nullptr,
-        TSK, FromTAArgsAsWritten ? &ToTAInfo : nullptr, *POIOrErr);
+        std::get<0>(*FunctionAndArgsOrErr), ToTAList, /*Token=*/{}, TSK,
+        FromTAArgsAsWritten ? &ToTAInfo : nullptr, *POIOrErr);
     return Error::success();
   }
 
@@ -3769,8 +3769,8 @@ 
ASTNodeImporter::FindFunctionTemplateSpecialization(FunctionDecl *FromFD) {
   FunctionTemplateDecl *Template;
   TemplateArgsTy ToTemplArgs;
   std::tie(Template, ToTemplArgs) = *FunctionAndArgsOrErr;
-  void *InsertPos = nullptr;
-  auto *FoundSpec = Template->findSpecialization(ToTemplArgs, InsertPos);
+  llvm::FoldingSetInsertToken Token;
+  auto *FoundSpec = Template->findSpecialization(ToTemplArgs, Token);
   return FoundSpec;
 }
 
@@ -6368,7 +6368,7 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateSpecializationDecl(
     return std::move(Err);
   // Try to find an existing specialization with these template arguments and
   // template parameter list.
-  void *InsertPos = nullptr;
+  llvm::FoldingSetInsertToken Token;
   ClassTemplateSpecializationDecl *PrevDecl = nullptr;
   ClassTemplatePartialSpecializationDecl *PartialSpec =
             dyn_cast<ClassTemplatePartialSpecializationDecl>(D);
@@ -6382,10 +6382,9 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateSpecializationDecl(
       return ToTPListOrErr.takeError();
     ToTPList = *ToTPListOrErr;
     PrevDecl = ClassTemplate->findPartialSpecialization(TemplateArgs,
-                                                        *ToTPListOrErr,
-                                                        InsertPos);
+                                                        *ToTPListOrErr, Token);
   } else
-    PrevDecl = ClassTemplate->findSpecialization(TemplateArgs, InsertPos);
+    PrevDecl = ClassTemplate->findSpecialization(TemplateArgs, Token);
 
   if (PrevDecl) {
     if (IsStructuralMatch(D, PrevDecl)) {
@@ -6446,13 +6445,13 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateSpecializationDecl(
             cast_or_null<ClassTemplatePartialSpecializationDecl>(PrevDecl)))
       return D2;
 
-    // Update InsertPos, because preceding import calls may have invalidated
+    // Update Token, because preceding import calls may have invalidated
     // it by adding new specializations.
     auto *PartSpec2 = cast<ClassTemplatePartialSpecializationDecl>(D2);
     if (!ClassTemplate->findPartialSpecialization(TemplateArgs, ToTPList,
-                                                  InsertPos))
+                                                  Token))
       // Add this partial specialization to the class template.
-      ClassTemplate->AddPartialSpecialization(PartSpec2, InsertPos);
+      ClassTemplate->AddPartialSpecialization(PartSpec2, Token);
     if (Expected<ClassTemplatePartialSpecializationDecl *> ToInstOrErr =
             import(PartialSpec->getInstantiatedFromMember()))
       PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
@@ -6467,11 +6466,11 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateSpecializationDecl(
                                 PrevDecl))
       return D2;
 
-    // Update InsertPos, because preceding import calls may have invalidated
+    // Update Token, because preceding import calls may have invalidated
     // it by adding new specializations.
-    if (!ClassTemplate->findSpecialization(TemplateArgs, InsertPos))
+    if (!ClassTemplate->findSpecialization(TemplateArgs, Token))
       // Add this specialization to the class template.
-      ClassTemplate->AddSpecialization(D2, InsertPos);
+      ClassTemplate->AddSpecialization(D2, Token);
   }
 
   D2->setSpecializationKind(D->getSpecializationKind());
@@ -6698,9 +6697,9 @@ ExpectedDecl 
ASTNodeImporter::VisitVarTemplateSpecializationDecl(
     return std::move(Err);
 
   // Try to find an existing specialization with these template arguments.
-  void *InsertPos = nullptr;
+  llvm::FoldingSetInsertToken Token;
   VarTemplateSpecializationDecl *FoundSpecialization =
-      VarTemplate->findSpecialization(TemplateArgs, InsertPos);
+      VarTemplate->findSpecialization(TemplateArgs, Token);
   if (FoundSpecialization) {
     if (IsStructuralMatch(D, FoundSpecialization)) {
       VarDecl *FoundDef = FoundSpecialization->getDefinition();
@@ -6770,10 +6769,10 @@ ExpectedDecl 
ASTNodeImporter::VisitVarTemplateSpecializationDecl(
       return D2;
   }
 
-  // Update InsertPos, because preceding import calls may have invalidated
+  // Update Token, because preceding import calls may have invalidated
   // it by adding new specializations.
-  if (!VarTemplate->findSpecialization(TemplateArgs, InsertPos))
-    VarTemplate->AddSpecialization(D2, InsertPos);
+  if (!VarTemplate->findSpecialization(TemplateArgs, Token))
+    VarTemplate->AddSpecialization(D2, Token);
 
   QualType T;
   if (Error Err = importInto(T, D->getType()))
diff --git a/clang/lib/AST/ByteCode/Compiler.cpp 
b/clang/lib/AST/ByteCode/Compiler.cpp
index c182639ea07f8..fec8d00fcae12 100644
--- a/clang/lib/AST/ByteCode/Compiler.cpp
+++ b/clang/lib/AST/ByteCode/Compiler.cpp
@@ -7282,9 +7282,9 @@ bool Compiler<Emitter>::emitLambdaStaticInvokerBody(const 
CXXMethodDecl *MD) {
     const TemplateArgumentList *TAL = MD->getTemplateSpecializationArgs();
     FunctionTemplateDecl *CallOpTemplate =
         LambdaCallOp->getDescribedFunctionTemplate();
-    void *InsertPos = nullptr;
+    llvm::FoldingSetInsertToken Token;
     const FunctionDecl *CorrespondingCallOpSpecialization =
-        CallOpTemplate->findSpecialization(TAL->asArray(), InsertPos);
+        CallOpTemplate->findSpecialization(TAL->asArray(), Token);
     assert(CorrespondingCallOpSpecialization);
     LambdaCallOp = CorrespondingCallOpSpecialization;
   } else {
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index c9524dc82588a..93a7a47955936 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -4393,7 +4393,7 @@ FunctionDecl::getTemplateSpecializationArgsAsWritten() 
const {
 
 void FunctionDecl::setFunctionTemplateSpecialization(
     ASTContext &C, FunctionTemplateDecl *Template,
-    TemplateArgumentList *TemplateArgs, void *InsertPos,
+    TemplateArgumentList *TemplateArgs, llvm::FoldingSetInsertToken Token,
     TemplateSpecializationKind TSK,
     const TemplateArgumentListInfo *TemplateArgsAsWritten,
     SourceLocation PointOfInstantiation) {
@@ -4413,7 +4413,7 @@ void FunctionDecl::setFunctionTemplateSpecialization(
           dyn_cast_if_present<MemberSpecializationInfo *>(
               TemplateOrSpecialization));
   TemplateOrSpecialization = Info;
-  Template->addSpecialization(Info, InsertPos);
+  Template->addSpecialization(Info, Token);
 }
 
 void FunctionDecl::setDependentTemplateSpecialization(
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 3f952a1fe980b..188c67b9738a5 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -376,38 +376,38 @@ bool 
RedeclarableTemplateDecl::loadLazySpecializationsImpl(
 template <class EntryType, typename... ProfileArguments>
 typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType *
 RedeclarableTemplateDecl::findSpecializationLocally(
-    llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
-    ProfileArguments... ProfileArgs) {
+    llvm::FoldingSetVector<EntryType> &Specs,
+    llvm::FoldingSetInsertToken &Token, ProfileArguments... ProfileArgs) {
   using SETraits = RedeclarableTemplateDecl::SpecEntryTraits<EntryType>;
 
   llvm::FoldingSetNodeID ID;
   EntryType::Profile(ID, ProfileArgs..., getASTContext());
-  EntryType *Entry = Specs.FindNodeOrInsertPos(ID, InsertPos);
+  EntryType *Entry = Specs.lookup(ID, Token);
   return Entry ? SETraits::getDecl(Entry)->getMostRecentDecl() : nullptr;
 }
 
 template <class EntryType, typename... ProfileArguments>
 typename RedeclarableTemplateDecl::SpecEntryTraits<EntryType>::DeclType *
 RedeclarableTemplateDecl::findSpecializationImpl(
-    llvm::FoldingSetVector<EntryType> &Specs, void *&InsertPos,
-    ProfileArguments... ProfileArgs) {
+    llvm::FoldingSetVector<EntryType> &Specs,
+    llvm::FoldingSetInsertToken &Token, ProfileArguments... ProfileArgs) {
 
-  if (auto *Found = findSpecializationLocally(Specs, InsertPos, 
ProfileArgs...))
+  if (auto *Found = findSpecializationLocally(Specs, Token, ProfileArgs...))
     return Found;
 
   if (!loadLazySpecializationsImpl(ProfileArgs...))
     return nullptr;
 
-  return findSpecializationLocally(Specs, InsertPos, ProfileArgs...);
+  return findSpecializationLocally(Specs, Token, ProfileArgs...);
 }
 
-template<class Derived, class EntryType>
+template <class Derived, class EntryType>
 void RedeclarableTemplateDecl::addSpecializationImpl(
     llvm::FoldingSetVector<EntryType> &Specializations, EntryType *Entry,
-    void *InsertPos) {
+    llvm::FoldingSetInsertToken Token) {
   using SETraits = SpecEntryTraits<EntryType>;
 
-  if (InsertPos) {
+  if (Token) {
 #ifndef NDEBUG
     auto Args = SETraits::getTemplateArgs(Entry);
     // Due to hash collisions, it can happen that we load another template
@@ -415,14 +415,13 @@ void RedeclarableTemplateDecl::addSpecializationImpl(
     // call to findSpecializationImpl does not find a matching Decl for the
     // template arguments.
     loadLazySpecializationsImpl(Args);
-    void *CorrectInsertPos;
-    assert(!findSpecializationImpl(Specializations, CorrectInsertPos, Args) &&
-           InsertPos == CorrectInsertPos &&
-           "given incorrect InsertPos for specialization");
+    llvm::FoldingSetInsertToken CorrectToken;
+    assert(!findSpecializationImpl(Specializations, CorrectToken, Args) &&
+           Token == CorrectToken && "given incorrect Token for 
specialization");
 #endif
-    Specializations.InsertNode(Entry, InsertPos);
+    Specializations.insert(Entry, Token);
   } else {
-    EntryType *Existing = Specializations.GetOrInsertNode(Entry);
+    EntryType *Existing = Specializations.getOrInsert(Entry);
     (void)Existing;
     assert(SETraits::getDecl(Existing)->isCanonicalDecl...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/219844
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to