r187840 - clang-cl: Use .obj as object file extension instead of .o
Hans Wennborg
hans at hanshq.net
Tue Aug 6 17:32:16 PDT 2013
Author: hans
Date: Tue Aug 6 19:32:15 2013
New Revision: 187840
URL: http://llvm.org/viewvc/llvm-project?rev=187840&view=rev
Log:
clang-cl: Use .obj as object file extension instead of .o
Differential Revision: http://llvm-reviews.chandlerc.com/D1302
Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Types.h
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Types.cpp
cfe/trunk/test/Driver/cl-Fo.c
Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=187840&r1=187839&r2=187840&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue Aug 6 19:32:15 2013
@@ -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;
Modified: cfe/trunk/include/clang/Driver/Types.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.h?rev=187840&r1=187839&r2=187840&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Types.h (original)
+++ cfe/trunk/include/clang/Driver/Types.h Tue Aug 6 19:32:15 2013
@@ -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);
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=187840&r1=187839&r2=187840&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Aug 6 19:32:15 2013
@@ -1589,7 +1589,8 @@ const char *Driver::GetNamedOutputPath(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(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(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()));
}
}
Modified: cfe/trunk/lib/Driver/Types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=187840&r1=187839&r2=187840&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Types.cpp (original)
+++ cfe/trunk/lib/Driver/Types.cpp Tue Aug 6 19:32:15 2013
@@ -44,7 +44,9 @@ types::ID types::getPreprocessedType(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(
.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)
Modified: cfe/trunk/test/Driver/cl-Fo.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-Fo.c?rev=187840&r1=187839&r2=187840&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-Fo.c (original)
+++ cfe/trunk/test/Driver/cl-Fo.c Tue Aug 6 19:32:15 2013
@@ -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"
More information about the cfe-commits
mailing list