]> granicus.if.org Git - clang/commitdiff
Add PreprocessorOptions to CompilerInvocation.
authorDaniel Dunbar <daniel@zuster.org>
Mon, 9 Nov 2009 23:12:31 +0000 (23:12 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 9 Nov 2009 23:12:31 +0000 (23:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86623 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Frontend/CompilerInvocation.h
tools/clang-cc/clang-cc.cpp

index 3416654481837d0b0a6fe0bd52de743a710badf9..b249ce90779b90f35e139a11a1922f967884b187 100644 (file)
@@ -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;
   }
 };
 
index e4bfee697e2527f19d3776ede9e0980a0fe70d3c..ba654fdc9d7896fafe4bb15fe4571ab2fe1ead29 100644 (file)
@@ -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()) {