]> granicus.if.org Git - clang/commitdiff
Driver: Ditch Driver::DefaultToolChain, this can vary between compilations.
authorDaniel Dunbar <daniel@zuster.org>
Wed, 18 Mar 2009 03:13:20 +0000 (03:13 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Wed, 18 Mar 2009 03:13:20 +0000 (03:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67162 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Action.h
include/clang/Driver/Driver.h
lib/Driver/Driver.cpp

index b65e5af65af18ec31615e4304ef98a51da08b1ac..b9bf671db2bdee12594cd8887a91b47e78bd2706 100644 (file)
@@ -105,6 +105,8 @@ public:
 };
 
 class BindArchAction : public Action {
+  /// The architecture to bind, or 0 if the default architecture
+  /// should be bound.
   const char *ArchName;
 
 public:
index aea5d8c979911e78381090c776859e35cb0b841b..8198913bd04f67b6fefa3aae94cdbdf54180415e 100644 (file)
@@ -64,11 +64,6 @@ public:
   /// will generally be the actual host platform, but not always.
   const HostInfo *Host;
 
-  /// The default tool chain for this host.
-  // FIXME: This shouldn't be here; this should be in a
-  // CompilationInfo structure.
-  ToolChain *DefaultToolChain;
-
   /// Information about the host which can be overriden by the user.
   std::string HostBits, HostMachine, HostSystem, HostRelease;
 
@@ -164,7 +159,7 @@ public:
   void PrintVersion() const;
 
   /// PrintActions - Print the list of actions.
-  void PrintActions(const ArgList &Args, const ActionList &Actions) const;
+  void PrintActions(const Compilation &C) const;
 
   /// GetFilePath - Lookup \arg Name in the list of file search paths.
   ///
index f60271c02e03eb98665bd08b23e2b4180a99330e..84f3428c62846c0287d119244e7059ec3e6237c3 100644 (file)
@@ -162,12 +162,9 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) {
   ArgList *Args = ParseArgStrings(Start, End);
 
   Host = GetHostInfo(HostTriple);
-  // FIXME: This shouldn't live inside Driver, the default tool chain
-  // is part of the compilation (it is arg dependent).
-  DefaultToolChain = Host->getToolChain(*Args);
 
   // The compilation takes ownership of Args.
-  Compilation *C = new Compilation(*DefaultToolChain, Args);
+  Compilation *C = new Compilation(*Host->getToolChain(*Args), Args);
 
   // FIXME: This behavior shouldn't be here.
   if (CCCPrintOptions) {
@@ -188,7 +185,7 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) {
     BuildActions(C->getArgs(), C->getActions());
 
   if (CCCPrintActions) {
-    PrintActions(C->getArgs(), C->getActions());
+    PrintActions(*C);
     return C;
   }
 
@@ -255,7 +252,7 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
   return true;
 }
 
-static unsigned PrintActions1(const ArgList &Args,
+static unsigned PrintActions1(const Compilation &C,
                               Action *A, 
                               std::map<Action*, unsigned> &Ids) {
   if (Ids.count(A))
@@ -266,14 +263,15 @@ static unsigned PrintActions1(const ArgList &Args,
   
   os << Action::getClassName(A->getKind()) << ", ";
   if (InputAction *IA = dyn_cast<InputAction>(A)) {    
-    os << "\"" << IA->getInputArg().getValue(Args) << "\"";
+    os << "\"" << IA->getInputArg().getValue(C.getArgs()) << "\"";
   } else if (BindArchAction *BIA = dyn_cast<BindArchAction>(A)) {
-    os << "\"" << BIA->getArchName() << "\", "
-       << "{" << PrintActions1(Args, *BIA->begin(), Ids) << "}";
+    os << '"' << (BIA->getArchName() ? BIA->getArchName() : 
+                  C.getDefaultToolChain().getArchName()) << '"'
+       << ", {" << PrintActions1(C, *BIA->begin(), Ids) << "}";
   } else {
     os << "{";
     for (Action::iterator it = A->begin(), ie = A->end(); it != ie;) {
-      os << PrintActions1(Args, *it, Ids);
+      os << PrintActions1(C, *it, Ids);
       ++it;
       if (it != ie)
         os << ", ";
@@ -289,12 +287,11 @@ static unsigned PrintActions1(const ArgList &Args,
   return Id;
 }
 
-void Driver::PrintActions(const ArgList &Args, 
-                          const ActionList &Actions) const {
+void Driver::PrintActions(const Compilation &C) const {
   std::map<Action*, unsigned> Ids;
-  for (ActionList::const_iterator it = Actions.begin(), ie = Actions.end(); 
-       it != ie; ++it)
-    PrintActions1(Args, *it, Ids);
+  for (ActionList::const_iterator it = C.getActions().begin(), 
+         ie = C.getActions().end(); it != ie; ++it)
+    PrintActions1(C, *it, Ids);
 }
 
 void Driver::BuildUniversalActions(const ArgList &Args, 
@@ -319,12 +316,11 @@ void Driver::BuildUniversalActions(const ArgList &Args,
     }
   }
 
-  // When there is no explicit arch for this platform, get one from
-  // the host so that -Xarch_ is handled correctly.
-  if (!Archs.size()) {
-    const char *Arch = DefaultToolChain->getArchName().c_str();
-    Archs.push_back(Arch);
-  }
+  // When there is no explicit arch for this platform, make sure we
+  // still bind the architecture (to the default) so that -Xarch_ is
+  // handled correctly.
+  if (!Archs.size())
+    Archs.push_back(0);
 
   // FIXME: We killed off some others but these aren't yet detected in
   // a functional manner. If we added information to jobs about which
@@ -641,8 +637,7 @@ void Driver::BuildJobs(Compilation &C) const {
     }
 
     InputInfo II;
-    BuildJobsForAction(C, 
-                       A, DefaultToolChain, 
+    BuildJobsForAction(C, A, &C.getDefaultToolChain(), 
                        /*CanAcceptPipe*/ true,
                        /*AtTopLevel*/ true,
                        /*LinkingOutput*/ LinkingOutput,
@@ -679,6 +674,8 @@ void Driver::BuildJobsForAction(Compilation &C,
 
   if (const BindArchAction *BAA = dyn_cast<BindArchAction>(A)) {
     const char *ArchName = BAA->getArchName();
+    if (!ArchName)
+      ArchName = C.getDefaultToolChain().getArchName().c_str();
     BuildJobsForAction(C,
                        *BAA->begin(), 
                        Host->getToolChain(C.getArgs(), ArchName),