diff options
-rw-r--r-- | clang/lib/Index/IndexBody.cpp | 2 | ||||
-rw-r--r-- | clang/test/Index/Core/index-source.cpp | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Index/IndexBody.cpp b/clang/lib/Index/IndexBody.cpp index 4908d852e89..62f4e8802ae 100644 --- a/clang/lib/Index/IndexBody.cpp +++ b/clang/lib/Index/IndexBody.cpp @@ -148,7 +148,7 @@ public: bool VisitDesignatedInitExpr(DesignatedInitExpr *E) { for (DesignatedInitExpr::Designator &D : llvm::reverse(E->designators())) { - if (D.isFieldDesignator()) + if (D.isFieldDesignator() && D.getField()) return IndexCtx.handleReference(D.getField(), D.getFieldLoc(), Parent, ParentDC, SymbolRoleSet(), {}, E); } diff --git a/clang/test/Index/Core/index-source.cpp b/clang/test/Index/Core/index-source.cpp index 75c6396da55..c4e12903f6c 100644 --- a/clang/test/Index/Core/index-source.cpp +++ b/clang/test/Index/Core/index-source.cpp @@ -7,3 +7,15 @@ class TemplCls { // CHECK: [[@LINE-1]]:3 | constructor/C++ | TemplCls | c:@ST>1#T@TemplCls@F@TemplCls#I# | <no-cgname> | Decl,RelChild | rel: 1 // CHECK-NEXT: RelChild | TemplCls | c:@ST>1#T@TemplCls }; + +template <typename T> +class BT { + struct KLR { + int idx; + }; + + // CHECK: [[@LINE+1]]:7 | instance-method/C++ | foo | + KLR foo() { + return { .idx = 0 }; // Make sure this doesn't trigger a crash. + } +}; |