llvm-project/clang/test/Driver/disable-llvm.c
Fangrui Song 8d9d27db47 [Driver] Add -Xclang= as an alias for -Xclang
Driver options taking a value typically use `=` as the separator, instead of a
space. Unfortunately many older driver options do not stick with the rule, but I
find -Xclang used a lot and will be convenient if -Xclang= exists.

For build systems using a string array instead of a string to indicate compiler options,
`["-Xclang=-foo"]` is more convenient than `["-Xclang", "-foo"]`.
If a tool wants to filter out -Xclang=-foo, it is trivial for the `=` form, but
complex for the space separated form.

Reviewed By: jhuber6

Differential Revision: https://reviews.llvm.org/D131455
2022-08-08 19:05:24 -07:00

27 lines
1.1 KiB
C

// 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"
//
// We also support two alternative spellings for historical reasons.
// RUN: %clang -O2 -Xclang -disable-llvm-optzns -### %s 2>&1 \
// RUN: | FileCheck --check-prefix=DISABLED-LEGACY %s
// RUN: %clang -O2 -mllvm -disable-llvm-optzns -### %s 2>&1 \
// RUN: | FileCheck --check-prefix=DISABLED-LEGACY %s
// DISABLED-LEGACY: -cc1
// DISABLED-LEGACY-NOT: "-mllvm" "-disable-llvm-optzns"
// DISABLED-LEGACY: "-disable-llvm-optzns"
//
// The main flag shouldn't be specially handled when used with '-mllvm'.
// RUN: %clang -O2 -mllvm -disable-llvm-passes -### %s 2>&1 | FileCheck --check-prefix=MLLVM %s
// MLLVM: -cc1
// MLLVM-NOT: -disable-llvm-passes
// MLLVM: "-mllvm" "-disable-llvm-passes"
// MLLVM-NOT: -disable-llvm-passes