Add CompileOptions to CompilerInvocation.

llvm-svn: 86685
This commit is contained in:
Daniel Dunbar 2009-11-10 16:19:45 +00:00
parent 66df54f92c
commit 754c11ec48
2 changed files with 34 additions and 15 deletions

View 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

View 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) {