[cfe-commits] r64709 - in /cfe/trunk/tools/ccc: ccclib/Arguments.py ccclib/ToolChain.py ccclib/Tools.py test/ccc/math-errno.c
Daniel Dunbar
daniel at zuster.org
Mon Feb 16 16:42:05 PST 2009
Author: ddunbar
Date: Mon Feb 16 18:42:05 2009
New Revision: 64709
URL: http://llvm.org/viewvc/llvm-project?rev=64709&view=rev
Log:
ccc: Pass -f[no-]math-errno to clang.
Added:
cfe/trunk/tools/ccc/test/ccc/math-errno.c
Modified:
cfe/trunk/tools/ccc/ccclib/Arguments.py
cfe/trunk/tools/ccc/ccclib/ToolChain.py
cfe/trunk/tools/ccc/ccclib/Tools.py
Modified: cfe/trunk/tools/ccc/ccclib/Arguments.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Arguments.py?rev=64709&r1=64708&r2=64709&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Arguments.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Arguments.py Mon Feb 16 18:42:05 2009
@@ -364,9 +364,30 @@
arg.opt.matches(optionC)):
yield arg
+ def getLastArgAndPosition(self, option):
+ return self.lastArgs.get(option, (None,-1))
+
def getLastArg(self, option):
- return self.lastArgs.get(option)
+ return self.getLastArgAndPosition(option)[0]
+ def hasFFlag(self, option, negativeOption, default):
+ """hasFFlag - Given an option and its corresponding negative
+ option, return True if the option is present, False if the
+ negation is present, and default if neither option is
+ given. If both the option and its negation are present, the
+ last one wins.
+ """
+ arg,argPos = self.getLastArgAndPosition(option)
+ neg,negPos = self.getLastArgAndPosition(negativeOption)
+ if arg and neg:
+ return negPos < argPos
+ elif arg:
+ return True
+ elif neg:
+ return False
+ else:
+ return default
+
def getInputString(self, index, offset=0):
# Source 0 is argv.
if index.sourceId == 0:
@@ -457,9 +478,9 @@
opt = arg.opt
if opt.alias:
opt = opt.alias
- self.lastArgs[opt] = arg
+ self.lastArgs[opt] = (arg, len(self.args) - 1)
if opt.group is not None:
- self.lastArgs[opt.group] = arg
+ self.lastArgs[opt.group] = (arg, len(self.args) - 1)
# Forwarding methods.
#
@@ -793,6 +814,8 @@
self.f_indirectVirtualCallsOption = self.addOption(FlagOption('-findirect-virtual-calls', self.fGroup))
self.f_laxVectorConversionsOption = self.addOption(FlagOption('-flax-vector-conversions', self.Clang_fGroup))
self.f_limitedPrecisionOption = self.addOption(JoinedOption('-flimited-precision=', self.fGroup))
+ self.f_mathErrnoOption = self.addOption(FlagOption('-fmath-errno', self.fGroup))
+ self.f_noMathErrnoOption = self.addOption(FlagOption('-fno-math-errno', self.fGroup))
self.f_msExtensionsOption = self.addOption(FlagOption('-fms-extensions', self.Clang_fGroup))
self.f_mudflapOption = self.addOption(FlagOption('-fmudflap', self.fGroup))
self.f_mudflapthOption = self.addOption(FlagOption('-fmudflapth', self.fGroup))
Modified: cfe/trunk/tools/ccc/ccclib/ToolChain.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/ToolChain.py?rev=64709&r1=64708&r2=64709&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/ToolChain.py (original)
+++ cfe/trunk/tools/ccc/ccclib/ToolChain.py Mon Feb 16 18:42:05 2009
@@ -76,6 +76,9 @@
return True
+ def isMathErrnoDefault(self):
+ return True
+
class Darwin_X86_ToolChain(ToolChain):
def __init__(self, driver, darwinVersion, gccVersion, archName):
super(Darwin_X86_ToolChain, self).__init__(driver)
@@ -224,6 +227,9 @@
return al
+ def isMathErrnoDefault(self):
+ return False
+
class Generic_GCC_ToolChain(ToolChain):
"""Generic_GCC_ToolChain - A tool chain using the 'gcc' command to
perform all subcommands; this relies on gcc translating the
Modified: cfe/trunk/tools/ccc/ccclib/Tools.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/ccclib/Tools.py?rev=64709&r1=64708&r2=64709&view=diff
==============================================================================
--- cfe/trunk/tools/ccc/ccclib/Tools.py (original)
+++ cfe/trunk/tools/ccc/ccclib/Tools.py Mon Feb 16 18:42:05 2009
@@ -280,6 +280,13 @@
if arglist.getLastArg(arglist.parser.f_unwindTablesOption):
cmd_args.append('--unwind-tables')
+ if arglist.hasFFlag(arglist.parser.f_mathErrnoOption,
+ arglist.parser.f_noMathErrnoOption,
+ self.toolChain.isMathErrnoDefault()):
+ cmd_args.append('--fmath-errno=1')
+ else:
+ cmd_args.append('--fmath-errno=0')
+
arg = arglist.getLastArg(arglist.parser.f_limitedPrecisionOption)
if arg:
cmd_args.append('--limit-float-precision')
Added: cfe/trunk/tools/ccc/test/ccc/math-errno.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/ccc/test/ccc/math-errno.c?rev=64709&view=auto
==============================================================================
--- cfe/trunk/tools/ccc/test/ccc/math-errno.c (added)
+++ cfe/trunk/tools/ccc/test/ccc/math-errno.c Mon Feb 16 18:42:05 2009
@@ -0,0 +1,5 @@
+// RUN: xcc -ccc-host-system unknown -### %s -S 2>&1 | grep -- "--fmath-errno=1" | count 1 &&
+// RUN: xcc -ccc-host-system unknown -### %s -S -fno-math-errno 2>&1 | grep -- "--fmath-errno=0" | count 1 &&
+// RUN: xcc -ccc-host-system unknown -### %s -S -fmath-errno -fno-math-errno 2>&1 | grep -- "--fmath-errno=0" | count 1 &&
+// RUN: xcc -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### %s -S 2>&1 | grep -- "--fmath-errno=0" | count 1 &&
+// RUN: xcc -ccc-host-bits 32 -ccc-host-machine i386 -ccc-host-system darwin -ccc-host-release 10.5.0 -### %s -S -fmath-errno 2>&1 | grep -- "--fmath-errno=1" | count 1
More information about the cfe-commits
mailing list