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/PreprocessingRecord.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/PreprocessingRecord.cpp')
-rw-r--r-- | lib/Lex/PreprocessingRecord.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp index 83268e0134..6e0e28a1b8 100644 --- a/lib/Lex/PreprocessingRecord.cpp +++ b/lib/Lex/PreprocessingRecord.cpp @@ -21,3 +21,27 @@ void PreprocessingRecord::addPreprocessedEntity(PreprocessedEntity *Entity) { PreprocessedEntities.push_back(Entity); } +MacroDefinition *PreprocessingRecord::findMacroDefinition(MacroInfo *MI) { + llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos + = MacroDefinitions.find(MI); + if (Pos == MacroDefinitions.end()) + return 0; + + return Pos->second; +} + +void PreprocessingRecord::MacroExpands(const Token &Id, const MacroInfo* MI) { + PreprocessedEntities.push_back( + new (*this) MacroInstantiation(Id.getIdentifierInfo(), + Id.getLocation(), + MacroDefinitions[MI])); +} + +void PreprocessingRecord::MacroDefined(const IdentifierInfo *II, + const MacroInfo *MI) { + SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc()); + MacroDefinition *Def + = new (*this) MacroDefinition(II, MI->getDefinitionLoc(), R); + MacroDefinitions[MI] = Def; + PreprocessedEntities.push_back(Def); +} |