diff options
Diffstat (limited to 'clang/lib/ExtractAPI/API.cpp')
-rw-r--r-- | clang/lib/ExtractAPI/API.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/clang/lib/ExtractAPI/API.cpp b/clang/lib/ExtractAPI/API.cpp index 7aa8233..6b60d2c 100644 --- a/clang/lib/ExtractAPI/API.cpp +++ b/clang/lib/ExtractAPI/API.cpp @@ -17,7 +17,7 @@ #include "clang/AST/CommentLexer.h" #include "clang/AST/RawCommentList.h" #include "clang/Index/USRGeneration.h" -#include "llvm/Support/Allocator.h" +#include <memory> using namespace clang::extractapi; using namespace llvm; @@ -32,9 +32,9 @@ GlobalRecord *APISet::addGlobal(GVKind Kind, StringRef Name, StringRef USR, auto Result = Globals.insert({Name, nullptr}); if (Result.second) { // Create the record if it does not already exist. - auto Record = APIRecordUniquePtr<GlobalRecord>(new (Allocator) GlobalRecord{ + auto Record = std::make_unique<GlobalRecord>( 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 +63,8 @@ EnumConstantRecord *APISet::addEnumConstant( EnumRecord *Enum, StringRef Name, StringRef USR, PresumedLoc Loc, const AvailabilityInfo &Availability, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading) { - auto Record = - APIRecordUniquePtr<EnumConstantRecord>(new (Allocator) EnumConstantRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique<EnumConstantRecord>( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); return Enum->Constants.emplace_back(std::move(Record)).get(); } @@ -77,8 +76,8 @@ EnumRecord *APISet::addEnum(StringRef Name, StringRef USR, PresumedLoc Loc, auto Result = Enums.insert({Name, nullptr}); if (Result.second) { // Create the record if it does not already exist. - auto Record = APIRecordUniquePtr<EnumRecord>(new (Allocator) EnumRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique<EnumRecord>( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); Result.first->second = std::move(Record); } return Result.first->second.get(); @@ -90,9 +89,8 @@ StructFieldRecord *APISet::addStructField(StructRecord *Struct, StringRef Name, const DocComment &Comment, DeclarationFragments Declaration, DeclarationFragments SubHeading) { - auto Record = - APIRecordUniquePtr<StructFieldRecord>(new (Allocator) StructFieldRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique<StructFieldRecord>( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); return Struct->Fields.emplace_back(std::move(Record)).get(); } @@ -104,8 +102,8 @@ StructRecord *APISet::addStruct(StringRef Name, StringRef USR, PresumedLoc Loc, auto Result = Structs.insert({Name, nullptr}); if (Result.second) { // Create the record if it does not already exist. - auto Record = APIRecordUniquePtr<StructRecord>(new (Allocator) StructRecord{ - Name, USR, Loc, Availability, Comment, Declaration, SubHeading}); + auto Record = std::make_unique<StructRecord>( + Name, USR, Loc, Availability, Comment, Declaration, SubHeading); Result.first->second = std::move(Record); } return Result.first->second.get(); @@ -122,10 +120,10 @@ StringRef APISet::copyString(StringRef String) { return {}; // No need to allocate memory and copy if the string has already been stored. - if (Allocator.identifyObject(String.data())) + if (StringAllocator.identifyObject(String.data())) return String; - void *Ptr = Allocator.Allocate(String.size(), 1); + void *Ptr = StringAllocator.Allocate(String.size(), 1); memcpy(Ptr, String.data(), String.size()); return StringRef(reinterpret_cast<const char *>(Ptr), String.size()); } |