]> granicus.if.org Git - clang/commitdiff
Driver: Factor out IsUsingLTO helper function.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 21 Jun 2011 20:55:08 +0000 (20:55 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 21 Jun 2011 20:55:08 +0000 (20:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133542 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Driver.h
lib/Driver/Driver.cpp

index 5a7d830b069dd9eabf4163522c7d547ddd7ed14e..b6951663148b1eee7d77d89baac0602130a9e2bd 100644 (file)
@@ -357,6 +357,8 @@ public:
   bool ShouldUseClangCompiler(const Compilation &C, const JobAction &JA,
                               const llvm::Triple &ArchName) const;
 
+  bool IsUsingLTO(const ArgList &Args) const;
+
   /// @}
 
   /// GetReleaseVersion - Parse (([0-9]+)(.([0-9]+)(.([0-9]+)?))?)? and
index eb878a3f1c5e357cddba1218058816d44eeafef1..3a78b6a988fc2089d227a48468d2556ba195af30 100644 (file)
@@ -942,10 +942,6 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
   case phases::Precompile:
     return new PrecompileJobAction(Input, types::TY_PCH);
   case phases::Compile: {
-    bool HasO4 = false;
-    if (const Arg *A = Args.getLastArg(options::OPT_O_Group))
-      HasO4 = A->getOption().matches(options::OPT_O4);
-
     if (Args.hasArg(options::OPT_fsyntax_only)) {
       return new CompileJobAction(Input, types::TY_Nothing);
     } else if (Args.hasArg(options::OPT_rewrite_objc)) {
@@ -954,9 +950,7 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
       return new AnalyzeJobAction(Input, types::TY_Plist);
     } else if (Args.hasArg(options::OPT_emit_ast)) {
       return new CompileJobAction(Input, types::TY_AST);
-    } else if (Args.hasArg(options::OPT_emit_llvm) ||
-               Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false) ||
-               HasO4) {
+    } else if (IsUsingLTO(Args)) {
       types::ID Output =
         Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
       return new CompileJobAction(Input, Output);
@@ -972,6 +966,19 @@ Action *Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
   return 0;
 }
 
+bool Driver::IsUsingLTO(const ArgList &Args) const {
+  // Check for -emit-llvm or -flto.
+  if (Args.hasArg(options::OPT_emit_llvm) ||
+      Args.hasFlag(options::OPT_flto, options::OPT_fno_lto, false))
+    return true;
+
+  // Check for -O4.
+  if (const Arg *A = Args.getLastArg(options::OPT_O_Group))
+      return A->getOption().matches(options::OPT_O4);
+
+  return false;
+}
+
 void Driver::BuildJobs(Compilation &C) const {
   llvm::PrettyStackTraceString CrashInfo("Building compilation jobs");