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

Daniel Dunbar daniel at zuster.org
Tue Mar 17 13:45:45 PDT 2009


Author: ddunbar
Date: Tue Mar 17 15:45:45 2009
New Revision: 67102

URL: http://llvm.org/viewvc/llvm-project?rev=67102&view=rev
Log:
Driver: Pass Driver reference down into Host info, which will need it
to pass to ToolChains, which may need Driver specific information (for
example, to form search paths).

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

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

==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue Mar 17 15:45:45 2009
@@ -220,7 +220,7 @@
 
   /// GetHostInfo - Construct a new host info object for the given
   /// host triple.
-  static const HostInfo *GetHostInfo(const char *HostTriple);
+  const HostInfo *GetHostInfo(const char *HostTriple) const;
 
   /// @}
 };

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

==============================================================================
--- cfe/trunk/include/clang/Driver/HostInfo.h (original)
+++ cfe/trunk/include/clang/Driver/HostInfo.h Tue Mar 17 15:45:45 2009
@@ -15,6 +15,7 @@
 namespace clang {
 namespace driver {
   class ArgList;
+  class Driver;
   class ToolChain;
 
 /// HostInfo - Config information about a particular host which may
@@ -25,14 +26,17 @@
 /// being run from. For testing purposes, the HostInfo used by the
 /// driver may differ from the actual host.
 class HostInfo {
+  const Driver &TheDriver;
   std::string Arch, Platform, OS;
 
 protected:
-  HostInfo(const char *Arch, const char *Platform, const char *OS);
+  HostInfo(const Driver &D, const char *Arch, 
+           const char *Platform, const char *OS);
 
 public:
   virtual ~HostInfo();
 
+  const Driver &getDriver() const { return TheDriver; }
   const std::string &getArchName() const { return Arch; }
   const std::string &getPlatformName() const { return Platform; }
   const std::string &getOSName() const { return OS; }
@@ -56,10 +60,10 @@
                                   const char *ArchName=0) const = 0;
 };
 
-const HostInfo *createDarwinHostInfo(const char *Arch, const char *Platform, 
-                                     const char *OS);
-const HostInfo *createUnknownHostInfo(const char *Arch, const char *Platform, 
-                                      const char *OS);
+const HostInfo *createDarwinHostInfo(const Driver &D, const char *Arch, 
+                                     const char *Platform, const char *OS);
+const HostInfo *createUnknownHostInfo(const Driver &D, const char *Arch, 
+                                      const char *Platform, const char *OS);
 
 } // end namespace driver
 } // end namespace clang

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

==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Mar 17 15:45:45 2009
@@ -154,7 +154,7 @@
 
   ArgList *Args = ParseArgStrings(Start, End);
 
-  Host = Driver::GetHostInfo(HostTriple);
+  Host = GetHostInfo(HostTriple);
   DefaultToolChain = Host->getToolChain(*Args);
 
   // FIXME: This behavior shouldn't be here.
@@ -816,7 +816,7 @@
   return llvm::sys::Path(Name);
 }
 
-const HostInfo *Driver::GetHostInfo(const char *Triple) {
+const HostInfo *Driver::GetHostInfo(const char *Triple) const {
   // Dice into arch, platform, and OS. This matches 
   //  arch,platform,os = '(.*?)-(.*?)-(.*?)'
   // and missing fields are left empty.
@@ -842,7 +842,9 @@
     Arch = "x86_64";
   
   if (memcmp(&OS[0], "darwin", 6) == 0)
-    return createDarwinHostInfo(Arch.c_str(), Platform.c_str(), OS.c_str());
+    return createDarwinHostInfo(*this, Arch.c_str(), Platform.c_str(), 
+                                OS.c_str());
     
-  return createUnknownHostInfo(Arch.c_str(), Platform.c_str(), OS.c_str());
+  return createUnknownHostInfo(*this, Arch.c_str(), Platform.c_str(), 
+                               OS.c_str());
 }

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

==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Tue Mar 17 15:45:45 2009
@@ -21,9 +21,9 @@
  
 using namespace clang::driver;
 
-HostInfo::HostInfo(const char *_Arch, const char *_Platform,
+HostInfo::HostInfo(const Driver &D, const char *_Arch, const char *_Platform,
                    const char *_OS) 
-  : Arch(_Arch), Platform(_Platform), OS(_OS) 
+  : TheDriver(D), Arch(_Arch), Platform(_Platform), OS(_OS) 
 {
   
 }
@@ -47,7 +47,8 @@
   mutable llvm::StringMap<ToolChain*> ToolChains;
 
 public:
-  DarwinHostInfo(const char *Arch, const char *Platform, const char *OS);
+  DarwinHostInfo(const Driver &D, const char *Arch, 
+                 const char *Platform, const char *OS);
 
   virtual bool useDriverDriver() const;
 
@@ -55,9 +56,9 @@
                                   const char *ArchName) const;
 };
 
-DarwinHostInfo::DarwinHostInfo(const char *_Arch, const char *_Platform,
-                               const char *_OS) 
-  : HostInfo(_Arch, _Platform, _OS) {
+DarwinHostInfo::DarwinHostInfo(const Driver &D, const char *_Arch, 
+                               const char *_Platform, const char *_OS) 
+  : HostInfo(D, _Arch, _Platform, _OS) {
   
   assert((getArchName() == "i386" || getArchName() == "x86_64" || 
           getArchName() == "ppc" || getArchName() == "ppc64") &&
@@ -118,7 +119,8 @@
   mutable llvm::StringMap<ToolChain*> ToolChains;
 
 public:
-  UnknownHostInfo(const char *Arch, const char *Platform, const char *OS);
+  UnknownHostInfo(const Driver &D, const char *Arch, 
+                  const char *Platform, const char *OS);
 
   virtual bool useDriverDriver() const;
 
@@ -126,9 +128,9 @@
                                   const char *ArchName) const;
 };
 
-UnknownHostInfo::UnknownHostInfo(const char *Arch, const char *Platform,
-                                 const char *OS) 
-  : HostInfo(Arch, Platform, OS) {
+UnknownHostInfo::UnknownHostInfo(const Driver &D, const char *Arch, 
+                                 const char *Platform, const char *OS) 
+  : HostInfo(D, Arch, Platform, OS) {
 }
 
 bool UnknownHostInfo::useDriverDriver() const { 
@@ -161,14 +163,16 @@
 
 }
 
-const HostInfo *clang::driver::createDarwinHostInfo(const char *Arch, 
+const HostInfo *clang::driver::createDarwinHostInfo(const Driver &D,
+                                                    const char *Arch, 
                                                     const char *Platform, 
                                                     const char *OS) {
-  return new DarwinHostInfo(Arch, Platform, OS);
+  return new DarwinHostInfo(D, Arch, Platform, OS);
 }
 
-const HostInfo *clang::driver::createUnknownHostInfo(const char *Arch, 
+const HostInfo *clang::driver::createUnknownHostInfo(const Driver &D,
+                                                     const char *Arch, 
                                                      const char *Platform, 
                                                      const char *OS) {
-  return new UnknownHostInfo(Arch, Platform, OS);
+  return new UnknownHostInfo(D, Arch, Platform, OS);
 }





More information about the cfe-commits mailing list