mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-27 23:51:56 +00:00
[clang][index] Fix a crash for accessing a null field decl.
getField() may return a nullptr, we already did that in BodyIndexer::VisitDesignatedInitExpr, but missed one place.
This commit is contained in:
parent
1c3d9c2f36
commit
c2c36c4f4b
@ -414,7 +414,7 @@ public:
|
||||
|
||||
auto visitSyntacticDesignatedInitExpr = [&](DesignatedInitExpr *E) -> bool {
|
||||
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);
|
||||
|
8
clang/test/Index/index-designated-init-recovery.cpp
Normal file
8
clang/test/Index/index-designated-init-recovery.cpp
Normal file
@ -0,0 +1,8 @@
|
||||
struct Bar {};
|
||||
struct Foo {
|
||||
void method(Bar bar) {}
|
||||
};
|
||||
void NoCrash(Foo t) {
|
||||
t.method({.abc = 50}); // CHECK: field designator 'abc' does not refer to any field in type 'Bar'
|
||||
}
|
||||
// RUN: c-index-test -index-file %s -Xclang -frecovery-ast 2>&1 | FileCheck %s
|
Loading…
Reference in New Issue
Block a user