llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Daniel Grumberg (daniel-grumberg) <details> <summary>Changes</summary> Fixes #<!-- -->106355 --- Full diff: https://github.com/llvm/llvm-project/pull/106411.diff 2 Files Affected: - (modified) clang/include/clang/ExtractAPI/API.h (+5-6) - (modified) clang/lib/ExtractAPI/API.cpp (+4-2) ``````````diff diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h index 188e35b72117b5..4f34fcc575e807 100644 --- a/clang/include/clang/ExtractAPI/API.h +++ b/clang/include/clang/ExtractAPI/API.h @@ -23,7 +23,7 @@ #include "clang/AST/RawCommentList.h" #include "clang/Basic/SourceLocation.h" #include "clang/ExtractAPI/DeclarationFragments.h" -#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Casting.h" #include "llvm/TargetParser/Triple.h" @@ -1420,9 +1420,8 @@ class APISet { typename std::enable_if_t<std::is_base_of_v<APIRecord, RecordTy>, RecordTy> * createRecord(StringRef USR, StringRef Name, CtorArgsContTy &&...CtorArgs); - auto getTopLevelRecords() const { - return llvm::iterator_range<decltype(TopLevelRecords)::iterator>( - TopLevelRecords); + ArrayRef<const APIRecord *> getTopLevelRecords() const { + return TopLevelRecords; } void removeRecord(StringRef USR); @@ -1455,7 +1454,7 @@ class APISet { // lives in the BumpPtrAllocator. using APIRecordStoredPtr = std::unique_ptr<APIRecord, APIRecordDeleter>; llvm::DenseMap<StringRef, APIRecordStoredPtr> USRBasedLookupTable; - llvm::SmallPtrSet<const APIRecord *, 32> TopLevelRecords; + llvm::SmallVector<const APIRecord *, 32> TopLevelRecords; public: const std::string ProductName; @@ -1481,7 +1480,7 @@ APISet::createRecord(StringRef USR, StringRef Name, dyn_cast_if_present<RecordContext>(Record->Parent.Record)) ParentContext->addToRecordChain(Record); else - TopLevelRecords.insert(Record); + TopLevelRecords.push_back(Record); } else { Record = dyn_cast<RecordTy>(Result.first->second.get()); } diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp index 9dbc023885c37f..a6ca0ae8d0d51d 100644 --- a/clang/lib/ExtractAPI/API.cpp +++ b/clang/lib/ExtractAPI/API.cpp @@ -150,11 +150,13 @@ void APISet::removeRecord(StringRef USR) { if (auto *RecordAsCtx = llvm::dyn_cast<RecordContext>(Record)) ParentCtx->stealRecordChain(*RecordAsCtx); } else { - TopLevelRecords.erase(Record); + auto *It = llvm::find(TopLevelRecords, Record); + if (It != TopLevelRecords.end()) + TopLevelRecords.erase(It); if (auto *RecordAsCtx = llvm::dyn_cast<RecordContext>(Record)) { for (const auto *Child = RecordAsCtx->First; Child != nullptr; Child = Child->getNextInContext()) - TopLevelRecords.insert(Child); + TopLevelRecords.push_back(Child); } } USRBasedLookupTable.erase(Result); `````````` </details> https://github.com/llvm/llvm-project/pull/106411 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits