summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-01-07 16:56:53 +0000
committerDouglas Gregor <dgregor@apple.com>2013-01-07 16:56:53 +0000
commite68cf2722501e2a49ac039e36db93edf27b6cb40 (patch)
treec73292c8742ff86f0b5adff4e70bf50e629d8ef9
parent042e0883cbcd35641d60fd2d22105ac5c6a402f8 (diff)
downloadbcm5719-llvm-e68cf2722501e2a49ac039e36db93edf27b6cb40.tar.gz
bcm5719-llvm-e68cf2722501e2a49ac039e36db93edf27b6cb40.zip
updateOutOfDateIdentifier() can cause the identifier table to be
rehashed, invaliding the iterator walking through the identifier table. Separate out the identification of out-of-date identifiers from updating them. llvm-svn: 171756
-rw-r--r--clang/lib/Serialization/ASTWriter.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 58f7fe7051c..887876f2842 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3459,11 +3459,19 @@ void ASTWriter::WriteASTCore(Sema &SemaRef,
// If there are any out-of-date identifiers, bring them up to date.
if (ExternalPreprocessorSource *ExtSource = PP.getExternalSource()) {
+ // Find out-of-date identifiers.
+ SmallVector<IdentifierInfo *, 4> OutOfDate;
for (IdentifierTable::iterator ID = PP.getIdentifierTable().begin(),
IDEnd = PP.getIdentifierTable().end();
- ID != IDEnd; ++ID)
+ ID != IDEnd; ++ID) {
if (ID->second->isOutOfDate())
- ExtSource->updateOutOfDateIdentifier(*ID->second);
+ OutOfDate.push_back(ID->second);
+ }
+
+ // Update the out-of-date identifiers.
+ for (unsigned I = 0, N = OutOfDate.size(); I != N; ++I) {
+ ExtSource->updateOutOfDateIdentifier(*OutOfDate[I]);
+ }
}
// Build a record containing all of the tentative definitions in this file, in
OpenPOWER on IntegriCloud