From: Hans Wennborg Date: Tue, 24 May 2016 21:23:29 +0000 (+0000) Subject: clang-cl: Bake /Ob0 and /Ob2 into the general /O option handling X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b49e6f8c472760ae8c44318ea7e04b99a7a0a75e;p=clang clang-cl: Bake /Ob0 and /Ob2 into the general /O option handling This is a follow-up to r270609, wherein I forgot that /O options can be combined, and e.g. /Odb2 is a valid combination. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270614 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Driver/CLCompatOptions.td b/include/clang/Driver/CLCompatOptions.td index 3d98a65ec7..a6892e5671 100644 --- a/include/clang/Driver/CLCompatOptions.td +++ b/include/clang/Driver/CLCompatOptions.td @@ -100,10 +100,6 @@ def _SLASH_J : CLFlag<"J">, HelpText<"Make char type unsigned">, def _SLASH_O0 : CLFlag<"O0">, Alias; // /Oy- is handled by the /O option because /Oy- only has an effect on 32-bit. def _SLASH_O : CLJoined<"O">, HelpText<"Optimization level">; -def _SLASH_Ob0 : CLFlag<"Ob0">, HelpText<"Disable inlining">, - Alias; -def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">, - Alias; def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias; def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">, Alias; diff --git a/lib/Driver/MSVCToolChain.cpp b/lib/Driver/MSVCToolChain.cpp index 4af142de92..fb8d20be2f 100644 --- a/lib/Driver/MSVCToolChain.cpp +++ b/lib/Driver/MSVCToolChain.cpp @@ -722,8 +722,20 @@ static void TranslateOptArg(Arg *A, llvm::opt::DerivedArgList &DAL, } break; case 'b': - if (I + 1 != E && isdigit(OptStr[I + 1])) + if (I + 1 != E && isdigit(OptStr[I + 1])) { + switch (OptStr[I + 1]) { + case '0': + DAL.AddFlagArg(A, Opts.getOption(options::OPT_fno_inline)); + break; + case '1': + // TODO: Inline calls to 'inline functions' only. + break; + case '2': + DAL.AddFlagArg(A, Opts.getOption(options::OPT_finline_functions)); + break; + } ++I; + } break; case 'g': break; diff --git a/test/Driver/cl-options.c b/test/Driver/cl-options.c index 6a721fc9f8..2e68b18217 100644 --- a/test/Driver/cl-options.c +++ b/test/Driver/cl-options.c @@ -98,6 +98,7 @@ // Ob0: -fno-inline // RUN: %clang_cl /Ob2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s +// RUN: %clang_cl /Odb2 -### -- %s 2>&1 | FileCheck -check-prefix=Ob2 %s // Ob2: -finline-functions // RUN: %clang_cl /Od -### -- %s 2>&1 | FileCheck -check-prefix=Od %s