<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Interesting, it seems that libTooling is decoupled from the particular API changes in <span style="font-family: 'Helvetica Neue';" class="">r260048.</span></div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 8, 2016, at 5:39 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">FWIW, I tried to do something like this, perhaps with some other improvements, a few years ago. Not sure if things have changed for the better since then, but maybe those old patches may provide some insight/other improvements/options:<br class=""><br class=""><a href="http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140915/115122.html" class="">http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140915/115122.html</a><br class=""><a href="http://reviews.llvm.org/D4313" class="">http://reviews.llvm.org/D4313</a><br class=""><a href="http://reviews.llvm.org/D4312" class="">http://reviews.llvm.org/D4312</a><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sun, Feb 7, 2016 at 11:28 AM, Argyrios Kyrtzidis via cfe-commits <span dir="ltr" class=""><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank" class="">cfe-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: akirtzidis<br class="">
Date: Sun Feb 7 13:28:36 2016<br class="">
New Revision: 260048<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=260048&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=260048&view=rev</a><br class="">
Log:<br class="">
[Frontend] Make the memory management of FrontendAction pointers explicit by using unique_ptr.<br class="">
<br class="">
Modified:<br class="">
cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h<br class="">
cfe/trunk/include/clang/Frontend/FrontendAction.h<br class="">
cfe/trunk/include/clang/Frontend/FrontendActions.h<br class="">
cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h<br class="">
cfe/trunk/lib/ARCMigrate/ARCMTActions.cpp<br class="">
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp<br class="">
cfe/trunk/lib/Frontend/ASTMerge.cpp<br class="">
cfe/trunk/lib/Frontend/FrontendAction.cpp<br class="">
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp<br class="">
<br class="">
Modified: cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h (original)<br class="">
+++ cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h Sun Feb 7 13:28:36 2016<br class="">
@@ -22,7 +22,7 @@ protected:<br class="">
bool BeginInvocation(CompilerInstance &CI) override;<br class="">
<br class="">
public:<br class="">
- CheckAction(FrontendAction *WrappedAction);<br class="">
+ CheckAction(std::unique_ptr<FrontendAction> WrappedAction);<br class="">
};<br class="">
<br class="">
class ModifyAction : public WrapperFrontendAction {<br class="">
@@ -30,7 +30,7 @@ protected:<br class="">
bool BeginInvocation(CompilerInstance &CI) override;<br class="">
<br class="">
public:<br class="">
- ModifyAction(FrontendAction *WrappedAction);<br class="">
+ ModifyAction(std::unique_ptr<FrontendAction> WrappedAction);<br class="">
};<br class="">
<br class="">
class MigrateSourceAction : public ASTFrontendAction {<br class="">
@@ -49,7 +49,8 @@ protected:<br class="">
bool BeginInvocation(CompilerInstance &CI) override;<br class="">
<br class="">
public:<br class="">
- MigrateAction(FrontendAction *WrappedAction, StringRef migrateDir,<br class="">
+ MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,<br class="">
+ StringRef migrateDir,<br class="">
StringRef plistOut,<br class="">
bool emitPremigrationARCErrors);<br class="">
};<br class="">
@@ -61,8 +62,8 @@ class ObjCMigrateAction : public Wrapper<br class="">
FileRemapper Remapper;<br class="">
CompilerInstance *CompInst;<br class="">
public:<br class="">
- ObjCMigrateAction(FrontendAction *WrappedAction, StringRef migrateDir,<br class="">
- unsigned migrateAction);<br class="">
+ ObjCMigrateAction(std::unique_ptr<FrontendAction> WrappedAction,<br class="">
+ StringRef migrateDir, unsigned migrateAction);<br class="">
<br class="">
protected:<br class="">
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)<br class="">
+++ cfe/trunk/include/clang/Frontend/FrontendAction.h Sun Feb 7 13:28:36 2016<br class="">
@@ -283,7 +283,7 @@ protected:<br class="">
public:<br class="">
/// Construct a WrapperFrontendAction from an existing action, taking<br class="">
/// ownership of it.<br class="">
- WrapperFrontendAction(FrontendAction *WrappedAction);<br class="">
+ WrapperFrontendAction(std::unique_ptr<FrontendAction> WrappedAction);<br class="">
<br class="">
bool usesPreprocessorOnly() const override;<br class="">
TranslationUnitKind getTranslationUnitKind() override;<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)<br class="">
+++ cfe/trunk/include/clang/Frontend/FrontendActions.h Sun Feb 7 13:28:36 2016<br class="">
@@ -168,7 +168,7 @@ public:<br class="">
*/<br class="">
class ASTMergeAction : public FrontendAction {<br class="">
/// \brief The action that the merge action adapts.<br class="">
- FrontendAction *AdaptedAction;<br class="">
+ std::unique_ptr<FrontendAction> AdaptedAction;<br class="">
<br class="">
/// \brief The set of AST files to merge.<br class="">
std::vector<std::string> ASTFiles;<br class="">
@@ -184,7 +184,8 @@ protected:<br class="">
void EndSourceFileAction() override;<br class="">
<br class="">
public:<br class="">
- ASTMergeAction(FrontendAction *AdaptedAction, ArrayRef<std::string> ASTFiles);<br class="">
+ ASTMergeAction(std::unique_ptr<FrontendAction> AdaptedAction,<br class="">
+ ArrayRef<std::string> ASTFiles);<br class="">
~ASTMergeAction() override;<br class="">
<br class="">
bool usesPreprocessorOnly() const override;<br class="">
<br class="">
Modified: cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h (original)<br class="">
+++ cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h Sun Feb 7 13:28:36 2016<br class="">
@@ -50,8 +50,8 @@ public:<br class="">
/// frontend action.<br class="">
class FixItRecompile : public WrapperFrontendAction {<br class="">
public:<br class="">
- FixItRecompile(FrontendAction *WrappedAction)<br class="">
- : WrapperFrontendAction(WrappedAction) {}<br class="">
+ FixItRecompile(std::unique_ptr<FrontendAction> WrappedAction)<br class="">
+ : WrapperFrontendAction(std::move(WrappedAction)) {}<br class="">
<br class="">
protected:<br class="">
bool BeginInvocation(CompilerInstance &CI) override;<br class="">
<br class="">
Modified: cfe/trunk/lib/ARCMigrate/ARCMTActions.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMTActions.cpp?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMTActions.cpp?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/ARCMigrate/ARCMTActions.cpp (original)<br class="">
+++ cfe/trunk/lib/ARCMigrate/ARCMTActions.cpp Sun Feb 7 13:28:36 2016<br class="">
@@ -25,8 +25,8 @@ bool CheckAction::BeginInvocation(Compil<br class="">
return true;<br class="">
}<br class="">
<br class="">
-CheckAction::CheckAction(FrontendAction *WrappedAction)<br class="">
- : WrapperFrontendAction(WrappedAction) {}<br class="">
+CheckAction::CheckAction(std::unique_ptr<FrontendAction> WrappedAction)<br class="">
+ : WrapperFrontendAction(std::move(WrappedAction)) {}<br class="">
<br class="">
bool ModifyAction::BeginInvocation(CompilerInstance &CI) {<br class="">
return !arcmt::applyTransformations(CI.getInvocation(), getCurrentInput(),<br class="">
@@ -34,8 +34,8 @@ bool ModifyAction::BeginInvocation(Compi<br class="">
CI.getDiagnostics().getClient());<br class="">
}<br class="">
<br class="">
-ModifyAction::ModifyAction(FrontendAction *WrappedAction)<br class="">
- : WrapperFrontendAction(WrappedAction) {}<br class="">
+ModifyAction::ModifyAction(std::unique_ptr<FrontendAction> WrappedAction)<br class="">
+ : WrapperFrontendAction(std::move(WrappedAction)) {}<br class="">
<br class="">
bool MigrateAction::BeginInvocation(CompilerInstance &CI) {<br class="">
if (arcmt::migrateWithTemporaryFiles(<br class="">
@@ -49,11 +49,11 @@ bool MigrateAction::BeginInvocation(Comp<br class="">
return true;<br class="">
}<br class="">
<br class="">
-MigrateAction::MigrateAction(FrontendAction *WrappedAction,<br class="">
+MigrateAction::MigrateAction(std::unique_ptr<FrontendAction> WrappedAction,<br class="">
StringRef migrateDir,<br class="">
StringRef plistOut,<br class="">
bool emitPremigrationARCErrors)<br class="">
- : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir),<br class="">
+ : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),<br class="">
PlistOut(plistOut), EmitPremigrationARCErros(emitPremigrationARCErrors) {<br class="">
if (MigrateDir.empty())<br class="">
MigrateDir = "."; // user current directory if none is given.<br class="">
<br class="">
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)<br class="">
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Sun Feb 7 13:28:36 2016<br class="">
@@ -179,10 +179,11 @@ protected:<br class="">
<br class="">
}<br class="">
<br class="">
-ObjCMigrateAction::ObjCMigrateAction(FrontendAction *WrappedAction,<br class="">
+ObjCMigrateAction::ObjCMigrateAction(<br class="">
+ std::unique_ptr<FrontendAction> WrappedAction,<br class="">
StringRef migrateDir,<br class="">
unsigned migrateAction)<br class="">
- : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir),<br class="">
+ : WrapperFrontendAction(std::move(WrappedAction)), MigrateDir(migrateDir),<br class="">
ObjCMigAction(migrateAction),<br class="">
CompInst(nullptr) {<br class="">
if (MigrateDir.empty())<br class="">
<br class="">
Modified: cfe/trunk/lib/Frontend/ASTMerge.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTMerge.cpp?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTMerge.cpp?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Frontend/ASTMerge.cpp (original)<br class="">
+++ cfe/trunk/lib/Frontend/ASTMerge.cpp Sun Feb 7 13:28:36 2016<br class="">
@@ -83,14 +83,13 @@ void ASTMergeAction::EndSourceFileAction<br class="">
return AdaptedAction->EndSourceFileAction();<br class="">
}<br class="">
<br class="">
-ASTMergeAction::ASTMergeAction(FrontendAction *AdaptedAction,<br class="">
+ASTMergeAction::ASTMergeAction(std::unique_ptr<FrontendAction> adaptedAction,<br class="">
ArrayRef<std::string> ASTFiles)<br class="">
- : AdaptedAction(AdaptedAction), ASTFiles(ASTFiles.begin(), ASTFiles.end()) {<br class="">
+: AdaptedAction(std::move(adaptedAction)), ASTFiles(ASTFiles.begin(), ASTFiles.end()) {<br class="">
assert(AdaptedAction && "ASTMergeAction needs an action to adapt");<br class="">
}<br class="">
<br class="">
ASTMergeAction::~ASTMergeAction() {<br class="">
- delete AdaptedAction;<br class="">
}<br class="">
<br class="">
bool ASTMergeAction::usesPreprocessorOnly() const {<br class="">
<br class="">
Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)<br class="">
+++ cfe/trunk/lib/Frontend/FrontendAction.cpp Sun Feb 7 13:28:36 2016<br class="">
@@ -587,6 +587,7 @@ bool WrapperFrontendAction::hasCodeCompl<br class="">
return WrappedAction->hasCodeCompletionSupport();<br class="">
}<br class="">
<br class="">
-WrapperFrontendAction::WrapperFrontendAction(FrontendAction *WrappedAction)<br class="">
- : WrappedAction(WrappedAction) {}<br class="">
+WrapperFrontendAction::WrapperFrontendAction(<br class="">
+ std::unique_ptr<FrontendAction> WrappedAction)<br class="">
+ : WrappedAction(std::move(WrappedAction)) {}<br class="">
<br class="">
<br class="">
Modified: cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=260048&r1=260047&r2=260048&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp?rev=260048&r1=260047&r2=260048&view=diff</a><br class="">
==============================================================================<br class="">
--- cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp (original)<br class="">
+++ cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp Sun Feb 7 13:28:36 2016<br class="">
@@ -31,33 +31,34 @@<br class="">
using namespace clang;<br class="">
using namespace llvm::opt;<br class="">
<br class="">
-static FrontendAction *CreateFrontendBaseAction(CompilerInstance &CI) {<br class="">
+static std::unique_ptr<FrontendAction><br class="">
+CreateFrontendBaseAction(CompilerInstance &CI) {<br class="">
using namespace clang::frontend;<br class="">
StringRef Action("unknown");<br class="">
(void)Action;<br class="">
<br class="">
switch (CI.getFrontendOpts().ProgramAction) {<br class="">
- case ASTDeclList: return new ASTDeclListAction();<br class="">
- case ASTDump: return new ASTDumpAction();<br class="">
- case ASTPrint: return new ASTPrintAction();<br class="">
- case ASTView: return new ASTViewAction();<br class="">
- case DumpRawTokens: return new DumpRawTokensAction();<br class="">
- case DumpTokens: return new DumpTokensAction();<br class="">
- case EmitAssembly: return new EmitAssemblyAction();<br class="">
- case EmitBC: return new EmitBCAction();<br class="">
- case EmitHTML: return new HTMLPrintAction();<br class="">
- case EmitLLVM: return new EmitLLVMAction();<br class="">
- case EmitLLVMOnly: return new EmitLLVMOnlyAction();<br class="">
- case EmitCodeGenOnly: return new EmitCodeGenOnlyAction();<br class="">
- case EmitObj: return new EmitObjAction();<br class="">
- case FixIt: return new FixItAction();<br class="">
- case GenerateModule: return new GenerateModuleAction;<br class="">
- case GeneratePCH: return new GeneratePCHAction;<br class="">
- case GeneratePTH: return new GeneratePTHAction();<br class="">
- case InitOnly: return new InitOnlyAction();<br class="">
- case ParseSyntaxOnly: return new SyntaxOnlyAction();<br class="">
- case ModuleFileInfo: return new DumpModuleInfoAction();<br class="">
- case VerifyPCH: return new VerifyPCHAction();<br class="">
+ case ASTDeclList: return llvm::make_unique<ASTDeclListAction>();<br class="">
+ case ASTDump: return llvm::make_unique<ASTDumpAction>();<br class="">
+ case ASTPrint: return llvm::make_unique<ASTPrintAction>();<br class="">
+ case ASTView: return llvm::make_unique<ASTViewAction>();<br class="">
+ case DumpRawTokens: return llvm::make_unique<DumpRawTokensAction>();<br class="">
+ case DumpTokens: return llvm::make_unique<DumpTokensAction>();<br class="">
+ case EmitAssembly: return llvm::make_unique<EmitAssemblyAction>();<br class="">
+ case EmitBC: return llvm::make_unique<EmitBCAction>();<br class="">
+ case EmitHTML: return llvm::make_unique<HTMLPrintAction>();<br class="">
+ case EmitLLVM: return llvm::make_unique<EmitLLVMAction>();<br class="">
+ case EmitLLVMOnly: return llvm::make_unique<EmitLLVMOnlyAction>();<br class="">
+ case EmitCodeGenOnly: return llvm::make_unique<EmitCodeGenOnlyAction>();<br class="">
+ case EmitObj: return llvm::make_unique<EmitObjAction>();<br class="">
+ case FixIt: return llvm::make_unique<FixItAction>();<br class="">
+ case GenerateModule: return llvm::make_unique<GenerateModuleAction>();<br class="">
+ case GeneratePCH: return llvm::make_unique<GeneratePCHAction>();<br class="">
+ case GeneratePTH: return llvm::make_unique<GeneratePTHAction>();<br class="">
+ case InitOnly: return llvm::make_unique<InitOnlyAction>();<br class="">
+ case ParseSyntaxOnly: return llvm::make_unique<SyntaxOnlyAction>();<br class="">
+ case ModuleFileInfo: return llvm::make_unique<DumpModuleInfoAction>();<br class="">
+ case VerifyPCH: return llvm::make_unique<VerifyPCHAction>();<br class="">
<br class="">
case PluginAction: {<br class="">
for (FrontendPluginRegistry::iterator it =<br class="">
@@ -67,7 +68,7 @@ static FrontendAction *CreateFrontendBas<br class="">
std::unique_ptr<PluginASTAction> P(it->instantiate());<br class="">
if (!P->ParseArgs(CI, CI.getFrontendOpts().PluginArgs))<br class="">
return nullptr;<br class="">
- return P.release();<br class="">
+ return std::move(P);<br class="">
}<br class="">
}<br class="">
<br class="">
@@ -76,32 +77,33 @@ static FrontendAction *CreateFrontendBas<br class="">
return nullptr;<br class="">
}<br class="">
<br class="">
- case PrintDeclContext: return new DeclContextPrintAction();<br class="">
- case PrintPreamble: return new PrintPreambleAction();<br class="">
+ case PrintDeclContext: return llvm::make_unique<DeclContextPrintAction>();<br class="">
+ case PrintPreamble: return llvm::make_unique<PrintPreambleAction>();<br class="">
case PrintPreprocessedInput: {<br class="">
if (CI.getPreprocessorOutputOpts().RewriteIncludes)<br class="">
- return new RewriteIncludesAction();<br class="">
- return new PrintPreprocessedAction();<br class="">
+ return llvm::make_unique<RewriteIncludesAction>();<br class="">
+ return llvm::make_unique<PrintPreprocessedAction>();<br class="">
}<br class="">
<br class="">
- case RewriteMacros: return new RewriteMacrosAction();<br class="">
- case RewriteTest: return new RewriteTestAction();<br class="">
+ case RewriteMacros: return llvm::make_unique<RewriteMacrosAction>();<br class="">
+ case RewriteTest: return llvm::make_unique<RewriteTestAction>();<br class="">
#ifdef CLANG_ENABLE_OBJC_REWRITER<br class="">
- case RewriteObjC: return new RewriteObjCAction();<br class="">
+ case RewriteObjC: return llvm::make_unique<RewriteObjCAction>();<br class="">
#else<br class="">
case RewriteObjC: Action = "RewriteObjC"; break;<br class="">
#endif<br class="">
#ifdef CLANG_ENABLE_ARCMT<br class="">
- case MigrateSource: return new arcmt::MigrateSourceAction();<br class="">
+ case MigrateSource:<br class="">
+ return llvm::make_unique<arcmt::MigrateSourceAction>();<br class="">
#else<br class="">
case MigrateSource: Action = "MigrateSource"; break;<br class="">
#endif<br class="">
#ifdef CLANG_ENABLE_STATIC_ANALYZER<br class="">
- case RunAnalysis: return new ento::AnalysisAction();<br class="">
+ case RunAnalysis: return llvm::make_unique<ento::AnalysisAction>();<br class="">
#else<br class="">
case RunAnalysis: Action = "RunAnalysis"; break;<br class="">
#endif<br class="">
- case RunPreprocessorOnly: return new PreprocessOnlyAction();<br class="">
+ case RunPreprocessorOnly: return llvm::make_unique<PreprocessOnlyAction>();<br class="">
}<br class="">
<br class="">
#if !defined(CLANG_ENABLE_ARCMT) || !defined(CLANG_ENABLE_STATIC_ANALYZER) \<br class="">
@@ -113,16 +115,17 @@ static FrontendAction *CreateFrontendBas<br class="">
#endif<br class="">
}<br class="">
<br class="">
-static FrontendAction *CreateFrontendAction(CompilerInstance &CI) {<br class="">
+static std::unique_ptr<FrontendAction><br class="">
+CreateFrontendAction(CompilerInstance &CI) {<br class="">
// Create the underlying action.<br class="">
- FrontendAction *Act = CreateFrontendBaseAction(CI);<br class="">
+ std::unique_ptr<FrontendAction> Act = CreateFrontendBaseAction(CI);<br class="">
if (!Act)<br class="">
return nullptr;<br class="">
<br class="">
const FrontendOptions &FEOpts = CI.getFrontendOpts();<br class="">
<br class="">
if (FEOpts.FixAndRecompile) {<br class="">
- Act = new FixItRecompile(Act);<br class="">
+ Act = llvm::make_unique<FixItRecompile>(std::move(Act));<br class="">
}<br class="">
<br class="">
#ifdef CLANG_ENABLE_ARCMT<br class="">
@@ -133,13 +136,13 @@ static FrontendAction *CreateFrontendAct<br class="">
case FrontendOptions::ARCMT_None:<br class="">
break;<br class="">
case FrontendOptions::ARCMT_Check:<br class="">
- Act = new arcmt::CheckAction(Act);<br class="">
+ Act = llvm::make_unique<arcmt::CheckAction>(std::move(Act));<br class="">
break;<br class="">
case FrontendOptions::ARCMT_Modify:<br class="">
- Act = new arcmt::ModifyAction(Act);<br class="">
+ Act = llvm::make_unique<arcmt::ModifyAction>(std::move(Act));<br class="">
break;<br class="">
case FrontendOptions::ARCMT_Migrate:<br class="">
- Act = new arcmt::MigrateAction(Act,<br class="">
+ Act = llvm::make_unique<arcmt::MigrateAction>(std::move(Act),<br class="">
FEOpts.MTMigrateDir,<br class="">
FEOpts.ARCMTMigrateReportOut,<br class="">
FEOpts.ARCMTMigrateEmitARCErrors);<br class="">
@@ -147,8 +150,9 @@ static FrontendAction *CreateFrontendAct<br class="">
}<br class="">
<br class="">
if (FEOpts.ObjCMTAction != FrontendOptions::ObjCMT_None) {<br class="">
- Act = new arcmt::ObjCMigrateAction(Act, FEOpts.MTMigrateDir,<br class="">
- FEOpts.ObjCMTAction);<br class="">
+ Act = llvm::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),<br class="">
+ FEOpts.MTMigrateDir,<br class="">
+ FEOpts.ObjCMTAction);<br class="">
}<br class="">
}<br class="">
#endif<br class="">
@@ -156,7 +160,8 @@ static FrontendAction *CreateFrontendAct<br class="">
// If there are any AST files to merge, create a frontend action<br class="">
// adaptor to perform the merge.<br class="">
if (!FEOpts.ASTMergeFiles.empty())<br class="">
- Act = new ASTMergeAction(Act, FEOpts.ASTMergeFiles);<br class="">
+ Act = llvm::make_unique<ASTMergeAction>(std::move(Act),<br class="">
+ FEOpts.ASTMergeFiles);<br class="">
<br class="">
return Act;<br class="">
}<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
cfe-commits mailing list<br class="">
<a href="mailto:cfe-commits@lists.llvm.org" class="">cfe-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>