]> granicus.if.org Git - clang/commitdiff
Fix a PCH crash bug where we kept a reference inside a DenseMap while the map was...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 11 Aug 2011 23:26:42 +0000 (23:26 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Thu, 11 Aug 2011 23:26:42 +0000 (23:26 +0000)
No test case, sorry. It's one of those bugs where it's really really hard to make one. rdar://9910862.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137383 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Serialization/ASTReader.cpp

index 490e5f9da2a7970dee17d2b957329caed8e27a3e..1bda1ed42a8f8b815caf22250f24ca623dea3e91 100644 (file)
@@ -4307,7 +4307,10 @@ ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC,
   // There might be visible decls in multiple parts of the chain, for the TU
   // and namespaces. For any given name, the last available results replace
   // all earlier ones. For this reason, we walk in reverse.
-  DeclContextInfos &Infos = DeclContextOffsets[DC];
+  // Copy the DeclContextInfos vector instead of using a reference to the
+  // vector stored in the map, because DeclContextOffsets can change while
+  // we load declarations with GetLocalDeclAs.
+  DeclContextInfos Infos = DeclContextOffsets[DC];
   for (DeclContextInfos::reverse_iterator I = Infos.rbegin(), E = Infos.rend();
        I != E; ++I) {
     if (!I->NameLookupTableData)