Merge remote-tracking branch 'origin/swift-3.0-branch' into stable
* origin/swift-3.0-branch:
[index] Fix crash with indexing designated init expressions inside templates.
diff --git a/lib/Index/IndexBody.cpp b/lib/Index/IndexBody.cpp
index 74e082a..1db1114 100644
--- a/lib/Index/IndexBody.cpp
+++ b/lib/Index/IndexBody.cpp
@@ -150,7 +150,7 @@
for (DesignatedInitExpr::reverse_designators_iterator
D = E->designators_rbegin(), DEnd = E->designators_rend();
D != DEnd; ++D) {
- if (D->isFieldDesignator())
+ if (D->isFieldDesignator() && D->getField())
return IndexCtx.handleReference(D->getField(), D->getFieldLoc(),
Parent, ParentDC, SymbolRoleSet(),
{}, E);
diff --git a/test/Index/Core/index-source.cpp b/test/Index/Core/index-source.cpp
index 75c6396..c4e1290 100644
--- a/test/Index/Core/index-source.cpp
+++ b/test/Index/Core/index-source.cpp
@@ -7,3 +7,15 @@
// 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.
+ }
+};