[cfe-commits] r155981 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/fpack-struct.c
James Molloy
james.molloy at arm.com
Wed May 2 00:56:14 PDT 2012
Author: jamesm
Date: Wed May 2 02:56:14 2012
New Revision: 155981
URL: http://llvm.org/viewvc/llvm-project?rev=155981&view=rev
Log:
Fix forwarding of -fpack-struct from driver to CC1, and add a test.
-fpack-struct's handling has changed in CC1 (one of only two flags that needed changing) because the driver treats "-fpack-struct" as a boolean flag, and CC1 (did) treat it as an option with a separated value.
This change causes -fpack-struct=X to be forwarded correctly to -fpack-struct=X instead of erroneously to "-fpack-struct X"
Added:
cfe/trunk/test/Driver/fpack-struct.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=155981&r1=155980&r2=155981&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed May 2 02:56:14 2012
@@ -2500,12 +2500,12 @@
// Honor -fpack-struct= and -fpack-struct, if given. Note that
// -fno-pack-struct doesn't apply to -fpack-struct=.
if (Arg *A = Args.getLastArg(options::OPT_fpack_struct_EQ)) {
- CmdArgs.push_back("-fpack-struct");
- CmdArgs.push_back(A->getValue(Args));
+ std::string PackStructStr = "-fpack-struct=";
+ PackStructStr += A->getValue(Args);
+ CmdArgs.push_back(Args.MakeArgString(PackStructStr));
} else if (Args.hasFlag(options::OPT_fpack_struct,
options::OPT_fno_pack_struct, false)) {
- CmdArgs.push_back("-fpack-struct");
- CmdArgs.push_back("1");
+ CmdArgs.push_back("-fpack-struct=1");
}
if (Args.hasArg(options::OPT_mkernel) ||
Added: cfe/trunk/test/Driver/fpack-struct.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fpack-struct.c?rev=155981&view=auto
==============================================================================
--- cfe/trunk/test/Driver/fpack-struct.c (added)
+++ cfe/trunk/test/Driver/fpack-struct.c Wed May 2 02:56:14 2012
@@ -0,0 +1,10 @@
+// RUN: %clang -fpack-struct -### %s 2> %t
+// RUN: FileCheck < %t %s
+// RUN: %clang -fpack-struct=8 -### %s 2> %t
+// RUN: FileCheck < %t %s --check-prefix=EQ
+
+// CHECK: "-cc1"
+// CHECK: "-fpack-struct=1"
+
+// CHECK-EQ: "-cc1"
+// CHECK-EQ: "-fpack-struct=8"
More information about the cfe-commits
mailing list