[cfe-commits] r166599 - in /cfe/trunk: include/clang/Lex/Preprocessor.h lib/Frontend/ASTUnit.cpp lib/Frontend/CompilerInstance.cpp lib/Lex/Preprocessor.cpp unittests/Basic/SourceManagerTest.cpp unittests/Lex/LexerTest.cpp unittests/Lex/PreprocessingRecordTest.cpp

Douglas Gregor dgregor at apple.com
Wed Oct 24 10:46:57 PDT 2012


Author: dgregor
Date: Wed Oct 24 12:46:57 2012
New Revision: 166599

URL: http://llvm.org/viewvc/llvm-project?rev=166599&view=rev
Log:
Teach the preprocessor to hold onto the preprocessor options.

Modified:
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Lex/Preprocessor.cpp
    cfe/trunk/unittests/Basic/SourceManagerTest.cpp
    cfe/trunk/unittests/Lex/LexerTest.cpp
    cfe/trunk/unittests/Lex/PreprocessingRecordTest.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=166599&r1=166598&r2=166599&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Wed Oct 24 12:46:57 2012
@@ -55,6 +55,7 @@
 class DirectoryLookup;
 class PreprocessingRecord;
 class ModuleLoader;
+class PreprocessorOptions;
 
 /// \brief Stores token information for comparing actual tokens with
 /// predefined values.  Only handles simple tokens and identifiers.
