Author: Alex Hoppen
Date: 2021-05-06T13:12:26-07:00
New Revision: a3a8a1a15b524d91b5308db68e9d293b34cd88dd

URL: 
https://github.com/llvm/llvm-project/commit/a3a8a1a15b524d91b5308db68e9d293b34cd88dd
DIFF: 
https://github.com/llvm/llvm-project/commit/a3a8a1a15b524d91b5308db68e9d293b34cd88dd.diff

LOG: [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

Added: 
    

Modified: 
    clang/lib/Index/IndexDecl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp
index 2ba323e63575..00adb3644ff2 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))


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to