ccc: Implement support clang PTH using gcc PCH style interface.

This requires some hackery, as gcc's PCH mechanism changes behavior,
whereas while PTH is simply a cache. Notably:

 - Automatically cause clang to load a .pth file if we find one that
   matches a command line -include argument (similar to how gcc
   looks for .gch files).

 - When generating precompiled headers, translate the suffix from .gch
   to .pth (so we do not conflict with actual gcc PCH files).

 - When generating precompiled headers, copy the input header to the
   same location as the output PTH file. This is necessary because gcc
   supports -include xxx.h even if xxx.h doesn't exist, but for clang
   we need to actually have the contents of this file available.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62246 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/ccc/ccclib/ToolChain.py b/tools/ccc/ccclib/ToolChain.py
index 083ce38..8511328 100644
--- a/tools/ccc/ccclib/ToolChain.py
+++ b/tools/ccc/ccclib/ToolChain.py
@@ -76,12 +76,15 @@
     def selectTool(self, action):
         assert isinstance(action, Phases.JobAction)
         
-        if (self.driver.cccClang and
-            self.archName == 'i386' and
-            action.inputs[0].type in (Types.CType, Types.CTypeNoPP,
-                                      Types.ObjCType, Types.ObjCTypeNoPP) and
-            isinstance(action.phase, Phases.CompilePhase)):
-            return self.clangTool
+        if self.driver.cccClang and self.archName == 'i386':
+            if (action.inputs[0].type in (Types.CType, Types.CTypeNoPP,
+                                          Types.ObjCType, Types.ObjCTypeNoPP) and
+                isinstance(action.phase, Phases.CompilePhase)):
+                return self.clangTool
+            elif (action.inputs[0].type in (Types.CHeaderType, Types.CHeaderNoPPType,
+                                            Types.ObjCHeaderType, Types.ObjCHeaderNoPPType) and
+                  isinstance(action.phase, Phases.PrecompilePhase)):
+                return self.clangTool
 
         return self.toolMap[action.phase.__class__]