diff --git a/clang/include/clang/ExtractAPI/API.h b/clang/include/clang/ExtractAPI/API.h --- a/clang/include/clang/ExtractAPI/API.h +++ b/clang/include/clang/ExtractAPI/API.h @@ -30,25 +30,6 @@ #include "llvm/Support/Casting.h" #include -namespace { - -/// \brief A custom deleter used for ``std::unique_ptr`` to APIRecords stored -/// in the BumpPtrAllocator. -/// -/// \tparam T the exact type of the APIRecord subclass. -template struct UniquePtrBumpPtrAllocatorDeleter { - void operator()(T *Instance) { Instance->~T(); } -}; - -/// A unique pointer to an APIRecord stored in the BumpPtrAllocator. -/// -/// \tparam T the exact type of the APIRecord subclass. -template -using APIRecordUniquePtr = - std::unique_ptr>; - -} // anonymous namespace - namespace clang { namespace extractapi { @@ -165,7 +146,7 @@ /// This holds information associated with enums. struct EnumRecord : APIRecord { - SmallVector> Constants; + SmallVector> Constants; EnumRecord(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, @@ -194,7 +175,7 @@ /// This holds information associated with structs. struct StructRecord : APIRecord { - SmallVector> Fields; + SmallVector> Fields; StructRecord(StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, @@ -302,17 +283,16 @@ /// A map to store the set of GlobalRecord%s with the declaration name as the /// key. using GlobalRecordMap = - llvm::MapVector>; + llvm::MapVector>; /// A map to store the set of EnumRecord%s with the declaration name as the /// key. - using EnumRecordMap = - llvm::MapVector>; + using EnumRecordMap = llvm::MapVector>; /// A map to store the set of StructRecord%s with the declaration name as the /// key. using StructRecordMap = - llvm::MapVector>; + llvm::MapVector>; /// Get the target triple for the ExtractAPI invocation. const llvm::Triple &getTarget() const { return Target; } @@ -340,7 +320,9 @@ : Target(Target), LangOpts(LangOpts) {} private: - /// BumpPtrAllocator to store APIRecord%s and generated/copied strings. + /// BumpPtrAllocator to store generated/copied strings. + /// + /// Note: The main use for this is being able to deduplicate strings. llvm::BumpPtrAllocator Allocator; const llvm::Triple Target; diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp --- a/clang/lib/ExtractAPI/API.cpp +++ b/clang/lib/ExtractAPI/API.cpp @@ -18,6 +18,7 @@ #include "clang/AST/RawCommentList.h" #include "clang/Index/USRGeneration.h" #include "llvm/Support/Allocator.h" +#include using namespace clang::extractapi; using namespace llvm; @@ -32,9 +33,9 @@ auto Result = Globals.insert({Name, nullptr}); if (Result.second) { // Create the record if it does not already exist. - auto Record = APIRecordUniquePtr(new (Allocator) GlobalRecord{ + auto Record = std::make_unique( Kind, Name, USR, Loc, Availability, Linkage, Comment, Fragments, - SubHeading, Signature}); + SubHeading, Signature); Result.first->second = std::move(Record); } return Result.first->second.get(); @@ -63,9 +64,8 @@ EnumRecord *Enum, StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading) { - auto Record = - APIRecordUniquePtr(new (Allocator) EnumConstantRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); return Enum->Constants.emplace_back(std::move(Record)).get(); } @@ -77,8 +77,8 @@ auto Result = Enums.insert({Name, nullptr}); if (Result.second) { // Create the record if it does not already exist. - auto Record = APIRecordUniquePtr(new (Allocator) EnumRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); Result.first->second = std::move(Record); } return Result.first->second.get(); @@ -90,9 +90,8 @@ const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading) { - auto Record = - APIRecordUniquePtr(new (Allocator) StructFieldRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); return Struct->Fields.emplace_back(std::move(Record)).get(); } @@ -104,8 +103,8 @@ auto Result = Structs.insert({Name, nullptr}); if (Result.second) { // Create the record if it does not already exist. - auto Record = APIRecordUniquePtr(new (Allocator) StructRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); Result.first->second = std::move(Record); } return Result.first->second.get();