From: Daniel Dunbar Date: Mon, 9 Nov 2009 23:12:31 +0000 (+0000) Subject: Add PreprocessorOptions to CompilerInvocation. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5fc7d344ae772731d3d7c9076b8786e780a68696;p=clang Add PreprocessorOptions to CompilerInvocation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86623 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h index 3416654481..b249ce9077 100644 --- a/include/clang/Frontend/CompilerInvocation.h +++ b/include/clang/Frontend/CompilerInvocation.h @@ -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 @@ -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 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 TargetFeatures; public: CompilerInvocation() {} @@ -50,17 +54,22 @@ public: DiagnosticOptions &getDiagnosticOpts() { return DiagOpts; } const DiagnosticOptions &getDiagnosticOpts() const { return DiagOpts; } - llvm::StringMap &getTargetFeatures() { return TargetFeatures; } - const llvm::StringMap &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 &getTargetFeatures() { return TargetFeatures; } + const llvm::StringMap &getTargetFeatures() const { + return TargetFeatures; } }; diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp index e4bfee697e..ba654fdc9d 100644 --- a/tools/clang-cc/clang-cc.cpp +++ b/tools/clang-cc/clang-cc.cpp @@ -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 PP(CreatePreprocessor(Diags, - CompOpts.getLangOpts(), - *Target, SourceMgr, - HeaderInfo)); + llvm::OwningPtr + PP(CreatePreprocessor(Diags, CompOpts.getLangOpts(), + CompOpts.getPreprocessorOpts(), *Target, SourceMgr, + HeaderInfo)); // Handle generating dependencies, if requested. if (!DependencyFile.empty()) {