[clang-cl] [Driver] Fix clang-cl driver supported colon options (#88216)
Tested locally against msvc 1939. MSVC supports the colon form of various options that take a path even though that isn't documented for all options on MSDN. I added the colon form for all supported msvc options that clang-cl does not intentionally ignore due to being unsupported. I also fixed the existing colon options by ensure we use `JoinedOrSeparate`. `/F[x]` argument must used within the same command line argument. However, `/F[x]:` arguments are allowed to span a command line argument. The following is valid `/F[x]: path` which is 2 separate command line arguments. You can see this documented here, https://learn.microsoft.com/en-us/cpp/build/reference/fo-object-file-name?view=msvc-170, where it says `/Fo:[ ]"pathname"`. This behaviour works for all colon options that take a path and I tested it locally against msvc 1939 for all the option changes in this PR.
This commit is contained in:
@@ -8346,14 +8346,15 @@ def _SLASH_FI : CLJoinedOrSeparate<"FI">,
|
||||
def _SLASH_Fe : CLJoined<"Fe">,
|
||||
HelpText<"Set output executable file name">,
|
||||
MetaVarName<"<file or dir/>">;
|
||||
def _SLASH_Fe_COLON : CLJoined<"Fe:">, Alias<_SLASH_Fe>;
|
||||
def _SLASH_Fe_COLON : CLJoinedOrSeparate<"Fe:">, Alias<_SLASH_Fe>;
|
||||
def _SLASH_Fi : CLCompileJoined<"Fi">,
|
||||
HelpText<"Set preprocess output file name (with /P)">,
|
||||
MetaVarName<"<file>">;
|
||||
def _SLASH_Fi_COLON : CLJoinedOrSeparate<"Fi:">, Alias<_SLASH_Fi>;
|
||||
def _SLASH_Fo : CLCompileJoined<"Fo">,
|
||||
HelpText<"Set output object file (with /c)">,
|
||||
MetaVarName<"<file or dir/>">;
|
||||
def _SLASH_Fo_COLON : CLCompileJoined<"Fo:">, Alias<_SLASH_Fo>;
|
||||
def _SLASH_Fo_COLON : CLCompileJoinedOrSeparate<"Fo:">, Alias<_SLASH_Fo>;
|
||||
def _SLASH_guard : CLJoined<"guard:">,
|
||||
HelpText<"Enable Control Flow Guard with /guard:cf, or only the table with /guard:cf,nochecks. "
|
||||
"Enable EH Continuation Guard with /guard:ehcont">;
|
||||
@@ -8448,6 +8449,7 @@ def _SLASH_Zc_dllexportInlines_ : CLFlag<"Zc:dllexportInlines-">,
|
||||
HelpText<"Do not dllexport/dllimport inline member functions of dllexport/import classes">;
|
||||
def _SLASH_Fp : CLJoined<"Fp">,
|
||||
HelpText<"Set pch file name (with /Yc and /Yu)">, MetaVarName<"<file>">;
|
||||
def _SLASH_Fp_COLON : CLJoinedOrSeparate<"Fp:">, Alias<_SLASH_Fp>;
|
||||
|
||||
def _SLASH_Gd : CLFlag<"Gd">,
|
||||
HelpText<"Set __cdecl as a default calling convention">;
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
|
||||
// RUN: %clang_cl /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXT %s
|
||||
// RUN: %clang_cl /Fe:foo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXT %s
|
||||
// RUN: %clang_cl /Fe: foo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXT %s
|
||||
// FeEXT: "-out:foo.ext"
|
||||
|
||||
// RUN: %clang_cl /LD /Fefoo.ext -### -- %s 2>&1 | FileCheck -check-prefix=FeEXTDLL %s
|
||||
@@ -270,6 +271,8 @@
|
||||
// P: "-o" "cl-outputs.i"
|
||||
|
||||
// RUN: %clang_cl /P /Fifoo -### -- %s 2>&1 | FileCheck -check-prefix=Fi1 %s
|
||||
// RUN: %clang_cl /P /Fi:foo -### -- %s 2>&1 | FileCheck -check-prefix=Fi1 %s
|
||||
// RUN: %clang_cl /P /Fi: foo -### -- %s 2>&1 | FileCheck -check-prefix=Fi1 %s
|
||||
// Fi1: "-E"
|
||||
// Fi1: "-o" "foo.i"
|
||||
|
||||
@@ -302,6 +305,7 @@
|
||||
// RELATIVE_OBJPATH1: "-object-file-name=a.obj"
|
||||
|
||||
// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo:a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
|
||||
// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fo: a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH1_COLON %s
|
||||
// RELATIVE_OBJPATH1_COLON: "-object-file-name=a.obj"
|
||||
|
||||
// RUN: %clang_cl -fdebug-compilation-dir=. /Z7 /Fofoo/a.obj -### -- %s 2>&1 | FileCheck -check-prefix=RELATIVE_OBJPATH2 %s
|
||||
|
||||
@@ -99,6 +99,12 @@
|
||||
// /Yu /Fpout.pch => out.pch is filename
|
||||
// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fpout.pch /c -### -- %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK-YUFP1 %s
|
||||
// /Yu /Fp:out.pch => out.pch is filename
|
||||
// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fp:out.pch /c -### -- %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK-YUFP1 %s
|
||||
// /Yu /Fp: out.pch => out.pch is filename
|
||||
// RUN: %clang_cl -Werror /Yupchfile.h /FIpchfile.h /Fp: out.pch /c -### -- %s 2>&1 \
|
||||
// RUN: | FileCheck -check-prefix=CHECK-YUFP1 %s
|
||||
// Use .pch file, but don't build it.
|
||||
// CHECK-YUFP1: -include-pch
|
||||
// CHECK-YUFP1: out.pch
|
||||
|
||||
Reference in New Issue
Block a user