]> granicus.if.org Git - clang/commitdiff
Add CompileOptions to CompilerInvocation.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 10 Nov 2009 16:19:45 +0000 (16:19 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 10 Nov 2009 16:19:45 +0000 (16:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86685 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/CompilerInvocation.h
tools/clang-cc/clang-cc.cpp

index b249ce90779b90f35e139a11a1922f967884b187..c2a66bdf1d6ea5d21fb386299d94e983c16638c3 100644 (file)
@@ -11,6 +11,7 @@
 #define LLVM_CLANG_FRONTEND_COMPILERINVOCATION_H_
 
 #include "clang/Basic/LangOptions.h"
+#include "clang/Frontend/CompileOptions.h"
 #include "clang/Frontend/DiagnosticOptions.h"
 #include "clang/Frontend/HeaderSearchOptions.h"
 #include "clang/Frontend/PreprocessorOptions.h"
@@ -26,9 +27,8 @@ namespace clang {
 /// compiler, including data such as the include paths, the code generation
 /// options, the warning flags, and so on.
 class CompilerInvocation {
-  /// The location for the output file. This is optional only for compiler
-  /// invocations which have no output.
-  std::string OutputFile;
+  /// Options controlling IRgen and the backend.
+  CompileOptions CompileOpts;
 
   /// Options controlling the diagnostic engine.
   DiagnosticOptions DiagOpts;
@@ -42,15 +42,36 @@ class CompilerInvocation {
   /// Options controlling the preprocessor (aside from #include handling).
   PreprocessorOptions PreprocessorOpts;
 
+  /// The location for the output file. This is optional only for compiler
+  /// invocations which have no output.
+  std::string OutputFile;
+
   /// Set of target-specific code generation features to enable/disable.
   llvm::StringMap<bool> TargetFeatures;
 
 public:
   CompilerInvocation() {}
 
+  /// @name Invidual Options
+  /// @{
+
   std::string &getOutputFile() { return OutputFile; }
   const std::string &getOutputFile() const { return OutputFile; }
 
+  llvm::StringMap<bool> &getTargetFeatures() { return TargetFeatures; }
+  const llvm::StringMap<bool> &getTargetFeatures() const {
+    return TargetFeatures;
+  }
+
+  /// @}
+  /// @name Option Subgroups
+  /// @{
+
+  CompileOptions &getCompileOpts() { return CompileOpts; }
+  const CompileOptions &getCompileOpts() const {
+    return CompileOpts;
+  }
+
   DiagnosticOptions &getDiagnosticOpts() { return DiagOpts; }
   const DiagnosticOptions &getDiagnosticOpts() const { return DiagOpts; }
 
@@ -67,10 +88,7 @@ public:
     return PreprocessorOpts;
   }
 
-  llvm::StringMap<bool> &getTargetFeatures() { return TargetFeatures; }
-  const llvm::StringMap<bool> &getTargetFeatures() const {
-    return TargetFeatures;
-  }
+  /// @}
 };
 
 } // end namespace clang
index b80d5f87a38e5874f53fca7b51f746b61a1b1537..ae1b32f71f5702b02a6ce36e73bf8f87227d097f 100644 (file)
@@ -1330,7 +1330,6 @@ static void InitializeCompileOptions(CompileOptions &Opts,
       Opts.Inlining = CompileOptions::OnlyAlwaysInlining;
   }
 
-  // FIXME: There are llvm-gcc options to control these selectively.
   Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize);
   Opts.SimplifyLibCalls = !LangOpts.NoBuiltin;
 
@@ -1356,7 +1355,7 @@ static void InitializeCompileOptions(CompileOptions &Opts,
 
   Opts.DisableRedZone = DisableRedZone;
   Opts.NoImplicitFloat = NoImplicitFloat;
-  
+
   Opts.MergeAllConstants = !NoMergeConstants;
 }
 
@@ -1692,11 +1691,9 @@ static ASTConsumer *CreateConsumerAction(const CompilerInvocation &CompOpts,
       OS.reset(ComputeOutFile(CompOpts, InFile, "bc", true, OutPath));
     }
 
-    CompileOptions Opts;
-    InitializeCompileOptions(Opts, PP.getLangOptions(),
-                             CompOpts.getTargetFeatures());
     return CreateBackendConsumer(Act, PP.getDiagnostics(), PP.getLangOptions(),
-                                 Opts, InFile, OS.get(), Context);
+                                 CompOpts.getCompileOpts(), InFile, OS.get(),
+                                 Context);
   }
 
   case RewriteObjC:
@@ -2177,10 +2174,10 @@ static void ConstructCompilerInvocation(CompilerInvocation &Opts,
 
   // Compute the feature set, which may effect the language.
   ComputeFeatureMap(Target, Opts.getTargetFeatures());
-  
+
   // Initialize language options.
   LangOptions LangInfo;
-  
+
   // FIXME: These aren't used during operations on ASTs. Split onto a separate
   // code path to make this obvious.
   if (LK != langkind_ast) {
@@ -2194,6 +2191,10 @@ static void ConstructCompilerInvocation(CompilerInvocation &Opts,
 
   // Initialize the other preprocessor options.
   InitializePreprocessorOptions(Opts.getPreprocessorOpts());
+
+  // Initialize backend options.
+  InitializeCompileOptions(Opts.getCompileOpts(), Opts.getLangOpts(),
+                           Opts.getTargetFeatures());
 }
 
 int main(int argc, char **argv) {