diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-01-19 03:14:56 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2013-01-19 03:14:56 +0000 |
commit | 719736c5816bd6b0167b66bc2033fa45f632e555 (patch) | |
tree | 6af43df8d57a706a1d04956a0ad49eeeac4bf422 /clang/lib/Serialization/ASTWriter.cpp | |
parent | 7d9ce5312441d81a4c154f2823a153974b3e213f (diff) | |
download | bcm5719-llvm-719736c5816bd6b0167b66bc2033fa45f632e555.tar.gz bcm5719-llvm-719736c5816bd6b0167b66bc2033fa45f632e555.zip |
[PCH/Modules] Revert r172843, it caused a module to fail building.
llvm-svn: 172884
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index df6d1124c82..37577ce0718 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -1798,10 +1798,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)); } } @@ -1821,9 +1823,9 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { for (unsigned I = 0, N = MacrosToEmit.size(); I != N; ++I) { const IdentifierInfo *Name = MacrosToEmit[I].first; - MacroInfo *HeadMI = MacrosToEmit[I].second; - for (MacroInfo *MI = HeadMI; MI; MI = MI->getPreviousDefinition()) { + for (MacroInfo *MI = MacrosToEmit[I].second; MI; + MI = MI->getPreviousDefinition()) { MacroID ID = getMacroRef(MI); if (!ID) continue; @@ -1854,13 +1856,6 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) { Record.push_back(inferSubmoduleIDFromLocation(MI->getDefinitionLoc())); AddSourceLocation(MI->getDefinitionLoc(), Record); AddSourceLocation(MI->getDefinitionEndLoc(), Record); - Record.push_back(MI == HeadMI); - 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()); @@ -2742,8 +2737,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(); @@ -2788,8 +2789,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 |