[PATCH] D131455: [Driver] Add -Xclang= as an alias for -Xclang

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 8 17:10:30 PDT 2022


MaskRay created this revision.
MaskRay added reviewers: jhuber6, rnk.
Herald added subscribers: jeroen.dobbelaere, StephenFan.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Driver options taking a value typically use `=` as the separator, instead of a
space. Not using a space also helps a dozen compiler driver wrappers which don't
want to know which options are `Separate`. Unfortunately many older driver
options do not stick with the rule, but I find -Xclang used a lot and will
provide convenience when -Xclang= is supported.

For build systems using a string array instead of a string to indicate compiler options,
`["-Xclang=-foo"]` is more convenient than `["-Xclang", "-foo"]`.

Note: there is a `=` precedence for `-X*` option: `-Xopenmp-target=`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131455

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/disable-llvm.c


Index: clang/test/Driver/disable-llvm.c
===================================================================
--- clang/test/Driver/disable-llvm.c
+++ clang/test/Driver/disable-llvm.c
@@ -1,6 +1,10 @@
 // We support a CC1 option for disabling LLVM's passes.
 // RUN: %clang -O2 -Xclang -disable-llvm-passes -### %s 2>&1 \
 // RUN:     | FileCheck --check-prefix=DISABLED %s
+
+// Try -Xclang=.
+// RUN: %clang -O2 -Xclang=-disable-llvm-passes -### %s 2>&1 \
+// RUN:     | FileCheck --check-prefix=DISABLED %s
 // DISABLED: -cc1
 // DISABLED-NOT: "-mllvm" "-disable-llvm-passes"
 // DISABLED: "-disable-llvm-passes"
Index: clang/include/clang/Driver/Options.td
===================================================================
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -817,6 +817,9 @@
 def Xclang : Separate<["-"], "Xclang">,
   HelpText<"Pass <arg> to the clang compiler">, MetaVarName<"<arg>">,
   Flags<[NoXarchOption, CoreOption]>, Group<CompileOnly_Group>;
+def : Joined<["-"], "Xclang=">,
+  HelpText<"Pass <arg> to the clang compiler">, MetaVarName<"<arg>">,
+  Flags<[NoXarchOption, CoreOption]>, Group<CompileOnly_Group>, Alias<Xclang>;
 def Xcuda_fatbinary : Separate<["-"], "Xcuda-fatbinary">,
   HelpText<"Pass <arg> to fatbinary invocation">, MetaVarName<"<arg>">;
 def Xcuda_ptxas : Separate<["-"], "Xcuda-ptxas">,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131455.451006.patch
Type: text/x-patch
Size: 1375 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220809/e4dd251b/attachment-0001.bin>


More information about the cfe-commits mailing list