@@ -83,6 +84,7 @@
 /// like the \#include stack, token expansion, etc.
 ///
 class Preprocessor : public RefCountedBase<Preprocessor> {
+  llvm::IntrusiveRefCntPtr<PreprocessorOptions> PPOpts;
   DiagnosticsEngine        *Diags;
   LangOptions       &LangOpts;
   const TargetInfo  *Target;
@@ -394,7 +396,8 @@
   MacroInfoChain *MICache;
 
 public:
-  Preprocessor(DiagnosticsEngine &diags, LangOptions &opts,
+  Preprocessor(llvm::IntrusiveRefCntPtr<PreprocessorOptions> PPOpts,
+               DiagnosticsEngine &diags, LangOptions &opts,
                const TargetInfo *target,
                SourceManager &SM, HeaderSearch &Headers,
                ModuleLoader &TheModuleLoader,

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=166599&r1=166598&r2=166599&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Wed Oct 24 12:46:57 2012
@@ -27,6 +27,7 @@
 #include "clang/Serialization/ASTWriter.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/Basic/Diagnostic.h"
@@ -772,7 +773,8 @@
 
   OwningPtr<ASTReader> Reader;
 
-  AST->PP = new Preprocessor(AST->getDiagnostics(), AST->ASTFileLangOpts, 
+  AST->PP = new Preprocessor(new PreprocessorOptions(),
+                             AST->getDiagnostics(), AST->ASTFileLangOpts,
                              /*Target=*/0, AST->getSourceManager(), HeaderInfo, 
                              *AST, 
                              /*IILookup=*/0,

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=166599&r1=166598&r2=166599&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Oct 24 12:46:57 2012
@@ -247,7 +247,8 @@
                                               getDiagnostics(),
                                               getLangOpts(),
                                               &getTarget());
-  PP = new Preprocessor(getDiagnostics(), getLangOpts(), &getTarget(),
+  PP = new Preprocessor(&getPreprocessorOpts(),
+                        getDiagnostics(), getLangOpts(), &getTarget(),
                         getSourceManager(), *HeaderInfo, *this, PTHMgr,
                         /*OwnsHeaderSearch=*/true);
 

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=166599&r1=166598&r2=166599&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Wed Oct 24 12:46:57 2012
@@ -26,6 +26,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "MacroArgs.h"
 #include "clang/Lex/ExternalPreprocessorSource.h"
 #include "clang/Lex/HeaderSearch.h"
@@ -51,14 +52,16 @@
 
 PPMutationListener::~PPMutationListener() { }
 
-Preprocessor::Preprocessor(DiagnosticsEngine &diags, LangOptions &opts,
+Preprocessor::Preprocessor(llvm::IntrusiveRefCntPtr<PreprocessorOptions> PPOpts,
+                           DiagnosticsEngine &diags, LangOptions &opts,
                            const TargetInfo *target, SourceManager &SM,
                            HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
                            IdentifierInfoLookup* IILookup,
                            bool OwnsHeaders,
                            bool DelayInitialization,
                            bool IncrProcessing)
-  : Diags(&diags), LangOpts(opts), Target(target),FileMgr(Headers.getFileMgr()),
+  : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), Target(target),
+    FileMgr(Headers.getFileMgr()),
     SourceMgr(SM), HeaderInfo(Headers), TheModuleLoader(TheModuleLoader),
     ExternalSource(0), Identifiers(opts, IILookup), 
     IncrementalProcessing(IncrProcessing), CodeComplete(0), 

Modified: cfe/trunk/unittests/Basic/SourceManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/SourceManagerTest.cpp?rev=166599&r1=166598&r2=166599&view=diff
==============================================================================
--- cfe/trunk/unittests/Basic/SourceManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/SourceManagerTest.cpp Wed Oct 24 12:46:57 2012
@@ -18,6 +18,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Config/config.h"
 
@@ -69,8 +70,7 @@
   VoidModuleLoader ModLoader;
   HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags, LangOpts, 
                           &*Target);
-  Preprocessor PP(Diags, LangOpts,
-                  Target.getPtr(),
+  Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
                   SourceMgr, HeaderInfo, ModLoader,
                   /*IILookup =*/ 0,
                   /*OwnsHeaderSearch =*/false,
@@ -185,8 +185,7 @@
   VoidModuleLoader ModLoader;
   HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags, LangOpts, 
                           &*Target);
-  Preprocessor PP(Diags, LangOpts,
-                  Target.getPtr(),
+  Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
                   SourceMgr, HeaderInfo, ModLoader,
                   /*IILookup =*/ 0,
                   /*OwnsHeaderSearch =*/false,
@@ -283,8 +282,7 @@
   VoidModuleLoader ModLoader;
   HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags, LangOpts, 
                           &*Target);
-  Preprocessor PP(Diags, LangOpts,
-                  Target.getPtr(),
+  Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
                   SourceMgr, HeaderInfo, ModLoader,
                   /*IILookup =*/ 0,
                   /*OwnsHeaderSearch =*/false,

Modified: cfe/trunk/unittests/Lex/LexerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/LexerTest.cpp?rev=166599&r1=166598&r2=166599&view=diff
==============================================================================
--- cfe/trunk/unittests/Lex/LexerTest.cpp (original)
+++ cfe/trunk/unittests/Lex/LexerTest.cpp Wed Oct 24 12:46:57 2012
@@ -18,6 +18,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "llvm/Config/config.h"
 
 #include "gtest/gtest.h"
@@ -75,8 +76,7 @@
   VoidModuleLoader ModLoader;
   HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags, LangOpts, 
                           Target.getPtr());
-  Preprocessor PP(Diags, LangOpts,
-                  Target.getPtr(),
+  Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts, Target.getPtr(),
                   SourceMgr, HeaderInfo, ModLoader,
                   /*IILookup =*/ 0,
                   /*OwnsHeaderSearch =*/false,

Modified: cfe/trunk/unittests/Lex/PreprocessingRecordTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Lex/PreprocessingRecordTest.cpp?rev=166599&r1=166598&r2=166599&view=diff
==============================================================================
--- cfe/trunk/unittests/Lex/PreprocessingRecordTest.cpp (original)
+++ cfe/trunk/unittests/Lex/PreprocessingRecordTest.cpp Wed Oct 24 12:46:57 2012
@@ -18,6 +18,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/PreprocessingRecord.h"
 #include "llvm/Config/config.h"
 
@@ -86,8 +87,7 @@
   VoidModuleLoader ModLoader;
   HeaderSearch HeaderInfo(new HeaderSearchOptions, FileMgr, Diags, LangOpts, 
                           Target.getPtr());
-  Preprocessor PP(Diags, LangOpts,
-                  Target.getPtr(),
+  Preprocessor PP(new PreprocessorOptions(), Diags, LangOpts,Target.getPtr(),
                   SourceMgr, HeaderInfo, ModLoader,
                   /*IILookup =*/ 0,
                   /*OwnsHeaderSearch =*/false,





More information about the cfe-commits mailing list