[cfe-commits] r111005 - in /cfe/trunk: include/clang/Driver/OptParser.td include/clang/Driver/OptTable.h include/clang/Driver/Option.h include/clang/Driver/Options.td lib/Driver/OptTable.cpp lib/Driver/Option.cpp test/Driver/gcc_forward.c
Daniel Dunbar
daniel at zuster.org
Thu Aug 12 21:44:20 PDT 2010
Author: ddunbar
Date: Thu Aug 12 23:44:20 2010
New Revision: 111005
URL: http://llvm.org/viewvc/llvm-project?rev=111005&view=rev
Log:
Driver/OptParser: Add a NoForward flag to prevent forwarding certain options to
GCC.
- Mark -Xclang and -mlinker-version= with it for now, although I am sure there
are more.
Added:
cfe/trunk/test/Driver/gcc_forward.c
Modified:
cfe/trunk/include/clang/Driver/OptParser.td
cfe/trunk/include/clang/Driver/OptTable.h
cfe/trunk/include/clang/Driver/Option.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/OptTable.cpp
cfe/trunk/lib/Driver/Option.cpp
Modified: cfe/trunk/include/clang/Driver/OptParser.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/OptParser.td?rev=111005&r1=111004&r2=111005&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/OptParser.td (original)
+++ cfe/trunk/include/clang/Driver/OptParser.td Thu Aug 12 23:44:20 2010
@@ -82,6 +82,9 @@
// arguments to implement hidden help groups.
def HelpHidden : OptionFlag;
+// NoForward - The option should not be implicitly forwarded to other tools.
+def NoForward : OptionFlag;
+
// Define the option group class.
class OptionGroup<string name> {
Modified: cfe/trunk/include/clang/Driver/OptTable.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/OptTable.h?rev=111005&r1=111004&r2=111005&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/OptTable.h (original)
+++ cfe/trunk/include/clang/Driver/OptTable.h Thu Aug 12 23:44:20 2010
@@ -25,10 +25,11 @@
HelpHidden = (1 << 1),
LinkerInput = (1 << 2),
NoArgumentUnused = (1 << 3),
- RenderAsInput = (1 << 4),
- RenderJoined = (1 << 5),
- RenderSeparate = (1 << 6),
- Unsupported = (1 << 7)
+ NoForward = (1 << 4),
+ RenderAsInput = (1 << 5),
+ RenderJoined = (1 << 6),
+ RenderSeparate = (1 << 7),
+ Unsupported = (1 << 8)
};
}
Modified: cfe/trunk/include/clang/Driver/Option.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Option.h?rev=111005&r1=111004&r2=111005&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Option.h (original)
+++ cfe/trunk/include/clang/Driver/Option.h Thu Aug 12 23:44:20 2010
@@ -92,6 +92,9 @@
/// This option should not report argument unused errors.
bool NoArgumentUnused : 1;
+ /// This option should not be implicitly forwarded.
+ bool NoForward : 1;
+
protected:
Option(OptionClass Kind, OptSpecifier ID, const char *Name,
const OptionGroup *Group, const Option *Alias);
@@ -124,7 +127,12 @@
bool hasNoArgumentUnused() const { return NoArgumentUnused; }
void setNoArgumentUnused(bool Value) { NoArgumentUnused = Value; }
- bool hasForwardToGCC() const { return !DriverOption && !LinkerInput; }
+ bool hasNoForward() const { return NoForward; }
+ void setNoForward(bool Value) { NoForward = Value; }
+
+ bool hasForwardToGCC() const {
+ return !NoForward && !DriverOption && !LinkerInput;
+ }
/// getUnaliasedOption - Return the final option this option
/// aliases (itself, if the option has no alias).
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=111005&r1=111004&r2=111005&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Aug 12 23:44:20 2010
@@ -180,7 +180,8 @@
def Xassembler : Separate<"-Xassembler">,
HelpText<"Pass <arg> to the assembler">, MetaVarName<"<arg>">;
def Xclang : Separate<"-Xclang">,
- HelpText<"Pass <arg> to the clang compiler">, MetaVarName<"<arg>">;
+ HelpText<"Pass <arg> to the clang compiler">, MetaVarName<"<arg>">,
+ Flags<[NoForward]>;
def Xlinker : Separate<"-Xlinker">, Flags<[LinkerInput, RenderAsInput]>,
HelpText<"Pass <arg> to the linker">, MetaVarName<"<arg>">;
def Xpreprocessor : Separate<"-Xpreprocessor">,
@@ -442,7 +443,7 @@
def miphoneos_version_min_EQ : Joined<"-miphoneos-version-min=">, Group<m_Group>;
def mios_version_min_EQ : Joined<"-mios-version-min=">, Alias<miphoneos_version_min_EQ>;
def mkernel : Flag<"-mkernel">, Group<m_Group>;
-def mlinker_version_EQ : Joined<"-mlinker-version=">;
+def mlinker_version_EQ : Joined<"-mlinker-version=">, Flags<[NoForward]>;
def mllvm : Separate<"-mllvm">;
def mmacosx_version_min_EQ : Joined<"-mmacosx-version-min=">, Group<m_Group>;
def mmmx : Flag<"-mmmx">, Group<m_x86_Features_Group>;
Modified: cfe/trunk/lib/Driver/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/OptTable.cpp?rev=111005&r1=111004&r2=111005&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/OptTable.cpp (original)
+++ cfe/trunk/lib/Driver/OptTable.cpp Thu Aug 12 23:44:20 2010
@@ -164,6 +164,8 @@
Opt->setLinkerInput(true);
if (info.Flags & NoArgumentUnused)
Opt->setNoArgumentUnused(true);
+ if (info.Flags & NoForward)
+ Opt->setNoForward(true);
if (info.Flags & RenderAsInput)
Opt->setNoOptAsInput(true);
if (info.Flags & RenderJoined) {
Modified: cfe/trunk/lib/Driver/Option.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Option.cpp?rev=111005&r1=111004&r2=111005&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Option.cpp (original)
+++ cfe/trunk/lib/Driver/Option.cpp Thu Aug 12 23:44:20 2010
@@ -20,7 +20,7 @@
const OptionGroup *_Group, const Option *_Alias)
: Kind(_Kind), ID(_ID.getID()), Name(_Name), Group(_Group), Alias(_Alias),
Unsupported(false), LinkerInput(false), NoOptAsInput(false),
- DriverOption(false), NoArgumentUnused(false) {
+ DriverOption(false), NoArgumentUnused(false), NoForward(false) {
// Multi-level aliases are not supported, and alias options cannot
// have groups. This just simplifies option tracking, it is not an
Added: cfe/trunk/test/Driver/gcc_forward.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/gcc_forward.c?rev=111005&view=auto
==============================================================================
--- cfe/trunk/test/Driver/gcc_forward.c (added)
+++ cfe/trunk/test/Driver/gcc_forward.c Thu Aug 12 23:44:20 2010
@@ -0,0 +1,13 @@
+// Check that we don't try to forward -Xclang or -mlinker-version to GCC.
+//
+// RUN: %clang -ccc-host-triple powerpc-unknown-unknown \
+// RUN: -ccc-clang-archs i386 -c %s \
+// RUN: -Xclang foo-bar \
+// RUN: -mlinker-version=10 -### 2> %t
+// RUN: FileCheck < %t %s
+//
+// CHECK: gcc{{.*}}"
+// CHECK-NOT: "-mlinker-version=10"
+// CHECK-NOT: "-Xclang"
+// CHECK-NOT: "foo-bar"
+// CHECK: gcc_forward
More information about the cfe-commits
mailing list