diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-11-18 01:19:02 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2015-11-18 01:19:02 +0000 |
commit | 2a40fb78c0ae8ba9a46cd63fad2ed50c6f5ec31e (patch) | |
tree | a3b4cc0617ae136a4507eb88ee1df0b09c36b3da /clang/lib/Sema/SemaLookup.cpp | |
parent | 4d6232221352e34f0fc238217f5b2f81a1a06d36 (diff) | |
download | bcm5719-llvm-2a40fb78c0ae8ba9a46cd63fad2ed50c6f5ec31e.tar.gz bcm5719-llvm-2a40fb78c0ae8ba9a46cd63fad2ed50c6f5ec31e.zip |
Don't expose iterators into the list of types on the ASTContext; these are
unsafe, since many operations on the types can trigger lazy deserialization of
more types and invalidate the iterators. This fixes a crasher, but I've not
been able to reduce it to a reasonable testcase yet.
llvm-svn: 253420
Diffstat (limited to 'clang/lib/Sema/SemaLookup.cpp')
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 9b5d511818e..245c5519b22 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -3873,7 +3873,12 @@ void TypoCorrectionConsumer::addNamespaces( if (const Type *T = NNS->getAsType()) SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization; } - for (const auto *TI : SemaRef.getASTContext().types()) { + // Do not transform this into an iterator-based loop. The loop body can + // trigger the creation of further types (through lazy deserialization) and + // invalide iterators into this list. + auto &Types = SemaRef.getASTContext().getTypes(); + for (unsigned I = 0; I != Types.size(); ++I) { + const auto *TI = Types[I]; if (!TI->isClassType() && isa<TemplateSpecializationType>(TI)) continue; if (CXXRecordDecl *CD = TI->getAsCXXRecordDecl()) { |