From: Daniel Dunbar Date: Tue, 10 Nov 2009 18:47:35 +0000 (+0000) Subject: Factor out parts of InitializeCompileOptions that depend on the LangOptions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fcb0c3b39b2bf3390ea21749b4a1a8946aa927ed;p=clang Factor out parts of InitializeCompileOptions that depend on the LangOptions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86696 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index d177bab185..c0719bf576 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -1299,7 +1299,6 @@ static void ComputeFeatureMap(TargetInfo &Target, } static void InitializeCompileOptions(CompileOptions &Opts, - const LangOptions &LangOpts, const llvm::StringMap &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) {