зеркало из https://github.com/microsoft/clang-1.git
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111005 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
914ed9d30e
Коммит
caeed1d3a5
|
@ -82,6 +82,9 @@ def Unsupported : OptionFlag;
|
|||
// 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> {
|
||||
|
|
|
@ -25,10 +25,11 @@ namespace options {
|
|||
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)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -92,6 +92,9 @@ namespace driver {
|
|||
/// 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 @@ namespace driver {
|
|||
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).
|
||||
|
|
|
@ -180,7 +180,8 @@ def Xarch__ : JoinedAndSeparate<"-Xarch_">, Flags<[DriverOption]>;
|
|||
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 mhard_float : Flag<"-mhard-float">, Group<m_Group>;
|
|||
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>;
|
||||
|
|
|
@ -164,6 +164,8 @@ Option *OptTable::CreateOption(unsigned id) const {
|
|||
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) {
|
||||
|
|
|
@ -20,7 +20,7 @@ Option::Option(OptionClass _Kind, OptSpecifier _ID, const char *_Name,
|
|||
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
|
||||
|
|
|
@ -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
|
Загрузка…
Ссылка в новой задаче