diff options
author | Justin Bogner <mail@justinbogner.com> | 2015-07-02 22:52:08 +0000 |
---|---|---|
committer | Justin Bogner <mail@justinbogner.com> | 2015-07-02 22:52:08 +0000 |
commit | 0cd9248d9e1c4a35ea7633a11de3fb394b48f452 (patch) | |
tree | 1230089592673217be3821c094d26745ae06d150 /clang/lib | |
parent | 94817612e2b45c3e447399359aa117f386ab58c4 (diff) | |
download | bcm5719-llvm-0cd9248d9e1c4a35ea7633a11de3fb394b48f452.tar.gz bcm5719-llvm-0cd9248d9e1c4a35ea7633a11de3fb394b48f452.zip |
Driver: Remove the Job class. NFC
We had a strange relationship here where we made a list of Jobs
inherit from a single Job, but there weren't actually any places where
this arbitrary nesting was used or needed.
Simplify all of this by removing Job entirely and updating all of the
users to either work with a JobList or a single Command.
llvm-svn: 241310
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Driver/Compilation.cpp | 16 | ||||
-rw-r--r-- | clang/lib/Driver/Driver.cpp | 25 | ||||
-rw-r--r-- | clang/lib/Driver/Job.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Tooling/CompilationDatabase.cpp | 13 |
4 files changed, 21 insertions, 41 deletions
diff --git a/clang/lib/Driver/Compilation.cpp b/clang/lib/Driver/Compilation.cpp index 2bcbd5cf943..101d1fcc832 100644 --- a/clang/lib/Driver/Compilation.cpp +++ b/clang/lib/Driver/Compilation.cpp @@ -192,18 +192,14 @@ static bool InputsOk(const Command &C, return !ActionFailed(&C.getSource(), FailingCommands); } -void Compilation::ExecuteJob(const Job &J, - FailingCommandList &FailingCommands) const { - if (const Command *C = dyn_cast<Command>(&J)) { - if (!InputsOk(*C, FailingCommands)) - return; +void Compilation::ExecuteJobs(const JobList &Jobs, + FailingCommandList &FailingCommands) const { + for (const auto &Job : Jobs) { + if (!InputsOk(Job, FailingCommands)) + continue; const Command *FailingCommand = nullptr; - if (int Res = ExecuteCommand(*C, FailingCommand)) + if (int Res = ExecuteCommand(Job, FailingCommand)) FailingCommands.push_back(std::make_pair(Res, FailingCommand)); - } else { - const JobList *Jobs = cast<JobList>(&J); - for (const auto &Job : *Jobs) - ExecuteJob(Job, FailingCommands); } } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index a146ba0f460..b9dc35d6219 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -500,7 +500,7 @@ void Driver::generateCompilationDiagnostics(Compilation &C, // Generate preprocessed output. SmallVector<std::pair<int, const Command *>, 4> FailingCommands; - C.ExecuteJob(C.getJobs(), FailingCommands); + C.ExecuteJobs(C.getJobs(), FailingCommands); // If any of the preprocessing commands failed, clean up and exit. if (!FailingCommands.empty()) { @@ -560,26 +560,16 @@ void Driver::generateCompilationDiagnostics(Compilation &C, << "\n\n********************"; } -void Driver::setUpResponseFiles(Compilation &C, Job &J) { - if (JobList *Jobs = dyn_cast<JobList>(&J)) { - for (auto &Job : *Jobs) - setUpResponseFiles(C, Job); - return; - } - - Command *CurCommand = dyn_cast<Command>(&J); - if (!CurCommand) - return; - +void Driver::setUpResponseFiles(Compilation &C, Command &Cmd) { // Since argumentsFitWithinSystemLimits() may underestimate system's capacity // if the tool does not support response files, there is a chance/ that things // will just work without a response file, so we silently just skip it. - if (CurCommand->getCreator().getResponseFilesSupport() == Tool::RF_None || - llvm::sys::argumentsFitWithinSystemLimits(CurCommand->getArguments())) + if (Cmd.getCreator().getResponseFilesSupport() == Tool::RF_None || + llvm::sys::argumentsFitWithinSystemLimits(Cmd.getArguments())) return; std::string TmpName = GetTemporaryPath("response", "txt"); - CurCommand->setResponseFile( + Cmd.setResponseFile( C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()))); } @@ -597,9 +587,10 @@ int Driver::ExecuteCompilation( return 1; // Set up response file names for each command, if necessary - setUpResponseFiles(C, C.getJobs()); + for (auto &Job : C.getJobs()) + setUpResponseFiles(C, Job); - C.ExecuteJob(C.getJobs(), FailingCommands); + C.ExecuteJobs(C.getJobs(), FailingCommands); // Remove temp files. C.CleanupFileList(C.getTempFiles()); diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp index 4b5b839e524..ac18e1eb56a 100644 --- a/clang/lib/Driver/Job.cpp +++ b/clang/lib/Driver/Job.cpp @@ -25,12 +25,10 @@ using llvm::raw_ostream; using llvm::StringRef; using llvm::ArrayRef; -Job::~Job() {} - Command::Command(const Action &Source, const Tool &Creator, const char *Executable, const ArgStringList &Arguments) - : Job(CommandClass), Source(Source), Creator(Creator), - Executable(Executable), Arguments(Arguments), ResponseFile(nullptr) {} + : Source(Source), Creator(Creator), Executable(Executable), + Arguments(Arguments), ResponseFile(nullptr) {} static int skipArgs(const char *Flag, bool HaveCrashVFS) { // These flags are all of the form -Flag <Arg> and are treated as two @@ -293,8 +291,6 @@ int FallbackCommand::Execute(const StringRef **Redirects, std::string *ErrMsg, return SecondaryStatus; } -JobList::JobList() : Job(JobListClass) {} - void JobList::Print(raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo) const { for (const auto &Job : *this) diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp index 4483b189ca9..2272be632b9 100644 --- a/clang/lib/Tooling/CompilationDatabase.cpp +++ b/clang/lib/Tooling/CompilationDatabase.cpp @@ -250,14 +250,11 @@ static bool stripPositionalArgs(std::vector<const char *> Args, CompileJobAnalyzer CompileAnalyzer; - for (const auto &Job : Jobs) { - if (Job.getKind() == driver::Job::CommandClass) { - const driver::Command &Cmd = cast<driver::Command>(Job); - // 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()); - } + for (const auto &Cmd : Jobs) { + // 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 (CompileAnalyzer.Inputs.empty()) { |