forked from OSchip/llvm-project
Add PreprocessorOptions to CompilerInvocation.
llvm-svn: 86623
This commit is contained in:
parent
2524b04d0e
commit
60198df262
|
@ -13,6 +13,7 @@
|
|||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Frontend/DiagnosticOptions.h"
|
||||
#include "clang/Frontend/HeaderSearchOptions.h"
|
||||
#include "clang/Frontend/PreprocessorOptions.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include <string>
|
||||
|
||||
|
@ -32,14 +33,17 @@ class CompilerInvocation {
|
|||
/// Options controlling the diagnostic engine.
|
||||
DiagnosticOptions DiagOpts;
|
||||
|
||||
/// Set of target-specific code generation features to enable/disable.
|
||||
llvm::StringMap<bool> TargetFeatures;
|
||||
/// Options controlling the #include directive.
|
||||
HeaderSearchOptions HeaderSearchOpts;
|
||||
|
||||
/// Options controlling the language variant.
|
||||
LangOptions LangOpts;
|
||||
|
||||
/// Options controlling the #include directive.
|
||||
HeaderSearchOptions HeaderSearchOpts;
|
||||
/// Options controlling the preprocessor (aside from #include handling).
|
||||
PreprocessorOptions PreprocessorOpts;
|
||||
|
||||
/// Set of target-specific code generation features to enable/disable.
|
||||
llvm::StringMap<bool> TargetFeatures;
|
||||
|
||||
public:
|
||||
CompilerInvocation() {}
|
||||
|
@ -50,17 +54,22 @@ public:
|
|||
DiagnosticOptions &getDiagnosticOpts() { return DiagOpts; }
|
||||
const DiagnosticOptions &getDiagnosticOpts() const { return DiagOpts; }
|
||||
|
||||
llvm::StringMap<bool> &getTargetFeatures() { return TargetFeatures; }
|
||||
const llvm::StringMap<bool> &getTargetFeatures() const {
|
||||
return TargetFeatures;
|
||||
HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; }
|
||||
const HeaderSearchOptions &getHeaderSearchOpts() const {
|
||||
return HeaderSearchOpts;
|
||||
}
|
||||
|
||||
LangOptions &getLangOpts() { return LangOpts; }
|
||||
const LangOptions &getLangOpts() const { return LangOpts; }
|
||||
|
||||
HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; }
|
||||
const HeaderSearchOptions &getHeaderSearchOpts() const {
|
||||
return HeaderSearchOpts;
|
||||
PreprocessorOptions &getPreprocessorOpts() { return PreprocessorOpts; }
|
||||
const PreprocessorOptions &getPreprocessorOpts() const {
|
||||
return PreprocessorOpts;
|
||||
}
|
||||
|
||||
llvm::StringMap<bool> &getTargetFeatures() { return TargetFeatures; }
|
||||
const llvm::StringMap<bool> &getTargetFeatures() const {
|
||||
return TargetFeatures;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -1142,7 +1142,7 @@ static void InitializeIncludePaths(HeaderSearchOptions &Opts,
|
|||
Opts.UseStandardIncludes = !nostdinc;
|
||||
}
|
||||
|
||||
void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
|
||||
static void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
|
||||
// Use predefines?
|
||||
InitOpts.setUsePredefines(!UndefMacros);
|
||||
|
||||
|
@ -1208,9 +1208,9 @@ void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static Preprocessor *
|
||||
CreatePreprocessor(Diagnostic &Diags,const LangOptions &LangInfo,
|
||||
TargetInfo &Target, SourceManager &SourceMgr,
|
||||
HeaderSearch &HeaderInfo) {
|
||||
CreatePreprocessor(Diagnostic &Diags, const LangOptions &LangInfo,
|
||||
const PreprocessorOptions &PPOpts, TargetInfo &Target,
|
||||
SourceManager &SourceMgr, HeaderSearch &HeaderInfo) {
|
||||
PTHManager *PTHMgr = 0;
|
||||
if (!TokenCache.empty() && !ImplicitIncludePTH.empty()) {
|
||||
fprintf(stderr, "error: cannot use both -token-cache and -include-pth "
|
||||
|
@ -1241,9 +1241,7 @@ CreatePreprocessor(Diagnostic &Diags,const LangOptions &LangInfo,
|
|||
PP->setPTHManager(PTHMgr);
|
||||
}
|
||||
|
||||
PreprocessorOptions InitOpts;
|
||||
InitializePreprocessorOptions(InitOpts);
|
||||
InitializePreprocessor(*PP, InitOpts);
|
||||
InitializePreprocessor(*PP, PPOpts);
|
||||
|
||||
return PP;
|
||||
}
|
||||
|
@ -2212,6 +2210,9 @@ static void ConstructCompilerInvocation(CompilerInvocation &Opts,
|
|||
|
||||
// Initialize the header search options.
|
||||
InitializeIncludePaths(Opts.getHeaderSearchOpts(), Argv0, Opts.getLangOpts());
|
||||
|
||||
// Initialize the other preprocessor options.
|
||||
InitializePreprocessorOptions(Opts.getPreprocessorOpts());
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
@ -2338,10 +2339,10 @@ int main(int argc, char **argv) {
|
|||
CompOpts.getLangOpts(), Triple);
|
||||
|
||||
// Set up the preprocessor with these options.
|
||||
llvm::OwningPtr<Preprocessor> PP(CreatePreprocessor(Diags,
|
||||
CompOpts.getLangOpts(),
|
||||
*Target, SourceMgr,
|
||||
HeaderInfo));
|
||||
llvm::OwningPtr<Preprocessor>
|
||||
PP(CreatePreprocessor(Diags, CompOpts.getLangOpts(),
|
||||
CompOpts.getPreprocessorOpts(), *Target, SourceMgr,
|
||||
HeaderInfo));
|
||||
|
||||
// Handle generating dependencies, if requested.
|
||||
if (!DependencyFile.empty()) {
|
||||
|
|
Loading…
Reference in New Issue