Driver: Use pointee_iterator rather than iterating over unique_ptrs
There's probably never a good reason to iterate over unique_ptrs. This
lets us use range-for and say Job.foo instead of (*it)->foo in a few
places.
llvm-svn: 218938
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index f16f647..7613988 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -249,10 +249,9 @@
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)
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index aa72f63..7109584 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -69,7 +69,7 @@
// 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);
@@ -80,7 +80,7 @@
// 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;