[clang] [clang-tools-extra] [CLANGD] Do not crash on designator initialization of union (PR #83369)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 18:52:39 PDT 2024
================
@@ -4601,8 +4601,15 @@ SourceRange DesignatedInitExpr::getDesignatorsSourceRange() const {
SourceLocation DesignatedInitExpr::getBeginLoc() const {
auto *DIE = const_cast<DesignatedInitExpr *>(this);
Designator &First = *DIE->getDesignator(0);
- if (First.isFieldDesignator())
- return GNUSyntax ? First.getFieldLoc() : First.getDotLoc();
+ if (First.isFieldDesignator()) {
+ for (unsigned int i = 0; i < DIE->size(); i++) {
----------------
alirezamoshtaghi wrote:
I ended up using EXPECT_UNAVAILABLE because it still fails for crashing case.
but when I use EXPECT_AVAILABLE, it complains as:
Expected equality of these values:
true
isAvailable(AST, R)
Which is: false
struct A {
struct {
int x;
};
};
struct B {
int y;
};
void foo(struct B *b) {
struct A a = {.[[x]]=b->y};
}
https://github.com/llvm/llvm-project/pull/83369
More information about the cfe-commits
mailing list