Driver: Move HostInfo::lookupTypeForExtension to ToolChain::LookupTypeForExtension.

llvm-svn: 110024
This commit is contained in:
Daniel Dunbar 2010-08-02 05:43:56 +00:00
parent a36c2b3a62
commit cc7df6cc7b
7 changed files with 22 additions and 54 deletions

View File

@ -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 <string>
@ -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).
///

View File

@ -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; }

View File

@ -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;

View File

@ -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;
};

View File

@ -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);
}

View File

@ -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")

View File

@ -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;