[cfe-commits] r86623 - in /cfe/trunk: include/clang/Frontend/CompilerInvocation.h tools/clang-cc/clang-cc.cpp

Daniel Dunbar daniel at zuster.org
Mon Nov 9 15:12:31 PST 2009


Author: ddunbar
Date: Mon Nov  9 17:12:31 2009
New Revision: 86623

URL: http://llvm.org/viewvc/llvm-project?rev=86623&view=rev
Log:
Add PreprocessorOptions to CompilerInvocation.

Modified:
    cfe/trunk/include/clang/Frontend/CompilerInvocation.h
    cfe/trunk/tools/clang-cc/clang-cc.cpp

Modified: cfe/trunk/include/clang/Frontend/CompilerInvocation.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInvocation.h?rev=86623&r1=86622&r2=86623&view=diff

==============================================================================
--- cfe/trunk/include/clang/Frontend/CompilerInvocation.h (original)
+++ cfe/trunk/include/clang/Frontend/CompilerInvocation.h Mon Nov  9 17:12:31 2009
@@ -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 @@
   /// 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 @@
   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;
   }
 };
 

Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=86623&r1=86622&r2=86623&view=diff

==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Mon Nov  9 17:12:31 2009
@@ -1142,7 +1142,7 @@
   Opts.UseStandardIncludes = !nostdinc;
 }
 
-void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
+static void InitializePreprocessorOptions(PreprocessorOptions &InitOpts) {
   // Use predefines?
   InitOpts.setUsePredefines(!UndefMacros);
 
@@ -1208,9 +1208,9 @@
 //===----------------------------------------------------------------------===//
 
 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 @@
     PP->setPTHManager(PTHMgr);
   }
 
-  PreprocessorOptions InitOpts;
-  InitializePreprocessorOptions(InitOpts);
-  InitializePreprocessor(*PP, InitOpts);
+  InitializePreprocessor(*PP, PPOpts);
 
   return PP;
 }
@@ -2212,6 +2210,9 @@
 
   // 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 @@
                              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()) {





More information about the cfe-commits mailing list