diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-22 18:35:59 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-02-22 18:35:59 +0000 |
commit | 0b849d34b3a9574615e98e108db4e8099e9032e0 (patch) | |
tree | e533db37ea34e3b7394d3ed1e65ab59fe96316a7 /lib/Lex/PreprocessingRecord.cpp | |
parent | f512acee01617c9da8079ed88ded3bb9f2418349 (diff) |
[preprocessing record] Have the MacroDefinitions map point to the MacroDefinition object instead
its index in the preprocessed entities vector.
This is because the order of the entities in the vector can change in some (uncommon) cases.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/PreprocessingRecord.cpp')
-rw-r--r-- | lib/Lex/PreprocessingRecord.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/Lex/PreprocessingRecord.cpp b/lib/Lex/PreprocessingRecord.cpp index ac0985be84..0f3587e31c 100644 --- a/lib/Lex/PreprocessingRecord.cpp +++ b/lib/Lex/PreprocessingRecord.cpp @@ -320,8 +320,8 @@ unsigned PreprocessingRecord::allocateLoadedEntities(unsigned NumEntities) { } void PreprocessingRecord::RegisterMacroDefinition(MacroInfo *Macro, - PPEntityID PPID) { - MacroDefinitions[Macro] = PPID; + MacroDefinition *Def) { + MacroDefinitions[Macro] = Def; } /// \brief Retrieve the preprocessed entity at the given ID. @@ -358,15 +358,12 @@ PreprocessingRecord::getLoadedPreprocessedEntity(unsigned Index) { } MacroDefinition *PreprocessingRecord::findMacroDefinition(const MacroInfo *MI) { - llvm::DenseMap<const MacroInfo *, PPEntityID>::iterator Pos + llvm::DenseMap<const MacroInfo *, MacroDefinition *>::iterator Pos = MacroDefinitions.find(MI); if (Pos == MacroDefinitions.end()) return 0; - - PreprocessedEntity *Entity = getPreprocessedEntity(Pos->second); - if (Entity->isInvalid()) - return 0; - return cast<MacroDefinition>(Entity); + + return Pos->second; } void PreprocessingRecord::addMacroExpansion(const Token &Id, @@ -415,7 +412,8 @@ void PreprocessingRecord::MacroDefined(const Token &Id, SourceRange R(MI->getDefinitionLoc(), MI->getDefinitionEndLoc()); MacroDefinition *Def = new (*this) MacroDefinition(Id.getIdentifierInfo(), R); - MacroDefinitions[MI] = addPreprocessedEntity(Def); + addPreprocessedEntity(Def); + MacroDefinitions[MI] = Def; } void PreprocessingRecord::MacroUndefined(const Token &Id, |