Open jirislaby opened 3 months ago
Now I see that the beginLoc
(the <invalid sloc>
one) is inherited from ImplicitValueInitExpr 0x56499f84bdf8 <<invalid sloc>> 'int'
. If either Bunused
is removed from struct B
or initialized as .Ab.Bunused = 3
, it is all good.
Perhaps ImplicitValueInitExpr
should be skipped when constructing SourceRange
s of the surrounding InitListExpr
?
@llvm/issue-subscribers-clang-frontend
Author: Jiri Slaby (jirislaby)
Looks like ImplicitValueInitExpr
always returns empty SourceLocation
:
From the description that seems to make sense since they are implicit.
CC @AaronBallman
Looks like ImplicitValueInitExpr always returns empty SourceLocation:
Sure, no problem with that. But why is it inherited into the parent (InitListExpr
). That's what I am reporting ;).
Within InitListChecker::createInitListExpr()
, when the CurrentObjectType
is an ElaboratedType
for struct B
, the begin range is invalid but the end of the range is valid. This value comes from https://github.com/llvm/llvm-project/blob/a7fb25dd1fcc2e5afcc65cccfa83b7b381b48906/clang/lib/Sema/SemaInit.cpp#L2757
I've not had the chance to dig in to why the designator is created without a valid location, so hopefully someone else can pick it up from here.
For this code:
The inner
InitListExpr
(the second line here) has invalidSourceRange
:If I do:
((InitListExpr *)0x56499f84bd48)->getSourceRange().isInvalid()
, I receivefalse
(due to obvious<invalid sloc>
).Is this expected?
BTW, it is enough to run clang like this on the code above: