diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-01-18 04:34:14 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-01-18 04:34:14 +0000 |
commit | d3b036efdf0bf4ec216c701183a4b990cd041cd6 (patch) | |
tree | d5d0e6464583c3bef62ffd720714526ab388a980 /lib/Serialization/ASTWriter.cpp | |
parent | 6a21a556a728325e1fae4387128d149927a4fbff (diff) |
Revert Clang r172620 and r172629, which caused a hang when building
complicated modules (<rdar://problem/13038265>). Unfortunately, this
un-fixes <rdar://problem/13016031>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172783 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | lib/Serialization/ASTWriter.cpp | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 8c14b5f395..36e1bb3a69 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -1796,10 +1796,12 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { // Construct the list of macro definitions that need to be serialized. SmallVector<std::pair<const IdentifierInfo *, MacroInfo *>, 2> MacrosToEmit; + llvm::SmallPtrSet<const IdentifierInfo*, 4> MacroDefinitionsSeen; for (Preprocessor::macro_iterator I = PP.macro_begin(Chain == 0), E = PP.macro_end(Chain == 0); I != E; ++I) { if (!IsModule || I->second->isPublic()) { + MacroDefinitionsSeen.insert(I->first); MacrosToEmit.push_back(std::make_pair(I->first, I->second)); } } @@ -1852,12 +1854,6 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { Record.push_back(inferSubmoduleIDFromLocation(MI->getDefinitionLoc())); AddSourceLocation(MI->getDefinitionLoc(), Record); AddSourceLocation(MI->getDefinitionEndLoc(), Record); - MacroInfo *PrevMI = MI->getPreviousDefinition(); - // Serialize only the part of the definition chain that is local. - // The chain will be synthesized across modules by the ASTReader. - if (Chain && PrevMI && PrevMI->isFromAST()) - PrevMI = 0; - addMacroRef(PrevMI, Record); AddSourceLocation(MI->getUndefLoc(), Record); Record.push_back(MI->isUsed()); Record.push_back(MI->isPublic()); @@ -2739,8 +2735,14 @@ public: if (isInterestingIdentifier(II, Macro)) { DataLen += 2; // 2 bytes for builtin ID DataLen += 2; // 2 bytes for flags - if (hadMacroDefinition(II, Macro)) + if (hadMacroDefinition(II, Macro)) { + for (MacroInfo *M = Macro; M; M = M->getPreviousDefinition()) { + if (Writer.getMacroRef(M) != 0) + DataLen += 4; + } + DataLen += 4; + } for (IdentifierResolver::iterator D = IdResolver.begin(II), DEnd = IdResolver.end(); @@ -2785,8 +2787,13 @@ public: clang::io::Emit16(Out, Bits); if (HadMacroDefinition) { - // Write the macro ID associated with this identifier. - clang::io::Emit32(Out, Writer.getMacroRef(Macro)); + // Write all of the macro IDs associated with this identifier. + for (MacroInfo *M = Macro; M; M = M->getPreviousDefinition()) { + if (MacroID ID = Writer.getMacroRef(M)) + clang::io::Emit32(Out, ID); + } + + clang::io::Emit32(Out, 0); } // Emit the declaration IDs in reverse order, because the |