diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-10-09 16:01:50 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-10-09 16:01:50 +0000 |
commit | 3644d970095d9c638c658cfd17f8e19fc333aadc (patch) | |
tree | d599c71bb12d426f7b62685c62d185950219ab81 /lib/Serialization | |
parent | f5b132f7b373203eab7cf357b01f935bd88087bd (diff) |
If a macro has been #undef'd in a precompiled header, we still need to
write out the macro history for that macro. Similarly, we need to cope
with reading a macro definition that has been #undef'd.
Take advantage of this new ability so that global code-completion
results can refer to #undef'd macros, rather than losing them
entirely. For multiply defined/#undef'd macros, we will still get the
wrong result, but it's better than getting no result.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165502 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization')
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 2 | ||||
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 5 |
2 files changed, 4 insertions, 3 deletions
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index ff418caf9e..05a453143c 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -1460,6 +1460,8 @@ void ASTReader::setIdentifierIsMacro(IdentifierInfo *II, ModuleFile &F, if (Visible) { // Note that this identifier has a macro definition. II->setHasMacroDefinition(true); + } else { + II->setHadMacroDefinition(true); } // Adjust the offset to a global offset. diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index b8a0c28938..19a236fde2 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1698,14 +1698,13 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { IdentifierInfo *Name = const_cast<IdentifierInfo *>(DeserializedMacroNames[I]); if (Name->hadMacroDefinition() && MacroDefinitionsSeen.insert(Name)) - MacrosToEmit.push_back(std::make_pair(Name, PP.getMacroInfo(Name))); + MacrosToEmit.push_back(std::make_pair(Name, + PP.getMacroInfoHistory(Name))); } for (unsigned I = 0, N = MacrosToEmit.size(); I != N; ++I) { const IdentifierInfo *Name = MacrosToEmit[I].first; MacroInfo *MI = MacrosToEmit[I].second; - if (!MI) - continue; // History of macro definitions for this identifier in chronological order. SmallVector<MacroInfo*, 8> MacroHistory; |