diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-03-19 17:12:43 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-03-19 17:12:43 +0000 |
commit | b9e1b75772db2c7db566c6034ba90a07f22e35eb (patch) | |
tree | 614317b4cd29d2480d014468c34ecbd12b35428b /lib/Lex/Preprocessor.cpp | |
parent | 94dc8f640ebea52241412512ed48601626edbc58 (diff) |
Make the preprocessing record a PPCallbacks subclass itself,
eliminating the extra PopulatePreprocessingRecord object. This will
become useful once we start writing the preprocessing record to
precompiled headers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Preprocessor.cpp')
-rw-r--r-- | lib/Lex/Preprocessor.cpp | 42 |
1 files changed, 3 insertions, 39 deletions
diff --git a/lib/Lex/Preprocessor.cpp b/lib/Lex/Preprocessor.cpp index d9aaed4a48..9d59300d21 100644 --- a/lib/Lex/Preprocessor.cpp +++ b/lib/Lex/Preprocessor.cpp @@ -54,7 +54,7 @@ Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts, : Diags(&diags), Features(opts), Target(target),FileMgr(Headers.getFileMgr()), SourceMgr(SM), HeaderInfo(Headers), ExternalSource(0), Identifiers(opts, IILookup), BuiltinInfo(Target), CodeCompletionFile(0), - CurPPLexer(0), CurDirLookup(0), Callbacks(0), MacroArgCache(0) { + CurPPLexer(0), CurDirLookup(0), Callbacks(0), MacroArgCache(0), Record(0) { ScratchBuf = new ScratchBuffer(SourceMgr); CounterValue = 0; // __COUNTER__ starts at 0. OwnsHeaderSearch = OwnsHeaders; @@ -629,46 +629,10 @@ bool Preprocessor::HandleComment(Token &result, SourceRange Comment) { CommentHandler::~CommentHandler() { } -namespace { - /// \brief Preprocessor callback action used to populate a preprocessing - /// record. - class PopulatePreprocessingRecord : public PPCallbacks { - /// \brief The preprocessing record this action will populate. - PreprocessingRecord &Record; - - /// \brief Mapping from MacroInfo structures to their definitions. - llvm::DenseMap<const MacroInfo *, MacroDefinition *> MacroDefinitions; - - public: - explicit PopulatePreprocessingRecord(PreprocessingRecord &Record) - : Record(Record) { } - - virtual void MacroExpands(const Token &Id, const MacroInfo* MI); - virtual void MacroDefined(const IdentifierInfo *II, const MacroInfo *MI); - }; -} - -void PopulatePreprocessingRecord::MacroExpands(const Token &Id, - const MacroInfo* MI) { - Record.addPreprocessedEntity( - new (Record) MacroInstantiation(Id.getIdentifierInfo(), - Id.getLocation(), - MacroDefinitions[MI])); -} - -void PopulatePreprocessingRecord::MacroDefined(const IdentifierInfo *II, - const MacroInfo *MI) { - SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc()); - MacroDefinition *Def - = new (Record) MacroDefinition(II, MI->getDefinitionLoc(), R); - MacroDefinitions[MI] = Def; - Record.addPreprocessedEntity(Def); -} - void Preprocessor::createPreprocessingRecord() { if (Record) return; - Record.reset(new PreprocessingRecord); - addPPCallbacks(new PopulatePreprocessingRecord(*Record)); + Record = new PreprocessingRecord; + addPPCallbacks(Record); } |