[cfe-commits] r127769 - /cfe/trunk/lib/Driver/Driver.cpp

Joerg Sonnenberger joerg at bec.de
Wed Mar 16 15:45:03 PDT 2011


Author: joerg
Date: Wed Mar 16 17:45:02 2011
New Revision: 127769

URL: http://llvm.org/viewvc/llvm-project?rev=127769&view=rev
Log:
Use C as fallback type if in C preprocessor mode.

Modified:
    cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=127769&r1=127768&r2=127769&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Mar 16 17:45:02 2011
@@ -725,14 +725,19 @@
             Diag(clang::diag::err_drv_unknown_stdin_type);
           Ty = types::TY_C;
         } else {
-          // Otherwise lookup by extension, and fallback to ObjectType if not
-          // found. We use a host hook here because Darwin at least has its own
+          // Otherwise lookup by extension.
+          // Fallback is C if invoked as C preprocessor or Object otherwise.
+          // 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 = TC.LookupTypeForExtension(Ext + 1);
 
-          if (Ty == types::TY_INVALID)
-            Ty = types::TY_Object;
+          if (Ty == types::TY_INVALID) {
+            if (CCCIsCPP)
+              Ty = types::TY_C;
+            else
+              Ty = types::TY_Object;
+          }
 
           // If the driver is invoked as C++ compiler (like clang++ or c++) it
           // should autodetect some input files as C++ for g++ compatibility.





More information about the cfe-commits mailing list