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

Daniel Dunbar daniel at zuster.org
Tue Mar 17 15:47:07 PDT 2009


Author: ddunbar
Date: Tue Mar 17 17:47:06 2009
New Revision: 67125

URL: http://llvm.org/viewvc/llvm-project?rev=67125&view=rev
Log:
Driver: Add -ccc-print-bindings option (for testing); the Python
driver has no corresponding option.

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

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

==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue Mar 17 17:47:06 2009
@@ -78,6 +78,9 @@
   /// Echo commands while executing (in -v style).
   bool CCCEcho : 1;
 
+  /// Only print tool bindings, don't build any jobs.
+  bool CCCPrintBindings : 1;
+
   /// Don't use clang for any tasks.
   bool CCCNoClang : 1;
 

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

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Mar 17 17:47:06 2009
@@ -40,7 +40,7 @@
     Name(_Name), Dir(_Dir), DefaultHostTriple(_DefaultHostTriple),
     DefaultImageName(_DefaultImageName),
     Host(0),
-    CCCIsCXX(false), CCCEcho(false), 
+    CCCIsCXX(false), CCCEcho(false), CCCPrintBindings(false),
     CCCNoClang(false), CCCNoClangCXX(false), CCCNoClangCPP(false),
     SuppressMissingInputWarning(false)
 {
@@ -114,6 +114,8 @@
       CCCPrintOptions = true;
     } else if (!strcmp(Opt, "print-phases")) {
       CCCPrintActions = true;
+    } else if (!strcmp(Opt, "print-bindings")) {
+      CCCPrintBindings = true;
     } else if (!strcmp(Opt, "cxx")) {
       CCCIsCXX = true;
     } else if (!strcmp(Opt, "echo")) {
@@ -729,27 +731,32 @@
 
   // Determine the place to write output to (nothing, pipe, or
   // filename) and where to put the new job.
-  PipedJob *OutputJob = 0;
-  const char *Output = 0;
   if (JA->getType() == types::TY_Nothing) {
-    ;
+    Result = InputInfo(A->getType(), BaseInput);
   } else if (OutputToPipe) {
     // Append to current piped job or create a new one as appropriate.
-    if (PipedJob *PJ = dyn_cast<PipedJob>(Dest)) {
-      OutputJob = PJ;
-      Dest = OutputJob;
-    } else {
-      OutputJob = new PipedJob();
-      cast<JobList>(Dest)->addJob(OutputJob);
-      Dest = OutputJob;
+    PipedJob *PJ = dyn_cast<PipedJob>(Dest);
+    if (!PJ) {
+      PJ = new PipedJob();
+      cast<JobList>(Dest)->addJob(PJ);
     }
+    Result = InputInfo(PJ, A->getType(), BaseInput);
   } else {
-    Output = GetNamedOutputPath(C, *JA, BaseInput, AtTopLevel);
+    Result = InputInfo(GetNamedOutputPath(C, *JA, BaseInput, AtTopLevel),
+                       A->getType(), BaseInput);
   }
 
-  // FIXME: Make the job.
-
-  Result = InputInfo(Output, A->getType(), BaseInput);
+  if (CCCPrintBindings) {
+    llvm::errs() << "bind - \"" << T.getName() << "\", inputs: [";
+    for (unsigned i = 0, e = InputInfos.size(); i != e; ++i) {
+      llvm::errs() << InputInfos[i].getAsString();
+      if (i + 1 != e)
+        llvm::errs() << ", ";
+    }
+    llvm::errs() << "], output: " << Result.getAsString() << "\n";
+  } else {
+    assert(0 && "FIXME: Make the job.");
+  }
 }
 
 const char *Driver::GetNamedOutputPath(Compilation &C, 

Modified: cfe/trunk/lib/Driver/InputInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/InputInfo.h?rev=67125&r1=67124&r2=67125&view=diff

==============================================================================
--- cfe/trunk/lib/Driver/InputInfo.h (original)
+++ cfe/trunk/lib/Driver/InputInfo.h Tue Mar 17 17:47:06 2009
@@ -11,6 +11,7 @@
 #define CLANG_LIB_DRIVER_INPUTINFO_H_
 
 #include <cassert>
+#include <string>
 
 namespace clang {
 namespace driver {
@@ -28,6 +29,10 @@
 
 public:
   InputInfo() {}
+  InputInfo(types::ID _Type, const char *_BaseInput)
+    : IsPipe(false), Type(_Type), BaseInput(_BaseInput) {
+    Data.Filename = 0;
+  }
   InputInfo(const char *Filename, types::ID _Type, const char *_BaseInput)
     : IsPipe(false), Type(_Type), BaseInput(_BaseInput) {
     Data.Filename = Filename;
@@ -49,6 +54,17 @@
     assert(isPipe() && "Invalid accessor.");
     return *Data.Pipe;
   }
+
+  /// getAsString - Return a string name for this input, for
+  /// debugging.
+  std::string getAsString() const {
+    if (isPipe())
+      return "(pipe)";
+    else if (const char *N = getInputFilename())
+      return std::string("\"") + N + '"';
+    else
+      return "(nothing)";
+  }
 };
 
 } // end namespace driver





More information about the cfe-commits mailing list