forked from OSchip/llvm-project
Options: Use AliasArgs for -O -> -O2 translation.
This way we can do the translation in the .td file rather than manually. llvm-svn: 187583
This commit is contained in:
parent
0344cdfe39
commit
a203b50317
|
@ -220,6 +220,7 @@ def ObjCXX : Flag<["-"], "ObjC++">, Flags<[DriverOption]>,
|
|||
def ObjC : Flag<["-"], "ObjC">, Flags<[DriverOption]>,
|
||||
HelpText<"Treat source input files as Objective-C inputs">;
|
||||
def O : Joined<["-"], "O">, Group<O_Group>, Flags<[CC1Option]>;
|
||||
def O_flag : Flag<["-"], "O">, Flags<[CC1Option]>, Alias<O>, AliasArgs<["2"]>;
|
||||
def Ofast : Joined<["-"], "Ofast">, Group<O_Group>, Flags<[CC1Option]>;
|
||||
def P : Flag<["-"], "P">, Flags<[CC1Option]>,
|
||||
HelpText<"Disable linemarker output in -E mode">;
|
||||
|
|
|
@ -2705,14 +2705,10 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
// preprocessed inputs and configure concludes that -fPIC is not supported.
|
||||
Args.ClaimAllArgs(options::OPT_D);
|
||||
|
||||
// Manually translate -O to -O2 and -O4 to -O3; let clang reject
|
||||
// others.
|
||||
// Manually translate -O4 to -O3; let clang reject others.
|
||||
if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
|
||||
if (A->getOption().matches(options::OPT_O4))
|
||||
CmdArgs.push_back("-O3");
|
||||
else if (A->getOption().matches(options::OPT_O) &&
|
||||
A->getValue()[0] == '\0')
|
||||
CmdArgs.push_back("-O2");
|
||||
else
|
||||
A->render(Args, CmdArgs);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// Test that we parse and translate the -O option correctly.
|
||||
|
||||
// RUN: %clang -O -### %s 2>&1 | FileCheck -check-prefix=CHECK-O %s
|
||||
// CHECK-O: -O2
|
||||
|
||||
// RUN: %clang -O0 -### %s 2>&1 | FileCheck -check-prefix=CHECK-O0 %s
|
||||
// CHECK-O0: -O0
|
||||
|
||||
// RUN: %clang -O1 -### %s 2>&1 | FileCheck -check-prefix=CHECK-O1 %s
|
||||
// CHECK-O1: -O1
|
Loading…
Reference in New Issue