r217168 - unique_ptrify JobList::Jobs
David Blaikie
dblaikie at gmail.com
Thu Sep 4 09:04:28 PDT 2014
Author: dblaikie
Date: Thu Sep 4 11:04:28 2014
New Revision: 217168
URL: http://llvm.org/viewvc/llvm-project?rev=217168&view=rev
Log:
unique_ptrify JobList::Jobs
Modified:
cfe/trunk/examples/clang-interpreter/main.cpp
cfe/trunk/include/clang/Driver/Compilation.h
cfe/trunk/include/clang/Driver/Job.h
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/lib/Driver/Tools.h
cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
cfe/trunk/lib/Tooling/CompilationDatabase.cpp
cfe/trunk/lib/Tooling/Tooling.cpp
Modified: cfe/trunk/examples/clang-interpreter/main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/clang-interpreter/main.cpp?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/examples/clang-interpreter/main.cpp (original)
+++ cfe/trunk/examples/clang-interpreter/main.cpp Thu Sep 4 11:04:28 2014
@@ -111,7 +111,7 @@ int main(int argc, const char **argv, ch
// We expect to get back exactly one command job, if we didn't something
// failed. Extract that job from the compilation.
const driver::JobList &Jobs = C->getJobs();
- if (Jobs.size() != 1 || !isa<driver::Command>(*Jobs.begin())) {
+ if (Jobs.size() != 1 || !isa<driver::Command>(**Jobs.begin())) {
SmallString<256> Msg;
llvm::raw_svector_ostream OS(Msg);
Jobs.Print(OS, "; ", true);
@@ -119,14 +119,14 @@ int main(int argc, const char **argv, ch
return 1;
}
- const driver::Command *Cmd = cast<driver::Command>(*Jobs.begin());
- if (llvm::StringRef(Cmd->getCreator().getName()) != "clang") {
+ const driver::Command &Cmd = cast<driver::Command>(**Jobs.begin());
+ if (llvm::StringRef(Cmd.getCreator().getName()) != "clang") {
Diags.Report(diag::err_fe_expected_clang_command);
return 1;
}
// Initialize a compiler invocation object from the clang (-cc1) arguments.
- const driver::ArgStringList &CCArgs = Cmd->getArguments();
+ const driver::ArgStringList &CCArgs = Cmd.getArguments();
std::unique_ptr<CompilerInvocation> CI(new CompilerInvocation);
CompilerInvocation::CreateFromArgs(*CI,
const_cast<const char **>(CCArgs.data()),
Modified: cfe/trunk/include/clang/Driver/Compilation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Compilation.h?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Compilation.h (original)
+++ cfe/trunk/include/clang/Driver/Compilation.h Thu Sep 4 11:04:28 2014
@@ -94,7 +94,7 @@ public:
JobList &getJobs() { return Jobs; }
const JobList &getJobs() const { return Jobs; }
- void addCommand(Command *C) { Jobs.addJob(C); }
+ void addCommand(std::unique_ptr<Command> C) { Jobs.addJob(std::move(C)); }
const llvm::opt::ArgStringList &getTempFiles() const { return TempFiles; }
Modified: cfe/trunk/include/clang/Driver/Job.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Job.h?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Job.h (original)
+++ cfe/trunk/include/clang/Driver/Job.h Thu Sep 4 11:04:28 2014
@@ -104,7 +104,7 @@ class FallbackCommand : public Command {
public:
FallbackCommand(const Action &Source_, const Tool &Creator_,
const char *Executable_, const ArgStringList &Arguments_,
- Command *Fallback_);
+ std::unique_ptr<Command> Fallback_);
void Print(llvm::raw_ostream &OS, const char *Terminator, bool Quote,
bool CrashReport = false) const override;
@@ -123,7 +123,7 @@ private:
/// JobList - A sequence of jobs to perform.
class JobList : public Job {
public:
- typedef SmallVector<Job*, 4> list_type;
+ typedef SmallVector<std::unique_ptr<Job>, 4> list_type;
typedef list_type::size_type size_type;
typedef list_type::iterator iterator;
typedef list_type::const_iterator const_iterator;
@@ -133,13 +133,13 @@ private:
public:
JobList();
- virtual ~JobList();
+ virtual ~JobList() {}
void Print(llvm::raw_ostream &OS, const char *Terminator,
bool Quote, bool CrashReport = false) const override;
/// Add a job to the list (taking ownership).
- void addJob(Job *J) { Jobs.push_back(J); }
+ void addJob(std::unique_ptr<Job> J) { Jobs.push_back(std::move(J)); }
/// Clear the job list.
void clear();
Modified: cfe/trunk/lib/Driver/Job.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Thu Sep 4 11:04:28 2014
@@ -136,9 +136,9 @@ int Command::Execute(const StringRef **R
FallbackCommand::FallbackCommand(const Action &Source_, const Tool &Creator_,
const char *Executable_,
const ArgStringList &Arguments_,
- Command *Fallback_)
- : Command(Source_, Creator_, Executable_, Arguments_), Fallback(Fallback_) {
-}
+ std::unique_ptr<Command> Fallback_)
+ : Command(Source_, Creator_, Executable_, Arguments_),
+ Fallback(std::move(Fallback_)) {}
void FallbackCommand::Print(raw_ostream &OS, const char *Terminator,
bool Quote, bool CrashReport) const {
@@ -175,17 +175,10 @@ int FallbackCommand::Execute(const Strin
JobList::JobList() : Job(JobListClass) {}
-JobList::~JobList() {
- for (iterator it = begin(), ie = end(); it != ie; ++it)
- delete *it;
-}
-
void JobList::Print(raw_ostream &OS, const char *Terminator, bool Quote,
bool CrashReport) const {
for (const_iterator it = begin(), ie = end(); it != ie; ++it)
(*it)->Print(OS, Terminator, Quote, CrashReport);
}
-void JobList::clear() {
- DeleteContainerPointers(Jobs);
-}
+void JobList::clear() { Jobs.clear(); }
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Sep 4 11:04:28 2014
@@ -2391,10 +2391,10 @@ static void SplitDebugInfo(const ToolCha
Args.MakeArgString(TC.GetProgramPath("objcopy"));
// First extract the dwo sections.
- C.addCommand(new Command(JA, T, Exec, ExtractArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, T, Exec, ExtractArgs));
// Then remove them from the original .o file.
- C.addCommand(new Command(JA, T, Exec, StripArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, T, Exec, StripArgs));
}
/// \brief Vectorize at all optimization levels greater than 1 except for -Oz.
@@ -4475,11 +4475,12 @@ void Clang::ConstructJob(Compilation &C,
if (Args.hasArg(options::OPT__SLASH_fallback) &&
Output.getType() == types::TY_Object &&
(InputType == types::TY_C || InputType == types::TY_CXX)) {
- Command *CLCommand = getCLFallback()->GetCommand(C, JA, Output, Inputs,
- Args, LinkingOutput);
- C.addCommand(new FallbackCommand(JA, *this, Exec, CmdArgs, CLCommand));
+ auto CLCommand =
+ getCLFallback()->GetCommand(C, JA, Output, Inputs, Args, LinkingOutput);
+ C.addCommand(llvm::make_unique<FallbackCommand>(JA, *this, Exec, CmdArgs,
+ std::move(CLCommand)));
} else {
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
@@ -4914,7 +4915,7 @@ void ClangAs::ConstructJob(Compilation &
CmdArgs.push_back(Input.getFilename());
const char *Exec = getToolChain().getDriver().getClangProgramPath();
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
// Handle the debug info splitting at object creation time if we're
// creating an object.
@@ -5039,7 +5040,7 @@ void gcc::Common::ConstructJob(Compilati
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void gcc::Preprocess::RenderExtraToolArgs(const JobAction &JA,
@@ -5135,7 +5136,7 @@ void hexagon::Assemble::ConstructJob(Com
const char *GCCName = "hexagon-as";
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(GCCName));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void hexagon::Link::RenderExtraToolArgs(const JobAction &JA,
@@ -5301,7 +5302,8 @@ void hexagon::Link::ConstructJob(Compila
}
std::string Linker = ToolChain.GetProgramPath("hexagon-ld");
- C.addCommand(new Command(JA, *this, Args.MakeArgString(Linker), CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Args.MakeArgString(Linker),
+ CmdArgs));
}
// Hexagon tools end.
@@ -5562,7 +5564,7 @@ void darwin::Assemble::ConstructJob(Comp
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void darwin::MachOTool::anchor() {}
@@ -5791,7 +5793,7 @@ void darwin::Link::ConstructJob(Compilat
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("touch"));
CmdArgs.push_back(Output.getFilename());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
return;
}
@@ -5889,7 +5891,7 @@ void darwin::Link::ConstructJob(Compilat
const char *Exec =
Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA,
@@ -5911,7 +5913,7 @@ void darwin::Lipo::ConstructJob(Compilat
}
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("lipo"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void darwin::Dsymutil::ConstructJob(Compilation &C, const JobAction &JA,
@@ -5931,7 +5933,7 @@ void darwin::Dsymutil::ConstructJob(Comp
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("dsymutil"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void darwin::VerifyDebug::ConstructJob(Compilation &C, const JobAction &JA,
@@ -5954,7 +5956,7 @@ void darwin::VerifyDebug::ConstructJob(C
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("dwarfdump"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void solaris::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
@@ -5974,7 +5976,7 @@ void solaris::Assemble::ConstructJob(Com
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void solaris::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6079,7 +6081,7 @@ void solaris::Link::ConstructJob(Compila
const char *Exec =
Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6149,7 +6151,7 @@ void openbsd::Assemble::ConstructJob(Com
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6281,7 +6283,7 @@ void openbsd::Link::ConstructJob(Compila
const char *Exec =
Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void bitrig::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6301,7 +6303,7 @@ void bitrig::Assemble::ConstructJob(Comp
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void bitrig::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6417,7 +6419,7 @@ void bitrig::Link::ConstructJob(Compilat
const char *Exec =
Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6498,7 +6500,7 @@ void freebsd::Assemble::ConstructJob(Com
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6681,7 +6683,7 @@ void freebsd::Link::ConstructJob(Compila
const char *Exec =
Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void netbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6755,7 +6757,7 @@ void netbsd::Assemble::ConstructJob(Comp
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString((getToolChain().GetProgramPath("as")));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void netbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -6963,7 +6965,7 @@ void netbsd::Link::ConstructJob(Compilat
addProfileRT(getToolChain(), Args, CmdArgs);
const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void gnutools::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7136,7 +7138,7 @@ void gnutools::Assemble::ConstructJob(Co
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
// Handle the debug info splitting at object creation time if we're
// creating an object.
@@ -7514,7 +7516,8 @@ void gnutools::Link::ConstructJob(Compil
}
}
- C.addCommand(new Command(JA, *this, ToolChain.Linker.c_str(), CmdArgs));
+ C.addCommand(
+ llvm::make_unique<Command>(JA, *this, ToolChain.Linker.c_str(), CmdArgs));
}
void minix::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7533,7 +7536,7 @@ void minix::Assemble::ConstructJob(Compi
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void minix::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7587,7 +7590,7 @@ void minix::Link::ConstructJob(Compilati
}
const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
/// DragonFly Tools
@@ -7615,7 +7618,7 @@ void dragonfly::Assemble::ConstructJob(C
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7765,7 +7768,7 @@ void dragonfly::Link::ConstructJob(Compi
addProfileRT(getToolChain(), Args, CmdArgs);
const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath());
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
static void addSanitizerRTWindows(const ToolChain &TC, const ArgList &Args,
@@ -7842,7 +7845,7 @@ void visualstudio::Link::ConstructJob(Co
const char *Exec =
Args.MakeArgString(getToolChain().GetProgramPath("link.exe"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void visualstudio::Compile::ConstructJob(Compilation &C, const JobAction &JA,
@@ -7882,11 +7885,10 @@ static std::string FindFallback(const ch
return FallbackName;
}
-Command *visualstudio::Compile::GetCommand(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &Args,
- const char *LinkingOutput) const {
+std::unique_ptr<Command> visualstudio::Compile::GetCommand(
+ Compilation &C, const JobAction &JA, const InputInfo &Output,
+ const InputInfoList &Inputs, const ArgList &Args,
+ const char *LinkingOutput) const {
ArgStringList CmdArgs;
CmdArgs.push_back("/nologo");
CmdArgs.push_back("/c"); // Compile only.
@@ -7965,7 +7967,8 @@ Command *visualstudio::Compile::GetComma
const Driver &D = getToolChain().getDriver();
std::string Exec = FindFallback("cl.exe", D.getClangProgramPath());
- return new Command(JA, *this, Args.MakeArgString(Exec), CmdArgs);
+ return llvm::make_unique<Command>(JA, *this, Args.MakeArgString(Exec),
+ CmdArgs);
}
@@ -8002,7 +8005,7 @@ void XCore::Assemble::ConstructJob(Compi
CmdArgs.push_back(II.getFilename());
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
void XCore::Link::ConstructJob(Compilation &C, const JobAction &JA,
@@ -8029,5 +8032,5 @@ void XCore::Link::ConstructJob(Compilati
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc"));
- C.addCommand(new Command(JA, *this, Exec, CmdArgs));
+ C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs));
}
Modified: cfe/trunk/lib/Driver/Tools.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.h (original)
+++ cfe/trunk/lib/Driver/Tools.h Thu Sep 4 11:04:28 2014
@@ -584,11 +584,11 @@ namespace visualstudio {
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
- Command *GetCommand(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const llvm::opt::ArgList &TCArgs,
- const char *LinkingOutput) const;
+ std::unique_ptr<Command> GetCommand(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const llvm::opt::ArgList &TCArgs,
+ const char *LinkingOutput) const;
};
} // end namespace visualstudio
Modified: cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp (original)
+++ cfe/trunk/lib/Frontend/CreateInvocationFromCommandLine.cpp Thu Sep 4 11:04:28 2014
@@ -63,7 +63,7 @@ clang::createInvocationFromCommandLine(A
// We expect to get back exactly one command job, if we didn't something
// failed.
const driver::JobList &Jobs = C->getJobs();
- if (Jobs.size() != 1 || !isa<driver::Command>(*Jobs.begin())) {
+ if (Jobs.size() != 1 || !isa<driver::Command>(**Jobs.begin())) {
SmallString<256> Msg;
llvm::raw_svector_ostream OS(Msg);
Jobs.Print(OS, "; ", true);
@@ -71,13 +71,13 @@ clang::createInvocationFromCommandLine(A
return nullptr;
}
- const driver::Command *Cmd = cast<driver::Command>(*Jobs.begin());
- if (StringRef(Cmd->getCreator().getName()) != "clang") {
+ const driver::Command &Cmd = cast<driver::Command>(**Jobs.begin());
+ if (StringRef(Cmd.getCreator().getName()) != "clang") {
Diags->Report(diag::err_fe_expected_clang_command);
return nullptr;
}
- const ArgStringList &CCArgs = Cmd->getArguments();
+ const ArgStringList &CCArgs = Cmd.getArguments();
std::unique_ptr<CompilerInvocation> CI(new CompilerInvocation());
if (!CompilerInvocation::CreateFromArgs(*CI,
const_cast<const char **>(CCArgs.data()),
Modified: cfe/trunk/lib/Tooling/CompilationDatabase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/CompilationDatabase.cpp?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/CompilationDatabase.cpp (original)
+++ cfe/trunk/lib/Tooling/CompilationDatabase.cpp Thu Sep 4 11:04:28 2014
@@ -252,11 +252,11 @@ static bool stripPositionalArgs(std::vec
for (driver::JobList::const_iterator I = Jobs.begin(), E = Jobs.end(); I != E;
++I) {
if ((*I)->getKind() == driver::Job::CommandClass) {
- const driver::Command *Cmd = cast<driver::Command>(*I);
+ const driver::Command &Cmd = cast<driver::Command>(**I);
// Collect only for Assemble jobs. If we do all jobs we get duplicates
// since Link jobs point to Assemble jobs as inputs.
- if (Cmd->getSource().getKind() == driver::Action::AssembleJobClass)
- CompileAnalyzer.run(&Cmd->getSource());
+ if (Cmd.getSource().getKind() == driver::Action::AssembleJobClass)
+ CompileAnalyzer.run(&Cmd.getSource());
}
}
Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=217168&r1=217167&r2=217168&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Thu Sep 4 11:04:28 2014
@@ -69,7 +69,7 @@ static const llvm::opt::ArgStringList *g
// We expect to get back exactly one Command job, if we didn't something
// failed. Extract that job from the Compilation.
const clang::driver::JobList &Jobs = Compilation->getJobs();
- if (Jobs.size() != 1 || !isa<clang::driver::Command>(*Jobs.begin())) {
+ if (Jobs.size() != 1 || !isa<clang::driver::Command>(**Jobs.begin())) {
SmallString<256> error_msg;
llvm::raw_svector_ostream error_stream(error_msg);
Jobs.Print(error_stream, "; ", true);
@@ -79,14 +79,14 @@ static const llvm::opt::ArgStringList *g
}
// The one job we find should be to invoke clang again.
- const clang::driver::Command *Cmd =
- cast<clang::driver::Command>(*Jobs.begin());
- if (StringRef(Cmd->getCreator().getName()) != "clang") {
+ const clang::driver::Command &Cmd =
+ cast<clang::driver::Command>(**Jobs.begin());
+ if (StringRef(Cmd.getCreator().getName()) != "clang") {
Diagnostics->Report(clang::diag::err_fe_expected_clang_command);
return nullptr;
}
- return &Cmd->getArguments();
+ return &Cmd.getArguments();
}
/// \brief Returns a clang build invocation initialized from the CC1 flags.
More information about the cfe-commits
mailing list