ccc: Implement argument translation for clang.

- This is what ccc (old) currently handles.

 - Clang accepts some more things that aren't getting forwarded...

llvm-svn: 62210
This commit is contained in:
Daniel Dunbar 2009-01-14 01:50:15 +00:00
parent dedd3e1e14
commit a06af2ba07
2 changed files with 53 additions and 7 deletions

View File

@ -727,7 +727,11 @@ class OptionParser:
self.f_noEliminateUnusedDebugSymbolsOption = self.addOption(FlagOption('-fno-eliminate-unused-debug-symbols', self.fGroup))
self.f_exceptionsOption = self.addOption(FlagOption('-fexceptions', self.fGroup))
self.f_objcOption = self.addOption(FlagOption('-fobjc', self.fGroup))
self.f_objcGcOption = self.addOption(FlagOption('-fobjc-gc', self.fGroup))
self.f_objcGcOnlyOption = self.addOption(FlagOption('-fobjc-gc-only', self.fGroup))
self.f_openmpOption = self.addOption(FlagOption('-fopenmp', self.fGroup))
self.f_gnuRuntimeOption = self.addOption(FlagOption('-fgnu-runtime', self.fGroup))
self.f_nextRuntimeOption = self.addOption(FlagOption('-fnext-runtime', self.fGroup))
self.f_constantCfstringsOption = self.addOption(FlagOption('-fconstant-cfstrings', self.fGroup))
self.f_noConstantCfstringsOption = self.addOption(FlagOption('-fno-constant-cfstrings', self.fGroup))
self.f_pascalStringsOption = self.addOption(FlagOption('-fpascal-strings', self.fGroup))

View File

@ -172,18 +172,60 @@ class GCC_LinkTool(GCC_Common_Tool):
output, outputType, arglist,
[])
class Clang_CompileTool(GCC_Common_Tool):
class Clang_CompileTool(Tool):
def __init__(self):
super(Clang_CompileTool, self).__init__('clang',
(Tool.eFlagsPipedInput |
Tool.eFlagsPipedOutput |
Tool.eFlagsIntegratedCPP))
(Tool.eFlagsPipedInput |
Tool.eFlagsPipedOutput |
Tool.eFlagsIntegratedCPP))
def constructJob(self, phase, arch, jobs, inputs,
output, outputType, arglist):
return super(Clang_CompileTool, self).constructJob(phase, arch, jobs, inputs,
output, outputType, arglist,
['-S'])
cmd_args = []
if output is None:
cmd_args.append('-fsyntax-only')
elif outputType is Types.AsmTypeNoPP:
cmd_args.append('-S')
else:
raise ValueError,"Unexpected output type for clang tool."
arglist.addAllArgs(cmd_args, arglist.parser.vOption)
arglist.addAllArgs(cmd_args, arglist.parser.f_objcGcOption)
arglist.addAllArgs(cmd_args, arglist.parser.f_objcGcOnlyOption)
arglist.addAllArgs(cmd_args, arglist.parser.f_nextRuntimeOption)
arglist.addAllArgs(cmd_args, arglist.parser.f_gnuRuntimeOption)
arglist.addAllArgs2(cmd_args, arglist.parser.DOption, arglist.parser.UOption)
arglist.addAllArgs2(cmd_args, arglist.parser.IOption, arglist.parser.FOption)
arglist.addAllArgs(cmd_args, arglist.parser.stdOption)
arglist.addAllArgs(cmd_args, arglist.parser.m_macosxVersionMinOption)
# Special case debug options to only pass -g to clang. This is
# wrong.
if arglist.getLastArg(arglist.parser.gGroup):
cmd_args.append('-g')
# FIXME: Clang isn't going to accept just anything here.
arglist.addAllArgs(cmd_args, arglist.parser.iGroup)
# FIXME: Dehardcode this.
cmd_args.append('-fblocks')
if arch is not None:
cmd_args.extend(arglist.render(arch))
cmd_args.extend(arglist.render(output))
for input in inputs:
cmd_args.append('-x')
cmd_args.append(input.type.name)
if isinstance(input.source, Jobs.PipedJob):
cmd_args.append('-')
else:
cmd_args.extend(arglist.renderAsInput(input.source))
jobs.addJob(Jobs.Command('clang', cmd_args))
class Darwin_X86_CompileTool(Tool):
def __init__(self, toolChain):