[cfe-commits] r67418 - in /cfe/trunk: include/clang/Driver/HostInfo.h lib/Driver/Driver.cpp lib/Driver/HostInfo.cpp test/Driver/phases.c tools/ccc/ccclib/Driver.py tools/ccc/ccclib/HostInfo.py
Daniel Dunbar
daniel at zuster.org
Fri Mar 20 16:39:24 PDT 2009
Author: ddunbar
Date: Fri Mar 20 18:39:23 2009
New Revision: 67418
URL: http://llvm.org/viewvc/llvm-project?rev=67418&view=rev
Log:
ccc/Driver: .s defaults to 'assembler-with-cpp' on Darwin.
- <rdar://problem/6669441> ccc doesn't handle assembler-with-cpp
semantics correctly (but clang supports it)
- This is sad, because it requires a fairly useless target
hook. C'est la vie.
Modified:
cfe/trunk/include/clang/Driver/HostInfo.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/HostInfo.cpp
cfe/trunk/test/Driver/phases.c
cfe/trunk/tools/ccc/ccclib/Driver.py
cfe/trunk/tools/ccc/ccclib/HostInfo.py
Modified: cfe/trunk/include/clang/Driver/HostInfo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/HostInfo.h?rev=67418&r1=67417&r2=67418&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/HostInfo.h (original)
+++ cfe/trunk/include/clang/Driver/HostInfo.h Fri Mar 20 18:39:23 2009
@@ -10,6 +10,7 @@
#ifndef CLANG_DRIVER_HOSTINFO_H_
#define CLANG_DRIVER_HOSTINFO_H_
+#include "clang/Driver/Types.h"
#include <string>
namespace clang {
@@ -45,6 +46,10 @@
/// driver for 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;
+
/// getToolChain - Construct the toolchain to use for this host.
///
/// \param Args - The argument list, which may be used to alter the
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=67418&r1=67417&r2=67418&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Fri Mar 20 18:39:23 2009
@@ -445,9 +445,11 @@
Ty = types::TY_C;
} else {
// Otherwise lookup by extension, and fallback to ObjectType
- // if not found.
+ // if not 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 = types::lookupTypeForExtension(Ext + 1);
+ Ty = Host->lookupTypeForExtension(Ext + 1);
+
if (Ty == types::TY_INVALID)
Ty = types::TY_Object;
}
Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=67418&r1=67417&r2=67418&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Fri Mar 20 18:39:23 2009
@@ -57,6 +57,17 @@
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 *getToolChain(const ArgList &Args,
const char *ArchName) const;
};
@@ -173,6 +184,10 @@
virtual bool useDriverDriver() const;
+ virtual types::ID lookupTypeForExtension(const char *Ext) const {
+ return types::lookupTypeForExtension(Ext);
+ }
+
virtual ToolChain *getToolChain(const ArgList &Args,
const char *ArchName) const;
};
Modified: cfe/trunk/test/Driver/phases.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/phases.c?rev=67418&r1=67417&r2=67418&view=diff
==============================================================================
--- cfe/trunk/test/Driver/phases.c (original)
+++ cfe/trunk/test/Driver/phases.c Fri Mar 20 18:39:23 2009
@@ -66,4 +66,14 @@
// RUN: grep -F '1: preprocessor, {0}, c-header-cpp-output' %t &&
// RUN: grep -F '2: precompiler, {1}, precompiled-header' %t &&
+// Darwin overrides the handling for .s
+// RUN: touch %t.s &&
+// RUN: clang-driver -ccc-host-triple i386-unknown-unknown -ccc-print-phases -c %t.s &> %t &&
+// RUN: grep '0: input, ".*\.s", assembler' %t &&
+// RUN: grep -F '1: assembler, {0}, object' %t &&
+// RUN: clang-driver -ccc-host-triple i386-apple-darwin9 -ccc-print-phases -c %t.s &> %t &&
+// RUN: grep '0: input, ".*\.s", assembler-with-cpp' %t &&
+// RUN: grep -F '1: preprocessor, {0}, assembler' %t &&
+// RUN: grep -F '2: assembler, {1}, object' %t &&
+
// RUN: true
Modified: cfe/trunk/tools/ccc/ccclib/Driver.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Driver.py?rev=67418&r1=67417&r2=67418&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Driver.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Driver.py Fri Mar 20 18:39:23 2009
@@ -426,7 +426,7 @@
else:
raise Arguments.InvalidArgumentsError("-E or -x required when input is from standard input")
elif ext and ext in Types.kTypeSuffixMap:
- klass = Types.kTypeSuffixMap[ext]
+ klass = self.hostInfo.lookupTypeForExtension(ext)
else:
# FIXME: Its not clear why we shouldn't just
# revert to unknown. I think this is more likely a
Modified: cfe/trunk/tools/ccc/ccclib/HostInfo.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/HostInfo.py?rev=67418&r1=67417&r2=67418&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/HostInfo.py (original)
+++ cfe/trunk/tools/ccc/ccclib/HostInfo.py Fri Mar 20 18:39:23 2009
@@ -1,4 +1,5 @@
import ToolChain
+import Types
class HostInfo(object):
"""HostInfo - Config information about a particular host which may
@@ -14,6 +15,9 @@
def useDriverDriver(self):
abstract
+ def lookupTypeForExtension(self, ext):
+ abstract
+
def getToolChain(self):
abstract
@@ -37,6 +41,12 @@
def useDriverDriver(self):
return True
+ def lookupTypeForExtension(self, ext):
+ ty = Types.kTypeSuffixMap.get(ext)
+ if ty is Types.AsmTypeNoPP:
+ return Types.AsmType
+ return ty
+
def getToolChain(self):
return self.getToolChainForArch(self.getArchName(None))
@@ -98,6 +108,9 @@
def useDriverDriver(self):
return False
+ def lookupTypeForExtension(self, ext):
+ return Types.kTypeSuffixMap.get(ext)
+
def getToolChain(self):
return ToolChain.Generic_GCC_ToolChain(self.driver, '')
More information about the cfe-commits
mailing list