This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix the location of default init expressions
ClosedPublic

Authored by cor3ntin on Jul 18 2023, 3:25 AM.

Details

Reviewers
aaron.ballman
Group Reviewers
Restricted Project
Commits
rG64cfcde31a48: [Clang] Fix the location of default init expressions
Summary

Default member initializations constructed from
a parenthesized aggregate initialization should be constructed
at the location of the left paren, to be consistent with
brace initialization.
Otherwise we get diagmostics and source_location in the wrong places.

Fixes #63903

Diff Detail

Event Timeline

cor3ntin created this revision.Jul 18 2023, 3:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 3:25 AM
cor3ntin requested review of this revision.Jul 18 2023, 3:25 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 3:25 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
cor3ntin added reviewers: aaron.ballman, Restricted Project.Jul 18 2023, 3:25 AM

Should this come with a release note or is it correcting functionality added for this release?

clang/test/SemaCXX/source_location.cpp
796

Shouldn't this test fail because i != j?

Can you add a test that demonstrates we've corrected the source location information for diagnostics?

cor3ntin added inline comments.Jul 18 2023, 5:21 AM
clang/test/SemaCXX/source_location.cpp
796

They should all be equal!

Can you add a test that demonstrates we've corrected the source location information for diagnostics?

Hum, i was planning to do that in https://reviews.llvm.org/D155175. I can try to think of something there!

aaron.ballman added inline comments.Jul 18 2023, 5:23 AM
clang/test/SemaCXX/source_location.cpp
796

They should all be equal!

Whaaaaa? Shouldn't i == 790 && j == 791?

cor3ntin updated this revision to Diff 541473.Jul 18 2023, 5:32 AM

Address Aaron's comments

tbaeder added inline comments.
clang/test/SemaCXX/source_location.cpp
796

IIUC, they are evaluated as part of the constructor, so the values should be 795 or 796. Maybe that can be changed to

static_assert(S(0).i == S{0}.i == 796);

?

cor3ntin added inline comments.Jul 18 2023, 5:42 AM
clang/test/SemaCXX/source_location.cpp
796
aaron.ballman accepted this revision.Jul 18 2023, 5:44 AM

LGTM

clang/test/SemaCXX/source_location.cpp
796

Oh yeah! Thank you for the reminder, that makes sense now. A comment reminding other readers might not be a bad idea.

This revision is now accepted and ready to land.Jul 18 2023, 5:44 AM
This revision was automatically updated to reflect the committed changes.