r194743 - Pass -Wa, -I and -Xassembler -I args to integrated assembler
David Peixotto
dpeixott at codeaurora.org
Thu Nov 14 14:52:58 PST 2013
Author: dpeixott
Date: Thu Nov 14 16:52:58 2013
New Revision: 194743
URL: http://llvm.org/viewvc/llvm-project?rev=194743&view=rev
Log:
Pass -Wa,-I and -Xassembler -I args to integrated assembler
This patch adds -I to the arguments that are passed to the
integrated assembler from -Wa, and -Xassembler args.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/integrated-as.s
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=194743&r1=194742&r2=194743&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Thu Nov 14 16:52:58 2013
@@ -1707,6 +1707,13 @@ static void CollectArgsForIntegratedAsse
if (UseRelaxAll(C, Args))
CmdArgs.push_back("-mrelax-all");
+ // When passing -I arguments to the assembler we sometimes need to
+ // uncontionally take the next argument. For example, when parsing
+ // '-Wa,-I -Wa,foo' we need to accept the -Wa,foo arg after seeing the
+ // -Wa,-I arg and when parsing '-Wa,-I,foo' we need to accept the 'foo'
+ // arg after parsing the '-I' arg.
+ bool TakeNextArg = false;
+
// When using an integrated assembler, translate -Wa, and -Xassembler
// options.
for (arg_iterator it = Args.filtered_begin(options::OPT_Wa_COMMA,
@@ -1717,6 +1724,11 @@ static void CollectArgsForIntegratedAsse
for (unsigned i = 0, e = A->getNumValues(); i != e; ++i) {
StringRef Value = A->getValue(i);
+ if (TakeNextArg) {
+ CmdArgs.push_back(Value.data());
+ TakeNextArg = false;
+ continue;
+ }
if (Value == "-force_cpusubtype_ALL") {
// Do nothing, this is the default and we don't support anything else.
@@ -1727,6 +1739,12 @@ static void CollectArgsForIntegratedAsse
CmdArgs.push_back("-fatal-assembler-warnings");
} else if (Value == "--noexecstack") {
CmdArgs.push_back("-mnoexecstack");
+ } else if (Value.startswith("-I")) {
+ CmdArgs.push_back(Value.data());
+ // We need to consume the next argument if the current arg is a plain
+ // -I. The next arg will be the include directory.
+ if (Value == "-I")
+ TakeNextArg = true;
} else {
D.Diag(diag::err_drv_unsupported_option_argument)
<< A->getOption().getName() << Value;
Modified: cfe/trunk/test/Driver/integrated-as.s
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/integrated-as.s?rev=194743&r1=194742&r2=194743&view=diff
==============================================================================
--- cfe/trunk/test/Driver/integrated-as.s (original)
+++ cfe/trunk/test/Driver/integrated-as.s Thu Nov 14 16:52:58 2013
@@ -10,3 +10,24 @@
// RUN: %clang -### -target x86_64-linux-gnu -c -integrated-as %s -fsanitize=address 2>&1 %s | FileCheck --check-prefix=SANITIZE %s
// SANITIZE: argument unused during compilation: '-fsanitize=address'
+
+// Test that -I params in -Wa, and -Xassembler args are passed to integrated assembler
+// RUN: %clang -### -c -integrated-as %s -Wa,-I,foo_dir 2>&1 %s | FileCheck --check-prefix=WA_INCLUDE1 %s
+// WA_INCLUDE1: cc1as
+// WA_INCLUDE1: "-I" "foo_dir"
+
+// RUN: %clang -### -c -integrated-as %s -Wa,-Ifoo_dir 2>&1 %s | FileCheck --check-prefix=WA_INCLUDE2 %s
+// WA_INCLUDE2: cc1as
+// WA_INCLUDE2: "-Ifoo_dir"
+
+// RUN: %clang -### -c -integrated-as %s -Wa,-I -Wa,foo_dir 2>&1 %s | FileCheck --check-prefix=WA_INCLUDE3 %s
+// WA_INCLUDE3: cc1as
+// WA_INCLUDE3: "-I" "foo_dir"
+
+// RUN: %clang -### -c -integrated-as %s -Xassembler -I -Xassembler foo_dir 2>&1 %s | FileCheck --check-prefix=XA_INCLUDE1 %s
+// XA_INCLUDE1: cc1as
+// XA_INCLUDE1: "-I" "foo_dir"
+
+// RUN: %clang -### -c -integrated-as %s -Xassembler -Ifoo_dir 2>&1 %s | FileCheck --check-prefix=XA_INCLUDE2 %s
+// XA_INCLUDE2: cc1as
+// XA_INCLUDE2: "-Ifoo_dir"
More information about the cfe-commits
mailing list