forked from OSchip/llvm-project
clang-cl: Allow /Fo without an argument (PR21589)
When it's used without an argument, the default file name is used. The same goes for /Fe. Also, allow using /Fo, /Fa and /Fe with multiple inputs if they don't have an argument. llvm-svn: 222164
This commit is contained in:
parent
e30f11d9ee
commit
6164753e81
|
@ -1165,11 +1165,8 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
|
|||
// Diagnose misuse of /Fo.
|
||||
if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fo)) {
|
||||
StringRef V = A->getValue();
|
||||
if (V.empty()) {
|
||||
// It has to have a value.
|
||||
Diag(clang::diag::err_drv_missing_argument) << A->getSpelling() << 1;
|
||||
Args.eraseArg(options::OPT__SLASH_Fo);
|
||||
} else if (Inputs.size() > 1 && !llvm::sys::path::is_separator(V.back())) {
|
||||
if (Inputs.size() > 1 && !V.empty() &&
|
||||
!llvm::sys::path::is_separator(V.back())) {
|
||||
// Check whether /Fo tries to name an output file for multiple inputs.
|
||||
Diag(clang::diag::err_drv_out_file_argument_with_multiple_sources)
|
||||
<< A->getSpelling() << V;
|
||||
|
@ -1180,7 +1177,8 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
|
|||
// Diagnose misuse of /Fa.
|
||||
if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fa)) {
|
||||
StringRef V = A->getValue();
|
||||
if (Inputs.size() > 1 && !llvm::sys::path::is_separator(V.back())) {
|
||||
if (Inputs.size() > 1 && !V.empty() &&
|
||||
!llvm::sys::path::is_separator(V.back())) {
|
||||
// Check whether /Fa tries to name an asm file for multiple inputs.
|
||||
Diag(clang::diag::err_drv_out_file_argument_with_multiple_sources)
|
||||
<< A->getSpelling() << V;
|
||||
|
@ -1188,15 +1186,6 @@ void Driver::BuildActions(const ToolChain &TC, DerivedArgList &Args,
|
|||
}
|
||||
}
|
||||
|
||||
// Diagnose misuse of /Fe.
|
||||
if (Arg *A = Args.getLastArg(options::OPT__SLASH_Fe)) {
|
||||
if (A->getValue()[0] == '\0') {
|
||||
// It has to have a value.
|
||||
Diag(clang::diag::err_drv_missing_argument) << A->getSpelling() << 1;
|
||||
Args.eraseArg(options::OPT__SLASH_Fe);
|
||||
}
|
||||
}
|
||||
|
||||
// Diagnose misuse of /o.
|
||||
if (Arg *A = Args.getLastArg(options::OPT__SLASH_o)) {
|
||||
if (A->getValue()[0] == '\0') {
|
||||
|
|
|
@ -7,6 +7,9 @@
|
|||
// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=DEFAULT %s
|
||||
// DEFAULT: "-o" "cl-outputs.obj"
|
||||
|
||||
// RUN: %clang_cl /Fo -### -- %s 2>&1 | FileCheck -check-prefix=FoEMPTY %s
|
||||
// FoEMPTY: "-o" "cl-outputs.obj"
|
||||
|
||||
// RUN: %clang_cl /Foa -### -- %s 2>&1 | FileCheck -check-prefix=FoNAME %s
|
||||
// FoNAME: "-o" "a.obj"
|
||||
|
||||
|
@ -25,15 +28,15 @@
|
|||
// RUN: %clang_cl /Fo.. -### -- %s 2>&1 | FileCheck -check-prefix=FoCRAZY %s
|
||||
// FoCRAZY: "-o" "..obj"
|
||||
|
||||
// RUN: %clang_cl /Fo -### 2>&1 | FileCheck -check-prefix=FoMISSINGARG %s
|
||||
// FoMISSINGARG: error: argument to '/Fo' is missing (expected 1 value)
|
||||
|
||||
// RUN: %clang_cl /Foa.obj -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEERROR %s
|
||||
// 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-outputs.obj"
|
||||
|
||||
// RUN: %clang_cl /Fo -### -- %s %s 2>&1 | FileCheck -check-prefix=CHECK-MULTIPLESOURCEOK2 %s
|
||||
// CHECK-MULTIPLESOURCEOK2: "-o" "cl-outputs.obj"
|
||||
// CHECK-MULTIPLESOURCEOK2: "-o" "cl-outputs.obj"
|
||||
|
||||
// RUN: %clang_cl /c /oa -### -- %s 2>&1 | FileCheck -check-prefix=oNAME1 %s
|
||||
// oNAME1: "-o" "a.obj"
|
||||
|
@ -99,6 +102,10 @@
|
|||
// RUN: %clang_cl /Fefoo -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXT %s
|
||||
// FeNOEXT: "-out:foo.exe"
|
||||
|
||||
// RUN: %clang_cl /Fe -### -- %s 2>&1 | FileCheck -check-prefix=FeEMPTY %s
|
||||
// FeEMPTY-NOT: argument to '/Fe' is missing
|
||||
// FeEMPTY: "-out:cl-outputs.exe"
|
||||
|
||||
// RUN: %clang_cl /Fefoo /LD -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
|
||||
// RUN: %clang_cl /Fefoo /LDd -### -- %s 2>&1 | FileCheck -check-prefix=FeNOEXTDLL %s
|
||||
// FeNOEXTDLL: "-out:foo.dll"
|
||||
|
@ -136,9 +143,6 @@
|
|||
// FeDIRNAMEEXTDLL: "-out:foo.dir{{[/\\]+}}a.ext"
|
||||
// FeDIRNAMEEXTDLL: "-implib:foo.dir{{[/\\]+}}a.lib"
|
||||
|
||||
// RUN: %clang_cl /Fe -### 2>&1 | FileCheck -check-prefix=FeMISSINGARG %s
|
||||
// FeMISSINGARG: error: argument to '/Fe' is missing (expected 1 value)
|
||||
|
||||
// RUN: %clang_cl /Fefoo /Febar -### -- %s 2>&1 | FileCheck -check-prefix=FeOVERRIDE %s
|
||||
// FeOVERRIDE: "-out:bar.exe"
|
||||
|
||||
|
@ -214,6 +218,8 @@
|
|||
|
||||
// RUN: %clang_cl /FA -### -- %s 2>&1 | FileCheck -check-prefix=FA %s
|
||||
// FA: "-o" "cl-outputs.asm"
|
||||
// RUN: %clang_cl /FA /Fa -### -- %s 2>&1 | FileCheck -check-prefix=FaEMPTY %s
|
||||
// FaEMPTY: "-o" "cl-outputs.asm"
|
||||
// RUN: %clang_cl /FA /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
|
||||
// RUN: %clang_cl /Fafoo -### -- %s 2>&1 | FileCheck -check-prefix=FaNAME %s
|
||||
// FaNAME: "-o" "foo.asm"
|
||||
|
@ -227,6 +233,9 @@
|
|||
// FaDIRNAMEEXT: "-o" "foo.dir{{[/\\]+}}a.ext"
|
||||
// RUN: %clang_cl /Faa.asm -### -- %s %s 2>&1 | FileCheck -check-prefix=FaMULTIPLESOURCE %s
|
||||
// FaMULTIPLESOURCE: error: cannot specify '/Faa.asm' when compiling multiple source files
|
||||
// RUN: %clang_cl /Fa -### -- %s %s 2>&1 | FileCheck -check-prefix=FaMULTIPLESOURCEOK %s
|
||||
// FaMULTIPLESOURCEOK: "-o" "cl-outputs.asm"
|
||||
// FaMULTIPLESOURCEOK: "-o" "cl-outputs.asm"
|
||||
|
||||
// RUN: %clang_cl /P -### -- %s 2>&1 | FileCheck -check-prefix=P %s
|
||||
// P: "-E"
|
||||
|
|
Loading…
Reference in New Issue