diff options
author | Alexander Kornienko <alexfh@google.com> | 2012-09-25 17:18:14 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2012-09-25 17:18:14 +0000 |
commit | 4d7e0ced7f16a04aabe2d8d91cbbb52fb1162810 (patch) | |
tree | c6aa5f04eb7a64fb940e2be0a6eeb6afff3465d5 /lib/Lex | |
parent | 317d8f339c2ee7b59e0e8cc81646ef664e20532d (diff) |
Macro history (de-)serialization. Deserialization currently reads only the latest macro definition. Needs more work.
Summary: Passes all tests (+ the new one with code completion), but needs a thorough review in part related to modules.
Reviewers: doug.gregor
Reviewed By: alexfh
CC: cfe-commits, rsmith
Differential Revision: http://llvm-reviews.chandlerc.com/D41
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164610 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex')
-rw-r--r-- | lib/Lex/PPMacroExpansion.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Lex/PPMacroExpansion.cpp b/lib/Lex/PPMacroExpansion.cpp index b2d597713b..dcaa5a6636 100644 --- a/lib/Lex/PPMacroExpansion.cpp +++ b/lib/Lex/PPMacroExpansion.cpp @@ -32,8 +32,8 @@ #include <ctime> using namespace clang; -MacroInfo *Preprocessor::getInfoForMacro(IdentifierInfo *II) const { - assert(II->hasMacroDefinition() && "Identifier is not a macro!"); +MacroInfo *Preprocessor::getMacroInfoHistory(IdentifierInfo *II) const { + assert(II->hadMacroDefinition() && "Identifier has not been not a macro!"); macro_iterator Pos = Macros.find(II); if (Pos == Macros.end()) { @@ -42,7 +42,6 @@ MacroInfo *Preprocessor::getInfoForMacro(IdentifierInfo *II) const { Pos = Macros.find(II); } assert(Pos != Macros.end() && "Identifier macro info is missing!"); - assert(Pos->second->getUndefLoc().isInvalid() && "Macro is undefined!"); return Pos->second; } @@ -51,9 +50,11 @@ MacroInfo *Preprocessor::getInfoForMacro(IdentifierInfo *II) const { void Preprocessor::setMacroInfo(IdentifierInfo *II, MacroInfo *MI, bool LoadedFromAST) { assert(MI && "MacroInfo should be non-zero!"); + assert((LoadedFromAST || MI->getUndefLoc().isInvalid()) && + "Undefined macros can only be registered when just LoadedFromAST"); MI->setPreviousDefinition(Macros[II]); Macros[II] = MI; - II->setHasMacroDefinition(true); + II->setHasMacroDefinition(MI->getUndefLoc().isInvalid()); if (II->isFromAST() && !LoadedFromAST) II->setChangedSinceDeserialization(); } |