diff options
-rw-r--r-- | clang/include/clang/AST/ASTContext.h | 10 | ||||
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 7 |
2 files changed, 6 insertions, 11 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index a6d97aaec2e..b24e7652312 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -2274,16 +2274,6 @@ public: QualType getCorrespondingUnsignedType(QualType T) const; //===--------------------------------------------------------------------===// - // Type Iterators. - //===--------------------------------------------------------------------===// - typedef llvm::iterator_range<SmallVectorImpl<Type *>::const_iterator> - type_const_range; - - type_const_range types() const { - return type_const_range(Types.begin(), Types.end()); - } - - //===--------------------------------------------------------------------===// // Integer Values //===--------------------------------------------------------------------===// 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()) { |