From cc7df6cc7b00d9b43d0991f0f1006d4c078f7581 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Mon, 2 Aug 2010 05:43:56 +0000 Subject: [PATCH] Driver: Move HostInfo::lookupTypeForExtension to ToolChain::LookupTypeForExtension. llvm-svn: 110024 --- clang/include/clang/Driver/HostInfo.h | 5 --- clang/include/clang/Driver/ToolChain.h | 5 +++ clang/lib/Driver/Driver.cpp | 2 +- clang/lib/Driver/HostInfo.cpp | 48 -------------------------- clang/lib/Driver/ToolChain.cpp | 4 +++ clang/lib/Driver/ToolChains.cpp | 10 ++++++ clang/lib/Driver/ToolChains.h | 2 ++ 7 files changed, 22 insertions(+), 54 deletions(-) diff --git a/clang/include/clang/Driver/HostInfo.h b/clang/include/clang/Driver/HostInfo.h index 1b99a4459d16..af6ef822fbfd 100644 --- a/clang/include/clang/Driver/HostInfo.h +++ b/clang/include/clang/Driver/HostInfo.h @@ -10,7 +10,6 @@ #ifndef CLANG_DRIVER_HOSTINFO_H_ #define CLANG_DRIVER_HOSTINFO_H_ -#include "clang/Driver/Types.h" #include "llvm/ADT/Triple.h" #include @@ -48,10 +47,6 @@ public: /// this host and support -arch, -Xarch, etc. virtual bool useDriverDriver() const = 0; - /// lookupTypeForExtension - Return the default language type to use for the - /// given extension. - virtual types::ID lookupTypeForExtension(const char *Ext) const = 0; - /// CreateToolChain - Construct the toolchain to use for this host (which the /// host retains ownership of). /// diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h index 11a153c48ca3..ee18315832cf 100644 --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -10,6 +10,7 @@ #ifndef CLANG_DRIVER_TOOLCHAIN_H_ #define CLANG_DRIVER_TOOLCHAIN_H_ +#include "clang/Driver/Types.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" #include "llvm/System/Path.h" @@ -89,6 +90,10 @@ public: // Platform defaults information + /// LookupTypeForExtension - Return the default language type to use for the + /// given extension. + virtual types::ID LookupTypeForExtension(const char *Ext) const; + /// IsBlocksDefault - Does this tool chain enable -fblocks by default. virtual bool IsBlocksDefault() const { return false; } diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e28b2bc6ed84..7fbbe0b838ce 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -662,7 +662,7 @@ void Driver::BuildActions(const ToolChain &TC, const ArgList &Args, // found. We use a host hook here because Darwin at least has its own // idea of what .s is. if (const char *Ext = strrchr(Value, '.')) - Ty = Host->lookupTypeForExtension(Ext + 1); + Ty = TC.LookupTypeForExtension(Ext + 1); if (Ty == types::TY_INVALID) Ty = types::TY_Object; diff --git a/clang/lib/Driver/HostInfo.cpp b/clang/lib/Driver/HostInfo.cpp index 0636d9eab15c..a8fdec8a103e 100644 --- a/clang/lib/Driver/HostInfo.cpp +++ b/clang/lib/Driver/HostInfo.cpp @@ -53,17 +53,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - types::ID Ty = types::lookupTypeForExtension(Ext); - - // Darwin always preprocesses assembly files (unless -x is used - // explicitly). - if (Ty == types::TY_PP_Asm) - return types::TY_Asm; - - return Ty; - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -170,15 +159,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - types::ID Ty = types::lookupTypeForExtension(Ext); - - if (Ty == types::TY_PP_Asm) - return types::TY_Asm; - - return Ty; - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -212,10 +192,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - return types::lookupTypeForExtension(Ext); - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -279,10 +255,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - return types::lookupTypeForExtension(Ext); - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -330,10 +302,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - return types::lookupTypeForExtension(Ext); - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -379,10 +347,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - return types::lookupTypeForExtension(Ext); - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -439,10 +403,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - return types::lookupTypeForExtension(Ext); - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -491,10 +451,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - return types::lookupTypeForExtension(Ext); - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; @@ -540,10 +496,6 @@ public: virtual bool useDriverDriver() const; - virtual types::ID lookupTypeForExtension(const char *Ext) const { - return types::lookupTypeForExtension(Ext); - } - virtual ToolChain *CreateToolChain(const ArgList &Args, const char *ArchName) const; }; diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 9fae67de32f4..ab907c1aeff6 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -34,3 +34,7 @@ std::string ToolChain::GetFilePath(const char *Name) const { std::string ToolChain::GetProgramPath(const char *Name, bool WantFile) const { return Host.getDriver().GetProgramPath(Name, *this, WantFile); } + +types::ID ToolChain::LookupTypeForExtension(const char *Ext) const { + return types::lookupTypeForExtension(Ext); +} diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index 0449711208eb..bdccc3e3da29 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -40,6 +40,16 @@ Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple, << _DarwinVersion[1]; } +types::ID Darwin::LookupTypeForExtension(const char *Ext) const { + types::ID Ty = types::lookupTypeForExtension(Ext); + + // Darwin always preprocesses assembly files (unless -x is used explicitly). + if (Ty == types::TY_PP_Asm) + return types::TY_Asm; + + return Ty; +} + // FIXME: Can we tablegen this? static const char *GetArmArchForMArch(llvm::StringRef Value) { if (Value == "armv6k") diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h index b6c7badf3b3f..06d4fff4e7cc 100644 --- a/clang/lib/Driver/ToolChains.h +++ b/clang/lib/Driver/ToolChains.h @@ -147,6 +147,8 @@ public: /// @name ToolChain Implementation /// { + virtual types::ID LookupTypeForExtension(const char *Ext) const; + virtual DerivedArgList *TranslateArgs(const DerivedArgList &Args, const char *BoundArch) const;