break;
}
+ // If you add more args here, also add them to the block below that
+ // starts with "// If CollectArgsForIntegratedAssembler() isn't called below".
+
// When passing -I arguments to the assembler we sometimes need to
// unconditionally take the next argument. For example, when parsing
// '-Wa,-I -Wa,foo' we need to accept the -Wa,foo arg after seeing the
// Select the appropriate action.
RewriteKind rewriteKind = RK_None;
+ // If CollectArgsForIntegratedAssembler() isn't called below, claim the args
+ // it claims when not running an assembler. Otherwise, clang would emit
+ // "argument unused" warnings for assembler flags when e.g. adding "-E" to
+ // flags while debugging something. That'd be somewhat inconvenient, and it's
+ // also inconsistent with most other flags -- we don't warn on
+ // -ffunction-sections not being used in -E mode either for example, even
+ // though it's not really used either.
+ if (!isa<AssembleJobAction>(JA)) {
+ // The args claimed here should match the args used in
+ // CollectArgsForIntegratedAssembler().
+ if (TC.useIntegratedAs()) {
+ Args.ClaimAllArgs(options::OPT_mrelax_all);
+ Args.ClaimAllArgs(options::OPT_mno_relax_all);
+ Args.ClaimAllArgs(options::OPT_mincremental_linker_compatible);
+ Args.ClaimAllArgs(options::OPT_mno_incremental_linker_compatible);
+ switch (C.getDefaultToolChain().getArch()) {
+ case llvm::Triple::arm:
+ case llvm::Triple::armeb:
+ case llvm::Triple::thumb:
+ case llvm::Triple::thumbeb:
+ Args.ClaimAllArgs(options::OPT_mimplicit_it_EQ);
+ default:
+ break;
+ }
+ }
+ Args.ClaimAllArgs(options::OPT_Wa_COMMA);
+ Args.ClaimAllArgs(options::OPT_Xassembler);
+ }
+
if (isa<AnalyzeJobAction>(JA)) {
assert(JA.getType() == types::TY_Plist && "Invalid output type.");
CmdArgs.push_back("-analyze");
// RUN: | FileCheck %s
// CHECK: "-I" "foo_dir"
+
+// Test that assembler options don't cause warnings when there's no assembler
+// stage.
+
+// RUN: %clang -mincremental-linker-compatible -E \
+// RUN: -o /dev/null -x c++ %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mincremental-linker-compatible -E \
+// RUN: -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN: -o /dev/null -x c++ %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mimplicit-it=always -target armv7-linux-gnueabi -E \
+// RUN: -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -Wa,-mbig-obj -target i386-pc-windows -E \
+// RUN: -o /dev/null -x c++ %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -Wa,-mbig-obj -target i386-pc-windows -E \
+// RUN: -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -Xassembler -mbig-obj -target i386-pc-windows -E \
+// RUN: -o /dev/null -x c++ %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -Xassembler -mbig-obj -target i386-pc-windows -E \
+// RUN: -o /dev/null -x assembler-with-cpp %s 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// NOWARN-NOT: unused
+
+// Test that unsupported arguments do not cause errors when -fno-integrated-as
+// is set.
+// RUN: %clang -Wa,-mno-warn-deprecated -fno-integrated-as %s -S 2>&1 \
+// RUN: | FileCheck --check-prefix=NOERROR --allow-empty %s
+// NOERROR-NOT: error: unsupported argument '-mno-warn-deprecated' to option 'Wa,'
+
+// -Wa flags shouldn't cause warnings without an assembler stage with
+// -fno-integrated-as either.
+// RUN: %clang -Wa,-mno-warn-deprecated -fno-integrated-as %s -S 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+
+// But -m flags for the integrated assembler _should_ warn if the integrated
+// assembler is not in use.
+// RUN: %clang -mrelax-all -fintegrated-as %s -S 2>&1 \
+// RUN: | FileCheck --check-prefix=NOWARN --allow-empty %s
+// RUN: %clang -mrelax-all -fno-integrated-as %s -S 2>&1 \
+// RUN: | FileCheck --check-prefix=WARN --allow-empty %s
+// WARN: unused