Skip to content

Commit f5202d5

Browse files
committed
[Index] Ignore nullptr decls for indexing
We can end up with a call to `indexTopLevelDecl(D)` with `D == nullptr` in non-assert builds e.g. when indexing a module in `indexModule` and - `ASTReader::GetDecl` returns `nullptr` if `Index >= DeclsLoaded.size()`, thus returning `nullptr` => `ModuleDeclIterator::operator*` returns `nullptr` => we call `IndexCtx.indexTopLevelDecl` with `nullptr` Be resilient and just ignore the `nullptr` decls during indexing. Reviewed By: akyrtzi Differential Revision: https://reviews.llvm.org/D102001
1 parent 799bd79 commit f5202d5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

clang/lib/Index/IndexDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ bool IndexingContext::indexDeclContext(const DeclContext *DC) {
759759
}
760760

761761
bool IndexingContext::indexTopLevelDecl(const Decl *D) {
762-
if (D->getLocation().isInvalid())
762+
if (!D || D->getLocation().isInvalid())
763763
return true;
764764

765765
if (isa<ObjCMethodDecl>(D))

0 commit comments

Comments
 (0)