aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Index/IndexDecl.cpp
diff options
context:
space:
mode:
authorAlex Hoppen <ahoppen@apple.com>2021-05-06 13:11:26 -0700
committerArgyrios Kyrtzidis <kyrtzidis@apple.com>2021-05-06 13:12:26 -0700
commita3a8a1a15b524d91b5308db68e9d293b34cd88dd (patch)
treea6b25c1715afc8512a37e3f0f10cbdf4be07d5b3 /clang/lib/Index/IndexDecl.cpp
parent6304c0836a4dd2d77373d45716092b2a088fa948 (diff)
downloadllvm-a3a8a1a15b524d91b5308db68e9d293b34cd88dd.zip
llvm-a3a8a1a15b524d91b5308db68e9d293b34cd88dd.tar.gz
llvm-a3a8a1a15b524d91b5308db68e9d293b34cd88dd.tar.bz2
[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
Diffstat (limited to 'clang/lib/Index/IndexDecl.cpp')
-rw-r--r--clang/lib/Index/IndexDecl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp
index 2ba323e..00adb36 100644
--- a/clang/lib/Index/IndexDecl.cpp
+++ b/clang/lib/Index/IndexDecl.cpp
@@ -759,7 +759,7 @@ bool IndexingContext::indexDeclContext(const DeclContext *DC) {
}
bool IndexingContext::indexTopLevelDecl(const Decl *D) {
- if (D->getLocation().isInvalid())
+ if (!D || D->getLocation().isInvalid())
return true;
if (isa<ObjCMethodDecl>(D))