ccc: -x assembler-with-cpp was broken for darwin, and it wasn't using
clang as the preprocessor even when it should.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66737 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/ccc/ccclib/ToolChain.py b/tools/ccc/ccclib/ToolChain.py
index 8c71789..d081f28 100644
--- a/tools/ccc/ccclib/ToolChain.py
+++ b/tools/ccc/ccclib/ToolChain.py
@@ -57,14 +57,14 @@
 
     def shouldUseClangCompiler(self, action):
         # If user requested no clang, or this isn't a "compile" phase,
-        # or this isn't a C family option, then don't use clang.
+        # or this isn't an input clang understands, then don't use clang.
         if (self.driver.cccNoClang or 
             not isinstance(action.phase, (Phases.PreprocessPhase,
                                           Phases.CompilePhase,
                                           Phases.SyntaxOnlyPhase,
                                           Phases.EmitLLVMPhase,
                                           Phases.PrecompilePhase)) or
-            action.inputs[0].type not in Types.cTypesSet):
+            action.inputs[0].type not in Types.clangableTypesSet):
             return False
 
         if self.driver.cccNoClangPreprocessor:
diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py
index 53fe38d..f4b8683 100644
--- a/tools/ccc/ccclib/Tools.py
+++ b/tools/ccc/ccclib/Tools.py
@@ -193,7 +193,13 @@
         elif outputType is Types.LLVMBCType:
             cmd_args.append('-emit-llvm-bc')
         elif outputType is Types.AsmTypeNoPP:
-            cmd_args.append('-S')
+            # FIXME: This is hackish, it would be better if we had the
+            # action instead of just looking at types.
+            assert len(inputs) == 1
+            if inputs[0].type is Types.AsmType:
+                cmd_args.append('-E')
+            else:
+                cmd_args.append('-S')
         elif (inputs[0].type.preprocess and 
               outputType is inputs[0].type.preprocess):
             cmd_args.append('-E')
@@ -453,7 +459,9 @@
         """getCC1Name(type) -> name, use-cpp, is-cxx"""
         
         # FIXME: Get bool results from elsewhere.
-        if type is Types.CType or type is Types.CHeaderType:
+        if type is Types.AsmType:
+            return 'cc1',True,False
+        elif type is Types.CType or type is Types.CHeaderType:
             return 'cc1',True,False
         elif type is Types.CTypeNoPP or type is Types.CHeaderNoPPType:
             return 'cc1',False,False
diff --git a/tools/ccc/ccclib/Types.py b/tools/ccc/ccclib/Types.py
index 94c0041..77e7907 100644
--- a/tools/ccc/ccclib/Types.py
+++ b/tools/ccc/ccclib/Types.py
@@ -148,14 +148,15 @@
 }
 
 # Set of C family types.
-cTypesSet = set([CType, CTypeNoPP, 
-                 ObjCType, ObjCTypeNoPP,
-                 CXXType, CXXTypeNoPP,
-                 ObjCXXType, ObjCXXTypeNoPP,
-                 CHeaderType, CHeaderNoPPType,
-                 ObjCHeaderType, ObjCHeaderNoPPType,
-                 CXXHeaderType, CXXHeaderNoPPType,
-                 ObjCXXHeaderType, ObjCXXHeaderNoPPType])
+clangableTypesSet = set([AsmType, # Assembler to preprocess
+                         CType, CTypeNoPP, 
+                         ObjCType, ObjCTypeNoPP,
+                         CXXType, CXXTypeNoPP,
+                         ObjCXXType, ObjCXXTypeNoPP,
+                         CHeaderType, CHeaderNoPPType,
+                         ObjCHeaderType, ObjCHeaderNoPPType,
+                         CXXHeaderType, CXXHeaderNoPPType,
+                         ObjCXXHeaderType, ObjCXXHeaderNoPPType])
 
 # Set of C++ family types.
 cxxTypesSet = set([CXXType, CXXTypeNoPP,