unique_ptrify createDriverOptTable

llvm-svn: 291919
This commit is contained in:
David Blaikie 2017-01-13 17:34:15 +00:00
parent 10527a9253
commit 0aaa7625e1
7 changed files with 16 additions and 16 deletions

View file

@ -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;

View file

@ -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();
}
}

View file

@ -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 =

View file

@ -39,6 +39,6 @@ public:
}
OptTable *clang::driver::createDriverOptTable() {
return new DriverOptTable();
std::unique_ptr<OptTable> clang::driver::createDriverOptTable() {
return llvm::make_unique<DriverOptTable>();
}

View file

@ -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 =

View file

@ -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);

View file

@ -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);