diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/include/clang/Driver/Driver.h | 2 | ||||
-rw-r--r-- | clang/include/clang/Driver/Options.h | 4 | ||||
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Driver/DriverOptions.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 2 | ||||
-rw-r--r-- | clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Tooling/Tooling.cpp | 2 |
7 files changed, 16 insertions, 16 deletions
diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 0ce461ca61e..a5e0d5387d0 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -62,7 +62,7 @@ enum LTOKind { /// Driver - Encapsulate logic for constructing compilation processes /// from a set of gcc-driver-like command line arguments. class Driver { - llvm::opt::OptTable *Opts; + std::unique_ptr<llvm::opt::OptTable> Opts; DiagnosticsEngine &Diags; diff --git a/clang/include/clang/Driver/Options.h b/clang/include/clang/Driver/Options.h index 2716fa9ae85..e9d9000918c 100644 --- a/clang/include/clang/Driver/Options.h +++ b/clang/include/clang/Driver/Options.h @@ -10,6 +10,8 @@ #ifndef LLVM_CLANG_DRIVER_OPTIONS_H #define LLVM_CLANG_DRIVER_OPTIONS_H +#include <memory> + namespace llvm { namespace opt { class OptTable; @@ -44,7 +46,7 @@ enum ID { }; } -llvm::opt::OptTable *createDriverOptTable(); +std::unique_ptr<llvm::opt::OptTable> createDriverOptTable(); } } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 15f830d029e..729209cf509 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -86,8 +86,6 @@ Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple, } Driver::~Driver() { - delete Opts; - llvm::DeleteContainerSeconds(ToolChains); } @@ -214,9 +212,9 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL, return FinalPhase; } -static Arg *MakeInputArg(DerivedArgList &Args, OptTable *Opts, +static Arg *MakeInputArg(DerivedArgList &Args, OptTable &Opts, StringRef Value) { - Arg *A = new Arg(Opts->getOption(options::OPT_INPUT), Value, + Arg *A = new Arg(Opts.getOption(options::OPT_INPUT), Value, Args.getBaseArgs().MakeIndex(Value), Value.data()); Args.AddSynthesizedArg(A); A->claim(); @@ -287,7 +285,7 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { if (A->getOption().matches(options::OPT__DASH_DASH)) { A->claim(); for (StringRef Val : A->getValues()) - DAL->append(MakeInputArg(*DAL, Opts, Val)); + DAL->append(MakeInputArg(*DAL, *Opts, Val)); continue; } @@ -1561,14 +1559,14 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, } else if (A->getOption().matches(options::OPT__SLASH_Tc)) { StringRef Value = A->getValue(); if (DiagnoseInputExistence(*this, Args, Value, types::TY_C)) { - Arg *InputArg = MakeInputArg(Args, Opts, A->getValue()); + Arg *InputArg = MakeInputArg(Args, *Opts, A->getValue()); Inputs.push_back(std::make_pair(types::TY_C, InputArg)); } A->claim(); } else if (A->getOption().matches(options::OPT__SLASH_Tp)) { StringRef Value = A->getValue(); if (DiagnoseInputExistence(*this, Args, Value, types::TY_CXX)) { - Arg *InputArg = MakeInputArg(Args, Opts, A->getValue()); + Arg *InputArg = MakeInputArg(Args, *Opts, A->getValue()); Inputs.push_back(std::make_pair(types::TY_CXX, InputArg)); } A->claim(); @@ -1594,7 +1592,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args, if (CCCIsCPP() && Inputs.empty()) { // If called as standalone preprocessor, stdin is processed // if no other input is present. - Arg *A = MakeInputArg(Args, Opts, "-"); + Arg *A = MakeInputArg(Args, *Opts, "-"); Inputs.push_back(std::make_pair(types::TY_C, A)); } } @@ -2497,7 +2495,7 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args, const types::ID HeaderType = lookupHeaderTypeForSourceType(InputType); llvm::SmallVector<phases::ID, phases::MaxNumberOfPhases> PCHPL; types::getCompilationPhases(HeaderType, PCHPL); - Arg *PchInputArg = MakeInputArg(Args, Opts, YcArg->getValue()); + Arg *PchInputArg = MakeInputArg(Args, *Opts, YcArg->getValue()); // Build the pipeline for the pch file. Action *ClangClPch = diff --git a/clang/lib/Driver/DriverOptions.cpp b/clang/lib/Driver/DriverOptions.cpp index 8d5332b5cc2..6a7410901d2 100644 --- a/clang/lib/Driver/DriverOptions.cpp +++ b/clang/lib/Driver/DriverOptions.cpp @@ -39,6 +39,6 @@ public: } -OptTable *clang::driver::createDriverOptTable() { - return new DriverOptTable(); +std::unique_ptr<OptTable> clang::driver::createDriverOptTable() { + return llvm::make_unique<DriverOptTable>(); } diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 36f6b0a5111..2db6e0c4957 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2405,7 +2405,7 @@ bool CompilerInvocation::CreateFromArgs(CompilerInvocation &Res, bool Success = true; // Parse the arguments. - std::unique_ptr<OptTable> Opts(createDriverOptTable()); + std::unique_ptr<OptTable> Opts = createDriverOptTable(); const unsigned IncludedFlagsBitmask = options::CC1Option; unsigned MissingArgIndex, MissingArgCount; InputArgList Args = diff --git a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 187a6e76245..1f7493c9e39 100644 --- a/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -174,7 +174,7 @@ CreateFrontendAction(CompilerInstance &CI) { bool clang::ExecuteCompilerInvocation(CompilerInstance *Clang) { // Honor -help. if (Clang->getFrontendOpts().ShowHelp) { - std::unique_ptr<OptTable> Opts(driver::createDriverOptTable()); + std::unique_ptr<OptTable> Opts = driver::createDriverOptTable(); Opts->PrintHelp(llvm::outs(), "clang -cc1", "LLVM 'Clang' Compiler: http://clang.llvm.org", /*Include=*/ driver::options::CC1Option, /*Exclude=*/ 0); diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index 25cee98078f..9e1181281f1 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -244,7 +244,7 @@ bool ToolInvocation::run() { const char *const BinaryName = Argv[0]; IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions(); unsigned MissingArgIndex, MissingArgCount; - std::unique_ptr<llvm::opt::OptTable> Opts(driver::createDriverOptTable()); + std::unique_ptr<llvm::opt::OptTable> Opts = driver::createDriverOptTable(); llvm::opt::InputArgList ParsedArgs = Opts->ParseArgs( ArrayRef<const char *>(Argv).slice(1), MissingArgIndex, MissingArgCount); ParseDiagnosticArgs(*DiagOpts, ParsedArgs); |