]> granicus.if.org Git - clang/commitdiff
Factor out parts of InitializeCompileOptions that depend on the LangOptions.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 10 Nov 2009 18:47:35 +0000 (18:47 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 10 Nov 2009 18:47:35 +0000 (18:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86696 91177308-0d34-0410-b5e6-96231b3b80d8

tools/clang-cc/clang-cc.cpp

index d177bab185acde394f2032f60cbd9827214833d6..c0719bf576de782cadaa8110aa1197c49b0c575a 100644 (file)
@@ -1299,7 +1299,6 @@ static void ComputeFeatureMap(TargetInfo &Target,
 }
 
 static void InitializeCompileOptions(CompileOptions &Opts,
-                                     const LangOptions &LangOpts,
                                      const llvm::StringMap<bool> &Features) {
   using namespace codegenoptions;
   Opts.OptimizeSize = OptSize;
@@ -1314,7 +1313,7 @@ static void InitializeCompileOptions(CompileOptions &Opts,
     : CompileOptions::OnlyAlwaysInlining;
 
   Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize);
-  Opts.SimplifyLibCalls = !LangOpts.NoBuiltin;
+  Opts.SimplifyLibCalls = 1;
 
 #ifdef NDEBUG
   Opts.VerifyModule = 0;
@@ -1331,7 +1330,7 @@ static void InitializeCompileOptions(CompileOptions &Opts,
     Opts.Features.push_back(Name);
   }
 
-  Opts.NoCommon = NoCommon | LangOpts.CPlusPlus;
+  Opts.NoCommon = NoCommon;
 
   // Handle -ftime-report.
   Opts.TimePasses = TimeReport;
@@ -1342,6 +1341,14 @@ static void InitializeCompileOptions(CompileOptions &Opts,
   Opts.MergeAllConstants = !NoMergeConstants;
 }
 
+static void FinalizeCompileOptions(CompileOptions &Opts,
+                                   const LangOptions &Lang) {
+  if (Lang.NoBuiltin)
+    Opts.SimplifyLibCalls = 0;
+  if (Lang.CPlusPlus)
+    Opts.NoCommon = 1;
+}
+
 //===----------------------------------------------------------------------===//
 // Fix-It Options
 //===----------------------------------------------------------------------===//
@@ -2157,6 +2164,10 @@ static void ConstructCompilerInvocation(CompilerInvocation &Opts,
   // Compute the feature set, which may effect the language.
   ComputeFeatureMap(Target, Opts.getTargetFeatures());
 
+  // Initialize backend options, which may also be used to key some language
+  // options.
+  InitializeCompileOptions(Opts.getCompileOpts(), Opts.getTargetFeatures());
+
   // Initialize language options.
   LangOptions LangInfo;
 
@@ -2174,9 +2185,8 @@ static void ConstructCompilerInvocation(CompilerInvocation &Opts,
   // Initialize the other preprocessor options.
   InitializePreprocessorOptions(Opts.getPreprocessorOpts());
 
-  // Initialize backend options.
-  InitializeCompileOptions(Opts.getCompileOpts(), Opts.getLangOpts(),
-                           Opts.getTargetFeatures());
+  // Finalize, some code generation options.
+  FinalizeCompileOptions(Opts.getCompileOpts(), Opts.getLangOpts());
 }
 
 int main(int argc, char **argv) {