#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Option/Option.h"
+#include "llvm/ADT/iterator.h"
#include <memory>
namespace llvm {
public:
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;
+ typedef llvm::pointee_iterator<list_type::iterator> iterator;
+ typedef llvm::pointee_iterator<list_type::const_iterator> const_iterator;
private:
list_type Jobs;
FailingCommands.push_back(std::make_pair(Res, FailingCommand));
} else {
const JobList *Jobs = cast<JobList>(&J);
- for (JobList::const_iterator it = Jobs->begin(), ie = Jobs->end();
- it != ie; ++it)
- ExecuteJob(**it, FailingCommands);
+ for (const auto &Job : *Jobs)
+ ExecuteJob(Job, FailingCommands);
}
}
void Driver::setUpResponseFiles(Compilation &C, Job &J) {
if (JobList *Jobs = dyn_cast<JobList>(&J)) {
- for (JobList::iterator I = Jobs->begin(), E = Jobs->end(); I != E; ++I)
- setUpResponseFiles(C, **I);
+ for (auto &Job : *Jobs)
+ setUpResponseFiles(C, Job);
return;
}
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);
+ for (const auto &Job : *this)
+ Job.Print(OS, Terminator, Quote, CrashReport);
}
void JobList::clear() { Jobs.clear(); }
// 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);
return nullptr;
}
- const driver::Command &Cmd = cast<driver::Command>(**Jobs.begin());
+ 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;
CompileJobAnalyzer CompileAnalyzer;
- 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);
+ 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)
// 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);
// The one job we find should be to invoke clang again.
const clang::driver::Command &Cmd =
- cast<clang::driver::Command>(**Jobs.begin());
+ cast<clang::driver::Command>(*Jobs.begin());
if (StringRef(Cmd.getCreator().getName()) != "clang") {
Diagnostics->Report(clang::diag::err_fe_expected_clang_command);
return nullptr;