[cfe-commits] r67177 - in /cfe/trunk: include/clang/Driver/Compilation.h lib/Driver/Compilation.cpp

Daniel Dunbar daniel at zuster.org
Tue Mar 17 23:49:39 PDT 2009


Author: ddunbar
Date: Wed Mar 18 01:49:39 2009
New Revision: 67177

URL: http://llvm.org/viewvc/llvm-project?rev=67177&view=rev
Log:
Driver: Implement -### (hard to tell, since we don't actually
construct any jobs).

Modified:
    cfe/trunk/include/clang/Driver/Compilation.h
    cfe/trunk/lib/Driver/Compilation.cpp

Modified: cfe/trunk/include/clang/Driver/Compilation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Compilation.h?rev=67177&r1=67176&r2=67177&view=diff

==============================================================================
--- cfe/trunk/include/clang/Driver/Compilation.h (original)
+++ cfe/trunk/include/clang/Driver/Compilation.h Wed Mar 18 01:49:39 2009
@@ -15,6 +15,10 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 
+namespace llvm {
+  class raw_ostream;
+}
+
 namespace clang {
 namespace driver {
   class ArgList;
@@ -80,6 +84,15 @@
   /// Execute - Execute the compilation jobs and return an
   /// appropriate exit code.
   int Execute() const;
+
+private:
+  /// PrintJob - Print one job in -### format.
+  ///
+  /// OS - The stream to print on.
+  /// J - The job to print.
+  /// Terminator - A string to print at the end of the line.
+  void PrintJob(llvm::raw_ostream &OS, const Job *J, 
+                const char *Terminator) const;
 };
 
 } // end namespace driver

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=67177&r1=67176&r2=67177&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Wed Mar 18 01:49:39 2009
@@ -13,6 +13,7 @@
 #include "clang/Driver/ArgList.h"
 #include "clang/Driver/ToolChain.h"
 
+#include "llvm/Support/raw_ostream.h"
 using namespace clang::driver;
 
 Compilation::Compilation(ToolChain &_DefaultToolChain,
@@ -48,6 +49,32 @@
   return *Entry;
 }
 
+void Compilation::PrintJob(llvm::raw_ostream &OS, const Job *J, 
+                           const char *Terminator) const {
+  if (const Command *C = dyn_cast<Command>(J)) {
+    OS << " \"" << C->getExecutable() << '"';
+    for (ArgStringList::const_iterator it = C->getArguments().begin(),
+           ie = C->getArguments().end(); it != ie; ++it)
+      OS << " \"" << *it << '"';
+    OS << Terminator;
+  } else if (const PipedJob *PJ = dyn_cast<PipedJob>(J)) {
+    for (PipedJob::const_iterator 
+           it = PJ->begin(), ie = PJ->end(); it != ie; ++it)
+      PrintJob(OS, *it, (it + 1 != PJ->end()) ? " |\n" : "\n");
+  } else {
+    const JobList *Jobs = cast<JobList>(J);
+    for (JobList::const_iterator 
+           it = Jobs->begin(), ie = Jobs->end(); it != ie; ++it)
+      PrintJob(OS, *it, Terminator);
+  }
+}
+
 int Compilation::Execute() const {
+  // Just print if -### was present.
+  if (getArgs().hasArg(options::OPT__HASH_HASH_HASH)) {
+    PrintJob(llvm::errs(), &Jobs, "\n");
+    return 0;
+  }
+  
   return 0;
 }





More information about the cfe-commits mailing list