]> granicus.if.org Git - clang/commitdiff
clang-cl: Use .obj as object file extension instead of .o
authorHans Wennborg <hans@hanshq.net>
Wed, 7 Aug 2013 00:32:15 +0000 (00:32 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 7 Aug 2013 00:32:15 +0000 (00:32 +0000)
Differential Revision: http://llvm-reviews.chandlerc.com/D1302

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@187840 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
include/clang/Driver/Types.h
lib/Driver/Driver.cpp
lib/Driver/Types.cpp
test/Driver/cl-Fo.c

index b2db31845f794e46cdab6b699e34f67b48b7a777..dad25e8be64cef140b2d314477a2fbed39e7c097 100644 (file)
@@ -129,6 +129,9 @@ public:
   /// Whether the driver is just the preprocessor.
   bool CCCIsCPP() const { return Mode == CPPMode; }
 
+  /// Whether the driver should follow cl.exe like behavior.
+  bool IsCLMode() const { return Mode == CLMode; }
+
   /// Only print tool bindings, don't build any jobs.
   unsigned CCCPrintBindings : 1;
 
index be5015e843a4e6a9fafc510271a780d1dc156fba..cca576a054aa5f7a059fed1a24aede062b542e32 100644 (file)
@@ -34,7 +34,7 @@ namespace types {
 
   /// getTypeTempSuffix - Return the suffix to use when creating a
   /// temp file of this type, or null if unspecified.
-  const char *getTypeTempSuffix(ID Id);
+  const char *getTypeTempSuffix(ID Id, bool CLMode = false);
 
   /// onlyAssembleType - Should this type only be assembled.
   bool onlyAssembleType(ID Id);
index 729b9afe62ee18b7f4175aadd2eb0780839e82e4..3fddc8fe6e96257d60c184b63c1826f5ab52871b 100644 (file)
@@ -1589,7 +1589,8 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
     StringRef Name = llvm::sys::path::filename(BaseInput);
     std::pair<StringRef, StringRef> Split = Name.split('.');
     std::string TmpName =
-      GetTemporaryPath(Split.first, types::getTypeTempSuffix(JA.getType()));
+      GetTemporaryPath(Split.first,
+          types::getTypeTempSuffix(JA.getType(), IsCLMode()));
     return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
   }
 
@@ -1620,8 +1621,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
       if (llvm::sys::path::has_extension(Filename.str()))
         Filename = Filename.substr(0, Filename.rfind("."));
       Filename.append(".");
-      // FIXME: For clang-cl, we want .obj rather than .o for object files.
-      Filename.append(types::getTypeTempSuffix(types::TY_Object));
+      Filename.append(types::getTypeTempSuffix(types::TY_Object, IsCLMode()));
     }
 
     NamedOutput = C.getArgs().MakeArgString(Filename.c_str());
@@ -1665,7 +1665,8 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
       StringRef Name = llvm::sys::path::filename(BaseInput);
       std::pair<StringRef, StringRef> Split = Name.split('.');
       std::string TmpName =
-        GetTemporaryPath(Split.first, types::getTypeTempSuffix(JA.getType()));
+        GetTemporaryPath(Split.first,
+            types::getTypeTempSuffix(JA.getType(), IsCLMode()));
       return C.addTempFile(C.getArgs().MakeArgString(TmpName.c_str()));
     }
   }
index 19870fe6fdad46d8ec1fc9299e43611ba0e17784..67ef2a6a835b149f7f7d06dcfb245da9b9f515db 100644 (file)
@@ -44,7 +44,9 @@ types::ID types::getPreprocessedType(ID Id) {
   return getInfo(Id).PreprocessedType;
 }
 
-const char *types::getTypeTempSuffix(ID Id) {
+const char *types::getTypeTempSuffix(ID Id, bool CLMode) {
+  if (Id == TY_Object && CLMode)
+    return "obj";
   return getInfo(Id).TempSuffix;
 }
 
@@ -135,6 +137,7 @@ types::ID types::lookupTypeForExtension(const char *Ext) {
            .Case("s", TY_PP_Asm)
            .Case("S", TY_Asm)
            .Case("o", TY_Object)
+           .Case("obj", TY_Object)
            .Case("ii", TY_PP_CXX)
            .Case("mi", TY_PP_ObjC)
            .Case("mm", TY_ObjCXX)
index b820f0dcefd3d9255d0772c90c0c1d4201a4de1b..fe3d58d46baddfb2dc38938ae4740a5efdf7b67c 100644 (file)
@@ -5,23 +5,23 @@
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
 // RUN: %clang_cl /Foa -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-NAME %s
-// CHECK-NAME:  "-o" "a.o"
+// CHECK-NAME:  "-o" "a.obj"
 
 // RUN: %clang_cl /Foa.ext /Fob.ext -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-NAMEEXT %s
 // CHECK-NAMEEXT:  warning: overriding '/Foa.ext' option with '/Fob.ext'
 // CHECK-NAMEEXT:  "-o" "b.ext"
 
 // RUN: %clang_cl /Fofoo.dir/ -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-DIR %s
-// CHECK-DIR:  "-o" "foo.dir{{[/\\]+}}cl-Fo.o"
+// CHECK-DIR:  "-o" "foo.dir{{[/\\]+}}cl-Fo.obj"
 
 // RUN: %clang_cl /Fofoo.dir/a -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-DIRNAME %s
-// CHECK-DIRNAME:  "-o" "foo.dir{{[/\\]+}}a.o"
+// CHECK-DIRNAME:  "-o" "foo.dir{{[/\\]+}}a.obj"
 
 // RUN: %clang_cl /Fofoo.dir/a.ext -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-DIRNAMEEXT %s
 // CHECK-DIRNAMEEXT:  "-o" "foo.dir{{[/\\]+}}a.ext"
 
 // RUN: %clang_cl /Fo.. -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-CRAZY %s
-// CHECK-CRAZY:  "-o" "...o"
+// CHECK-CRAZY:  "-o" "...obj"
 
 
 // RUN: %clang_cl /Fo -### 2>&1 | FileCheck -check-prefix=CHECK-MISSINGARG %s
@@ -31,4 +31,4 @@
 // CHECK-MULTIPLESOURCEERROR: error: cannot specify '/Foa.obj' when compiling multiple source files
 
 // RUN: %clang_cl /Fomydir/ -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEOK %s
-// CHECK-MULTIPLESOURCEOK: "-o" "mydir{{[/\\]+}}cl-Fo.o"
+// CHECK-MULTIPLESOURCEOK: "-o" "mydir{{[/\\]+}}cl-Fo.obj"