File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -141,8 +141,10 @@ void collectDesignators(const InitListExpr *Sem,
141
141
Fields.next (); // Always advance to the next subobject name.
142
142
Prefix.resize (Size); // Erase any designator we appended.
143
143
});
144
- if (llvm::isa<ImplicitValueInitExpr>(Init))
145
- continue ; // a "hole" for a subobject that was not explicitly initialized
144
+ // Skip for a broken initializer or if it is a "hole" in a subobject that
145
+ // was not explicitly initialized.
146
+ if (!Init || llvm::isa<ImplicitValueInitExpr>(Init))
147
+ continue ;
146
148
147
149
const auto *BraceElidedSubobject = llvm::dyn_cast<InitListExpr>(Init);
148
150
if (BraceElidedSubobject &&
Original file line number Diff line number Diff line change @@ -1417,6 +1417,17 @@ TEST(DesignatorHints, OnlyAggregateInit) {
1417
1417
)cpp" /* no designator hints expected (but param hints!)*/ );
1418
1418
}
1419
1419
1420
+ TEST (DesignatorHints, NoCrash) {
1421
+ assertDesignatorHints (R"cpp(
1422
+ /*error-ok*/
1423
+ struct A {};
1424
+ struct Foo {int a; int b;};
1425
+ void test() {
1426
+ Foo f{A(), $b[[1]]};
1427
+ }
1428
+ )cpp" , ExpectedHint{" .b=" , " b" });
1429
+ }
1430
+
1420
1431
TEST (InlayHints, RestrictRange) {
1421
1432
Annotations Code (R"cpp(
1422
1433
auto a = false;
You can’t perform that action at this time.
0 commit comments