diff --git a/c/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp --- a/c/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -694,19 +694,23 @@ Opts.setInlining((Opts.OptimizationLevel == 0) ? CodeGenOptions::OnlyAlwaysInlining : CodeGenOptions::NormalInlining); - // Explicit inlining flags can disable some or all inlining even at - // optimization levels above zero. + // Handle inlining overrides if (Arg *InlineArg = Args.getLastArg( options::OPT_finline_functions, options::OPT_finline_hint_functions, options::OPT_fno_inline_functions, options::OPT_fno_inline)) { - if (Opts.OptimizationLevel > 0) { - const Option &InlineOpt = InlineArg->getOption(); - if (InlineOpt.matches(options::OPT_finline_functions)) - Opts.setInlining(CodeGenOptions::NormalInlining); - else if (InlineOpt.matches(options::OPT_finline_hint_functions)) - Opts.setInlining(CodeGenOptions::OnlyHintInlining); - else - Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); + const Option &InlineOpt = InlineArg->getOption(); + if (InlineOpt.matches(options::OPT_fno_inline)) { + Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); + } else if (InlineOpt.matches(options::OPT_fno_inline_functions)) { + Opts.setInlining(CodeGenOptions::OnlyAlwaysInlining); + } else if (InlineOpt.matches(options::OPT_finline_functions)) { + Opts.setInlining(CodeGenOptions::NormalInlining); + } else { + assert(InlineOpt.matches(options::OPT_finline_hint_functions) && + "Option parsing bug"); + Opts.setInlining(Args.hasArg(OPT_finline_functions) + ? CodeGenOptions::NormalInlining + : CodeGenOptions::OnlyHintInlining); } }