diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-07-01 19:02:28 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-07-01 19:02:28 +0000 |
commit | cae087e164e94e4286c11bf694dd0ff88f295302 (patch) | |
tree | ac70032590c62a21da250b32a40366102a2067b7 | |
parent | 4d374d4a4832a01d5d3b75c59cb1567e60df41e7 (diff) |
Driver: Add Source argument for Commands to hold the Action which caused a
Command to be generated, to support more advanced diagnostics.
- No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@74627 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Driver/Job.h | 10 | ||||
-rw-r--r-- | lib/Driver/Job.cpp | 6 | ||||
-rw-r--r-- | lib/Driver/Tools.cpp | 28 |
3 files changed, 27 insertions, 17 deletions
diff --git a/include/clang/Driver/Job.h b/include/clang/Driver/Job.h index f60f514641..a23babdbb3 100644 --- a/include/clang/Driver/Job.h +++ b/include/clang/Driver/Job.h @@ -52,6 +52,9 @@ public: /// Command - An executable path/name and argument vector to /// execute. class Command : public Job { + /// Source - The action which caused the creation of this job. + const Action &Source; + /// The executable to run. const char *Executable; @@ -60,9 +63,14 @@ class Command : public Job { ArgStringList Arguments; public: - Command(const char *_Executable, const ArgStringList &_Arguments); + Command(const Action &_Source, const char *_Executable, + const ArgStringList &_Arguments); + + /// getSource - Return the Action which caused the creation of this job. + const Action &getSource() const { return Source; } const char *getExecutable() const { return Executable; } + const ArgStringList &getArguments() const { return Arguments; } static bool classof(const Job *J) { diff --git a/lib/Driver/Job.cpp b/lib/Driver/Job.cpp index 222cf15db6..1b0ea18453 100644 --- a/lib/Driver/Job.cpp +++ b/lib/Driver/Job.cpp @@ -14,8 +14,10 @@ using namespace clang::driver; Job::~Job() {} -Command::Command(const char *_Executable, const ArgStringList &_Arguments) - : Job(CommandClass), Executable(_Executable), Arguments(_Arguments) { +Command::Command(const Action &_Source, const char *_Executable, + const ArgStringList &_Arguments) + : Job(CommandClass), Source(_Source), Executable(_Executable), + Arguments(_Arguments) { } PipedJob::PipedJob() : Job(PipedJobClass) {} diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index aaec0b4c8a..d198a54cf7 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -628,7 +628,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "clang-cc").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); // Explicitly warn that these options are unsupported, even though // we are allowing compilation to continue. @@ -759,7 +759,7 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA, getToolChain().getHost().getDriver().CCCGenericGCCName.c_str(); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, GCCName).c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void gcc::Preprocess::RenderExtraToolArgs(ArgStringList &CmdArgs) const { @@ -1135,7 +1135,7 @@ void darwin::Preprocess::ConstructJob(Compilation &C, const JobAction &JA, const char *CC1Name = getCC1Name(Inputs[0].getType()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name).c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA, @@ -1223,7 +1223,7 @@ void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA, const char *CC1Name = getCC1Name(Inputs[0].getType()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, CC1Name).c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, @@ -1276,7 +1276,7 @@ void darwin::Assemble::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "as").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } /// Helper routine for seeing if we should use dsymutil; this is a @@ -1700,7 +1700,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); // Find the first non-empty base input (we want to ignore linker // inputs). @@ -1730,7 +1730,7 @@ void darwin::Link::ConstructJob(Compilation &C, const JobAction &JA, Args.MakeArgString(getToolChain().GetProgramPath(C, "dsymutil").c_str()); ArgStringList CmdArgs; CmdArgs.push_back(Output.getFilename()); - C.getJobs().addCommand(new Command(Exec, CmdArgs)); + C.getJobs().addCommand(new Command(JA, Exec, CmdArgs)); } } } @@ -1756,7 +1756,7 @@ void darwin::Lipo::ConstructJob(Compilation &C, const JobAction &JA, } const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "lipo").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, @@ -1787,7 +1787,7 @@ void openbsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "as").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA, @@ -1869,7 +1869,7 @@ void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, @@ -1905,7 +1905,7 @@ void freebsd::Assemble::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "as").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, @@ -2016,7 +2016,7 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } /// DragonFly Tools @@ -2055,7 +2055,7 @@ void dragonfly::Assemble::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "as").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, @@ -2179,5 +2179,5 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(C, "ld").c_str()); - Dest.addCommand(new Command(Exec, CmdArgs)); + Dest.addCommand(new Command(JA, Exec, CmdArgs)); } |