r270614 - clang-cl: Bake /Ob0 and /Ob2 into the general /O option handling

Hans Wennborg via cfe-commits cfe-commits at lists.llvm.org
Tue May 24 14:23:30 PDT 2016


Author: hans
Date: Tue May 24 16:23:29 2016
New Revision: 270614

URL: http://llvm.org/viewvc/llvm-project?rev=270614&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/Driver/CLCompatOptions.td
    cfe/trunk/lib/Driver/MSVCToolChain.cpp
    cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=270614&r1=270613&r2=270614&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue May 24 16:23:29 2016
@@ -100,10 +100,6 @@ def _SLASH_J : CLFlag<"J">, HelpText<"Ma
 def _SLASH_O0 : CLFlag<"O0">, Alias<O0>;
 // /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<fno_inline>;
-def _SLASH_Ob2 : CLFlag<"Ob2">, HelpText<"Enable inlining">,
-  Alias<finline_functions>;
 def _SLASH_Od : CLFlag<"Od">, HelpText<"Disable optimization">, Alias<O0>;
 def _SLASH_Oi : CLFlag<"Oi">, HelpText<"Enable use of builtin functions">,
   Alias<fbuiltin>;

Modified: cfe/trunk/lib/Driver/MSVCToolChain.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/MSVCToolChain.cpp?rev=270614&r1=270613&r2=270614&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/MSVCToolChain.cpp (original)
+++ cfe/trunk/lib/Driver/MSVCToolChain.cpp Tue May 24 16:23:29 2016
@@ -722,8 +722,20 @@ static void TranslateOptArg(Arg *A, llvm
       }
       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;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=270614&r1=270613&r2=270614&view=diff
==============================================================================
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue May 24 16:23:29 2016
@@ -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




More information about the cfe-commits mailing list