[PATCH] clang-cl: Use .obj as object file extension instead of .o
Hans Wennborg
hans at chromium.org
Tue Aug 6 17:17:44 PDT 2013
Hi rnk,
Please take a look.
http://llvm-reviews.chandlerc.com/D1305
Files:
include/clang/Driver/Driver.h
include/clang/Driver/Types.h
lib/Driver/Driver.cpp
lib/Driver/Types.cpp
test/Driver/cl-Fo.c
Index: include/clang/Driver/Driver.h
===================================================================
--- include/clang/Driver/Driver.h
+++ include/clang/Driver/Driver.h
@@ -129,6 +129,9 @@
/// 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: include/clang/Driver/Types.h
===================================================================
--- include/clang/Driver/Types.h
+++ include/clang/Driver/Types.h
@@ -34,7 +34,7 @@
/// 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: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1589,7 +1589,8 @@
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 @@
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 @@
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: lib/Driver/Types.cpp
===================================================================
--- lib/Driver/Types.cpp
+++ lib/Driver/Types.cpp
@@ -44,7 +44,9 @@
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 @@
.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: test/Driver/cl-Fo.c
===================================================================
--- test/Driver/cl-Fo.c
+++ test/Driver/cl-Fo.c
@@ -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"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1305.1.patch
Type: text/x-patch
Size: 4858 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130806/dd719b46/attachment.bin>
More information about the cfe-commits
mailing list