r277570 - [index] Fix crash with indexing designated init expressions inside templates.
Argyrios Kyrtzidis via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 2 22:38:53 PDT 2016
Author: akirtzidis
Date: Wed Aug 3 00:38:53 2016
New Revision: 277570
URL: http://llvm.org/viewvc/llvm-project?rev=277570&view=rev
Log:
[index] Fix crash with indexing designated init expressions inside templates.
rdar://27452869
Modified:
cfe/trunk/lib/Index/IndexBody.cpp
cfe/trunk/test/Index/Core/index-source.cpp
Modified: cfe/trunk/lib/Index/IndexBody.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexBody.cpp?rev=277570&r1=277569&r2=277570&view=diff
==============================================================================
--- cfe/trunk/lib/Index/IndexBody.cpp (original)
+++ cfe/trunk/lib/Index/IndexBody.cpp Wed Aug 3 00:38:53 2016
@@ -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);
}
Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=277570&r1=277569&r2=277570&view=diff
==============================================================================
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Wed Aug 3 00:38:53 2016
@@ -7,3 +7,15 @@ class TemplCls {
// CHECK: [[@LINE-1]]:3 | constructor/C++ | TemplCls | c:@ST>1#T at TemplCls@F at TemplCls#I# | <no-cgname> | Decl,RelChild | rel: 1
// CHECK-NEXT: RelChild | TemplCls | c:@ST>1#T at 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.
+ }
+};
More information about the cfe-commits
mailing list