clang-cl: Use .obj as object file extension instead of .o

Differential Revision: http://llvm-reviews.chandlerc.com/D1302

llvm-svn: 187840
This commit is contained in:
Hans Wennborg 2013-08-07 00:32:15 +00:00
parent a3ae94e83f
commit 0a0faa98d1
5 changed files with 18 additions and 11 deletions

View 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;

View 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);

View 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()));
}
}

View 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)

View 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"