diff options
| author | Hans Wennborg <hans@hanshq.net> | 2013-08-01 16:21:57 +0000 |
|---|---|---|
| committer | Hans Wennborg <hans@hanshq.net> | 2013-08-01 16:21:57 +0000 |
| commit | a203b503177ba8cfac1351b55b8f4b113bb6fe24 (patch) | |
| tree | 39a01f1bdbde74084d162a125ee2f5fa9da013b8 /clang | |
| parent | 0344cdfe390842fd62e73a8a0cb4eb495c355076 (diff) | |
| download | bcm5719-llvm-a203b503177ba8cfac1351b55b8f4b113bb6fe24.tar.gz bcm5719-llvm-a203b503177ba8cfac1351b55b8f4b113bb6fe24.zip | |
Options: Use AliasArgs for -O -> -O2 translation.
This way we can do the translation in the .td file rather than manually.
llvm-svn: 187583
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/Driver/Options.td | 1 | ||||
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 6 | ||||
| -rw-r--r-- | clang/test/Driver/O.c | 10 |
3 files changed, 12 insertions, 5 deletions
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c03770095d8..e532b3751d3 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -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">; diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index bc003facba0..20dbaaddb0c 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -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); } diff --git a/clang/test/Driver/O.c b/clang/test/Driver/O.c new file mode 100644 index 00000000000..a7dedc860cf --- /dev/null +++ b/clang/test/Driver/O.c @@ -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 |

