Skip to content

Commit

Permalink
[Clang] Migrate llvm::make_unique to std::make_unique
Browse files Browse the repository at this point in the history
Now that we've moved to C++14, we no longer need the llvm::make_unique
implementation from STLExtras.h. This patch is a mechanical replacement
of (hopefully) all the llvm::make_unique instances across the monorepo.

Differential revision: https://reviews.llvm.org/D66259

llvm-svn: 368942
  • Loading branch information
JDevlieghere committed Aug 14, 2019
1 parent 5cd312d commit 2b3d49b
Show file tree
Hide file tree
Showing 259 changed files with 831 additions and 831 deletions.
2 changes: 1 addition & 1 deletion clang/examples/AnnotateFunctions/AnnotateFunctions.cpp
Expand Up @@ -41,7 +41,7 @@ class AnnotateFunctionsAction : public PluginASTAction {
public:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
llvm::StringRef) override {
return llvm::make_unique<AnnotateFunctionsConsumer>();
return std::make_unique<AnnotateFunctionsConsumer>();
}

bool ParseArgs(const CompilerInstance &CI,
Expand Down
2 changes: 1 addition & 1 deletion clang/examples/PrintFunctionNames/PrintFunctionNames.cpp
Expand Up @@ -81,7 +81,7 @@ class PrintFunctionNamesAction : public PluginASTAction {
protected:
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
llvm::StringRef) override {
return llvm::make_unique<PrintFunctionsConsumer>(CI, ParsedTemplates);
return std::make_unique<PrintFunctionsConsumer>(CI, ParsedTemplates);
}

bool ParseArgs(const CompilerInstance &CI,
Expand Down
2 changes: 1 addition & 1 deletion clang/examples/clang-interpreter/main.cpp
Expand Up @@ -58,7 +58,7 @@ class SimpleJIT {
IRCompileLayer CompileLayer{ES, ObjectLayer, SimpleCompiler(*TM)};

static std::unique_ptr<SectionMemoryManager> createMemMgr() {
return llvm::make_unique<SectionMemoryManager>();
return std::make_unique<SectionMemoryManager>();
}

SimpleJIT(
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/ASTImporterSharedState.h
Expand Up @@ -47,7 +47,7 @@ class ASTImporterSharedState {
ASTImporterSharedState() = default;

ASTImporterSharedState(TranslationUnitDecl &ToTU) {
LookupTable = llvm::make_unique<ASTImporterLookupTable>(ToTU);
LookupTable = std::make_unique<ASTImporterLookupTable>(ToTU);
}

ASTImporterLookupTable *getLookupTable() { return LookupTable.get(); }
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/SyncScope.h
Expand Up @@ -144,7 +144,7 @@ AtomicScopeModel::create(AtomicScopeModelKind K) {
case AtomicScopeModelKind::None:
return std::unique_ptr<AtomicScopeModel>{};
case AtomicScopeModelKind::OpenCL:
return llvm::make_unique<AtomicScopeOpenCLModel>();
return std::make_unique<AtomicScopeOpenCLModel>();
}
llvm_unreachable("Invalid atomic scope model kind");
}
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Frontend/ASTUnit.h
Expand Up @@ -315,7 +315,7 @@ class ASTUnit {

CodeCompletionTUInfo &getCodeCompletionTUInfo() {
if (!CCTUInfo)
CCTUInfo = llvm::make_unique<CodeCompletionTUInfo>(
CCTUInfo = std::make_unique<CodeCompletionTUInfo>(
std::make_shared<GlobalCodeCompletionAllocator>());
return *CCTUInfo;
}
Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Lex/Preprocessor.h
Expand Up @@ -994,7 +994,7 @@ class Preprocessor {
PPCallbacks *getPPCallbacks() const { return Callbacks.get(); }
void addPPCallbacks(std::unique_ptr<PPCallbacks> C) {
if (Callbacks)
C = llvm::make_unique<PPChainedCallbacks>(std::move(C),
C = std::make_unique<PPChainedCallbacks>(std::move(C),
std::move(Callbacks));
Callbacks = std::move(C);
}
Expand Down Expand Up @@ -1471,7 +1471,7 @@ class Preprocessor {
if (LexLevel) {
// It's not correct in general to enter caching lex mode while in the
// middle of a nested lexing action.
auto TokCopy = llvm::make_unique<Token[]>(1);
auto TokCopy = std::make_unique<Token[]>(1);
TokCopy[0] = Tok;
EnterTokenStream(std::move(TokCopy), 1, true, IsReinject);
} else {
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Sema/SemaInternal.h
Expand Up @@ -97,7 +97,7 @@ class TypoCorrectionConsumer : public VisibleDeclConsumer {
bool EnteringContext)
: Typo(TypoName.getName().getAsIdentifierInfo()), CurrentTCIndex(0),
SavedTCIndex(0), SemaRef(SemaRef), S(S),
SS(SS ? llvm::make_unique<CXXScopeSpec>(*SS) : nullptr),
SS(SS ? std::make_unique<CXXScopeSpec>(*SS) : nullptr),
CorrectionValidator(std::move(CCC)), MemberContext(MemberContext),
Result(SemaRef, TypoName, LookupKind),
Namespaces(SemaRef.Context, SemaRef.CurContext, SS),
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/Sema/TypoCorrection.h
Expand Up @@ -356,7 +356,7 @@ class DefaultFilterCCC final : public CorrectionCandidateCallback {
: CorrectionCandidateCallback(Typo, TypoNNS) {}

std::unique_ptr<CorrectionCandidateCallback> clone() override {
return llvm::make_unique<DefaultFilterCCC>(*this);
return std::make_unique<DefaultFilterCCC>(*this);
}
};

Expand All @@ -369,7 +369,7 @@ class DeclFilterCCC final : public CorrectionCandidateCallback {
return candidate.getCorrectionDeclAs<C>();
}
std::unique_ptr<CorrectionCandidateCallback> clone() override {
return llvm::make_unique<DeclFilterCCC>(*this);
return std::make_unique<DeclFilterCCC>(*this);
}
};

Expand All @@ -384,7 +384,7 @@ class FunctionCallFilterCCC : public CorrectionCandidateCallback {

bool ValidateCandidate(const TypoCorrection &candidate) override;
std::unique_ptr<CorrectionCandidateCallback> clone() override {
return llvm::make_unique<FunctionCallFilterCCC>(*this);
return std::make_unique<FunctionCallFilterCCC>(*this);
}

private:
Expand All @@ -409,7 +409,7 @@ class NoTypoCorrectionCCC final : public CorrectionCandidateCallback {
return false;
}
std::unique_ptr<CorrectionCandidateCallback> clone() override {
return llvm::make_unique<NoTypoCorrectionCCC>(*this);
return std::make_unique<NoTypoCorrectionCCC>(*this);
}
};

Expand Down
4 changes: 2 additions & 2 deletions clang/include/clang/Serialization/ASTReader.h
Expand Up @@ -1578,7 +1578,7 @@ class ASTReader
/// Takes ownership of \p L.
void addListener(std::unique_ptr<ASTReaderListener> L) {
if (Listener)
L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
L = std::make_unique<ChainedASTReaderListener>(std::move(L),
std::move(Listener));
Listener = std::move(L);
}
Expand All @@ -1594,7 +1594,7 @@ class ASTReader
auto Old = Reader.takeListener();
if (Old) {
Chained = true;
L = llvm::make_unique<ChainedASTReaderListener>(std::move(L),
L = std::make_unique<ChainedASTReaderListener>(std::move(L),
std::move(Old));
}
Reader.setListener(std::move(L));
Expand Down
Expand Up @@ -646,7 +646,7 @@ class NoteTag : public ProgramPointTag {

public:
const NoteTag *makeNoteTag(Callback &&Cb, bool IsPrunable = false) {
// We cannot use make_unique because we cannot access the private
// We cannot use std::make_unique because we cannot access the private
// constructor from inside it.
std::unique_ptr<NoteTag> T(new NoteTag(std::move(Cb), IsPrunable));
Tags.push_back(std::move(T));
Expand Down
Expand Up @@ -337,7 +337,7 @@ class ExplodedGraph {
bool IsSink = false);

std::unique_ptr<ExplodedGraph> MakeEmptyGraph() const {
return llvm::make_unique<ExplodedGraph>();
return std::make_unique<ExplodedGraph>();
}

/// addRoot - Add an untyped node to the set of roots.
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Tooling/ASTDiff/ASTDiff.h
Expand Up @@ -71,7 +71,7 @@ class SyntaxTree {
/// Constructs a tree from any AST node.
template <class T>
SyntaxTree(T *Node, ASTContext &AST)
: TreeImpl(llvm::make_unique<Impl>(this, Node, AST)) {}
: TreeImpl(std::make_unique<Impl>(this, Node, AST)) {}
SyntaxTree(SyntaxTree &&Other) = default;
~SyntaxTree();

Expand Down
Expand Up @@ -148,7 +148,7 @@ createRefactoringActionRule(const RequirementTypes &... Requirements) {
std::tuple<RequirementTypes...> Requirements;
};

return llvm::make_unique<Rule>(std::make_tuple(Requirements...));
return std::make_unique<Rule>(std::make_tuple(Requirements...));
}

} // end namespace tooling
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/ARCMigrate/ARCMT.cpp
Expand Up @@ -453,8 +453,8 @@ class ARCMTMacroTrackerAction : public ASTFrontendAction {
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) override {
CI.getPreprocessor().addPPCallbacks(
llvm::make_unique<ARCMTMacroTrackerPPCallbacks>(ARCMTMacroLocs));
return llvm::make_unique<ASTConsumer>();
std::make_unique<ARCMTMacroTrackerPPCallbacks>(ARCMTMacroLocs));
return std::make_unique<ASTConsumer>();
}
};

Expand Down
6 changes: 3 additions & 3 deletions clang/lib/ARCMigrate/ObjCMT.cpp
Expand Up @@ -208,10 +208,10 @@ ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
CI.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec));
std::vector<std::unique_ptr<ASTConsumer>> Consumers;
Consumers.push_back(WrapperFrontendAction::CreateASTConsumer(CI, InFile));
Consumers.push_back(llvm::make_unique<ObjCMigrateASTConsumer>(
Consumers.push_back(std::make_unique<ObjCMigrateASTConsumer>(
MigrateDir, ObjCMigAction, Remapper, CompInst->getFileManager(), PPRec,
CompInst->getPreprocessor(), false, None));
return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
return std::make_unique<MultiplexConsumer>(std::move(Consumers));
}

bool ObjCMigrateAction::BeginInvocation(CompilerInstance &CI) {
Expand Down Expand Up @@ -2034,7 +2034,7 @@ MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
CI.getPreprocessor().addPPCallbacks(std::unique_ptr<PPCallbacks>(PPRec));
std::vector<std::string> WhiteList =
getWhiteListFilenames(CI.getFrontendOpts().ObjCMTWhiteListPath);
return llvm::make_unique<ObjCMigrateASTConsumer>(
return std::make_unique<ObjCMigrateASTConsumer>(
CI.getFrontendOpts().OutputFile, ObjCMTAction, Remapper,
CI.getFileManager(), PPRec, CI.getPreprocessor(),
/*isOutputFile=*/true, WhiteList);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTContext.cpp
Expand Up @@ -10472,7 +10472,7 @@ ASTContext::getParents(const ast_type_traits::DynTypedNode &Node) {
if (!Parents)
// We build the parent map for the traversal scope (usually whole TU), as
// hasAncestor can escape any subtree.
Parents = llvm::make_unique<ParentMap>(*this);
Parents = std::make_unique<ParentMap>(*this);
return Parents->getParents(Node);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/CXXInheritance.cpp
Expand Up @@ -44,7 +44,7 @@ void CXXBasePaths::ComputeDeclsFound() {
Decls.insert(Path->Decls.front());

NumDeclsFound = Decls.size();
DeclsFound = llvm::make_unique<NamedDecl *[]>(NumDeclsFound);
DeclsFound = std::make_unique<NamedDecl *[]>(NumDeclsFound);
std::copy(Decls.begin(), Decls.end(), DeclsFound.get());
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ExternalASTMerger.cpp
Expand Up @@ -320,7 +320,7 @@ ExternalASTMerger::ExternalASTMerger(const ImporterTarget &Target,
void ExternalASTMerger::AddSources(llvm::ArrayRef<ImporterSource> Sources) {
for (const ImporterSource &S : Sources) {
assert(&S.AST != &Target.AST);
Importers.push_back(llvm::make_unique<LazyASTImporter>(
Importers.push_back(std::make_unique<LazyASTImporter>(
*this, Target.AST, Target.FM, S.AST, S.FM, S.OM));
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ItaniumCXXABI.cpp
Expand Up @@ -218,7 +218,7 @@ class ItaniumCXXABI : public CXXABI {

std::unique_ptr<MangleNumberingContext>
createMangleNumberingContext() const override {
return llvm::make_unique<ItaniumNumberingContext>();
return std::make_unique<ItaniumNumberingContext>();
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/Mangle.cpp
Expand Up @@ -470,7 +470,7 @@ class ASTNameGenerator::Implementation {
};

ASTNameGenerator::ASTNameGenerator(ASTContext &Ctx)
: Impl(llvm::make_unique<Implementation>(Ctx)) {}
: Impl(std::make_unique<Implementation>(Ctx)) {}

ASTNameGenerator::~ASTNameGenerator() {}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/MicrosoftCXXABI.cpp
Expand Up @@ -132,7 +132,7 @@ class MicrosoftCXXABI : public CXXABI {

std::unique_ptr<MangleNumberingContext>
createMangleNumberingContext() const override {
return llvm::make_unique<MicrosoftNumberingContext>();
return std::make_unique<MicrosoftNumberingContext>();
}
};
}
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/AST/VTableBuilder.cpp
Expand Up @@ -2268,7 +2268,7 @@ CreateVTableLayout(const ItaniumVTableBuilder &Builder) {
SmallVector<VTableLayout::VTableThunkTy, 1>
VTableThunks(Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());

return llvm::make_unique<VTableLayout>(
return std::make_unique<VTableLayout>(
Builder.VTableIndices, Builder.vtable_components(), VTableThunks,
Builder.getAddressPoints());
}
Expand Down Expand Up @@ -3253,7 +3253,7 @@ void MicrosoftVTableContext::computeVTablePaths(bool ForVBTables,

// Base case: this subobject has its own vptr.
if (ForVBTables ? Layout.hasOwnVBPtr() : Layout.hasOwnVFPtr())
Paths.push_back(llvm::make_unique<VPtrInfo>(RD));
Paths.push_back(std::make_unique<VPtrInfo>(RD));

// Recursive case: get all the vbtables from our bases and remove anything
// that shares a virtual base.
Expand All @@ -3276,7 +3276,7 @@ void MicrosoftVTableContext::computeVTablePaths(bool ForVBTables,
continue;

// Copy the path and adjust it as necessary.
auto P = llvm::make_unique<VPtrInfo>(*BaseInfo);
auto P = std::make_unique<VPtrInfo>(*BaseInfo);

// We mangle Base into the path if the path would've been ambiguous and it
// wasn't already extended with Base.
Expand Down Expand Up @@ -3562,7 +3562,7 @@ void MicrosoftVTableContext::computeVTableRelatedInformation(
const VTableLayout::AddressPointsMapTy EmptyAddressPointsMap;

{
auto VFPtrs = llvm::make_unique<VPtrInfoVector>();
auto VFPtrs = std::make_unique<VPtrInfoVector>();
computeVTablePaths(/*ForVBTables=*/false, RD, *VFPtrs);
computeFullPathsForVFTables(Context, RD, *VFPtrs);
VFPtrLocations[RD] = std::move(VFPtrs);
Expand All @@ -3576,7 +3576,7 @@ void MicrosoftVTableContext::computeVTableRelatedInformation(
assert(VFTableLayouts.count(id) == 0);
SmallVector<VTableLayout::VTableThunkTy, 1> VTableThunks(
Builder.vtable_thunks_begin(), Builder.vtable_thunks_end());
VFTableLayouts[id] = llvm::make_unique<VTableLayout>(
VFTableLayouts[id] = std::make_unique<VTableLayout>(
ArrayRef<size_t>{0}, Builder.vtable_components(), VTableThunks,
EmptyAddressPointsMap);
Thunks.insert(Builder.thunks_begin(), Builder.thunks_end());
Expand Down Expand Up @@ -3668,7 +3668,7 @@ const VirtualBaseInfo &MicrosoftVTableContext::computeVBTableRelatedInformation(
std::unique_ptr<VirtualBaseInfo> &Entry = VBaseInfo[RD];
if (Entry)
return *Entry;
Entry = llvm::make_unique<VirtualBaseInfo>();
Entry = std::make_unique<VirtualBaseInfo>();
VBI = Entry.get();
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/ASTMatchers/ASTMatchFinder.cpp
Expand Up @@ -1078,7 +1078,7 @@ bool MatchFinder::addDynamicMatcher(const internal::DynTypedMatcher &NodeMatch,
}

std::unique_ptr<ASTConsumer> MatchFinder::newASTConsumer() {
return llvm::make_unique<internal::MatchASTConsumer>(this, ParsingDone);
return std::make_unique<internal::MatchASTConsumer>(this, ParsingDone);
}

void MatchFinder::match(const clang::ast_type_traits::DynTypedNode &Node,
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/ASTMatchers/Dynamic/Marshallers.h
Expand Up @@ -729,7 +729,7 @@ std::unique_ptr<MatcherDescriptor>
makeMatcherAutoMarshall(ReturnType (*Func)(), StringRef MatcherName) {
std::vector<ast_type_traits::ASTNodeKind> RetTypes;
BuildReturnTypeVector<ReturnType>::build(RetTypes);
return llvm::make_unique<FixedArgCountMatcherDescriptor>(
return std::make_unique<FixedArgCountMatcherDescriptor>(
matcherMarshall0<ReturnType>, reinterpret_cast<void (*)()>(Func),
MatcherName, RetTypes, None);
}
Expand All @@ -741,7 +741,7 @@ makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1), StringRef MatcherName) {
std::vector<ast_type_traits::ASTNodeKind> RetTypes;
BuildReturnTypeVector<ReturnType>::build(RetTypes);
ArgKind AK = ArgTypeTraits<ArgType1>::getKind();
return llvm::make_unique<FixedArgCountMatcherDescriptor>(
return std::make_unique<FixedArgCountMatcherDescriptor>(
matcherMarshall1<ReturnType, ArgType1>,
reinterpret_cast<void (*)()>(Func), MatcherName, RetTypes, AK);
}
Expand All @@ -755,7 +755,7 @@ makeMatcherAutoMarshall(ReturnType (*Func)(ArgType1, ArgType2),
BuildReturnTypeVector<ReturnType>::build(RetTypes);
ArgKind AKs[] = { ArgTypeTraits<ArgType1>::getKind(),
ArgTypeTraits<ArgType2>::getKind() };
return llvm::make_unique<FixedArgCountMatcherDescriptor>(
return std::make_unique<FixedArgCountMatcherDescriptor>(
matcherMarshall2<ReturnType, ArgType1, ArgType2>,
reinterpret_cast<void (*)()>(Func), MatcherName, RetTypes, AKs);
}
Expand All @@ -766,7 +766,7 @@ template <typename ResultT, typename ArgT,
std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
ast_matchers::internal::VariadicFunction<ResultT, ArgT, Func> VarFunc,
StringRef MatcherName) {
return llvm::make_unique<VariadicFuncMatcherDescriptor>(VarFunc, MatcherName);
return std::make_unique<VariadicFuncMatcherDescriptor>(VarFunc, MatcherName);
}

/// Overload for VariadicDynCastAllOfMatchers.
Expand All @@ -778,7 +778,7 @@ std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
ast_matchers::internal::VariadicDynCastAllOfMatcher<BaseT, DerivedT>
VarFunc,
StringRef MatcherName) {
return llvm::make_unique<DynCastAllOfMatcherDescriptor>(VarFunc, MatcherName);
return std::make_unique<DynCastAllOfMatcherDescriptor>(VarFunc, MatcherName);
}

/// Argument adaptative overload.
Expand All @@ -791,7 +791,7 @@ std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
std::vector<std::unique_ptr<MatcherDescriptor>> Overloads;
AdaptativeOverloadCollector<ArgumentAdapterT, FromTypes, ToTypes>(MatcherName,
Overloads);
return llvm::make_unique<OverloadedMatcherDescriptor>(Overloads);
return std::make_unique<OverloadedMatcherDescriptor>(Overloads);
}

template <template <typename ToArg, typename FromArg> class ArgumentAdapterT,
Expand All @@ -810,7 +810,7 @@ std::unique_ptr<MatcherDescriptor> makeMatcherAutoMarshall(
ast_matchers::internal::VariadicOperatorMatcherFunc<MinCount, MaxCount>
Func,
StringRef MatcherName) {
return llvm::make_unique<VariadicOperatorMatcherDescriptor>(
return std::make_unique<VariadicOperatorMatcherDescriptor>(
MinCount, MaxCount, Func.Op, MatcherName);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/ASTMatchers/Dynamic/Registry.cpp
Expand Up @@ -71,7 +71,7 @@ void RegistryMaps::registerMatcher(

#define REGISTER_MATCHER_OVERLOAD(name) \
registerMatcher(#name, \
llvm::make_unique<internal::OverloadedMatcherDescriptor>(name##Callbacks))
std::make_unique<internal::OverloadedMatcherDescriptor>(name##Callbacks))

#define SPECIFIC_MATCHER_OVERLOAD(name, Id) \
static_cast<::clang::ast_matchers::name##_Type##Id>( \
Expand Down

0 comments on commit 2b3d49b

Please sign in to comment.