This is an archive of the discontinued LLVM Phabricator instance.

Move definitions to prevent incomplete types.
ClosedPublic

Authored by massberg on Jan 13 2023, 2:50 AM.

Details

Summary

C++20 is more strict when erroring out due to incomplete types.
Thus the code required some restructoring so that it complies in C++20.

Diff Detail

Event Timeline

massberg created this revision.Jan 13 2023, 2:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2023, 2:50 AM
massberg requested review of this revision.Jan 13 2023, 2:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 13 2023, 2:50 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
ilya-biryukov added a subscriber: kadircet.

There is potentially a way to move less code by keeping all declarations at place and only moving bodies of definitions of constructors and destructors to the .cpp file.
Not sure what's preferable (less code moves vs more functions inline in the header), @kadircet do you have an opinion?

There is potentially a way to move less code by keeping all declarations at place and only moving bodies of definitions of constructors and destructors to the .cpp file.
Not sure what's preferable (less code moves vs more functions inline in the header), @kadircet do you have an opinion?

Having as few code in headers as possible is the general style guide in LLVM, so I'd rather err towards that and put definitions out-of-line as much as possible. Therefore if we can getaway by just moving definitions out-of-line, while keeping rest of the header ordering the same, let's go with that if it's feasible

Having as few code in headers as possible is the general style guide in LLVM, so I'd rather err towards that and put definitions out-of-line as much as possible. Therefore if we can getaway by just moving definitions out-of-line, while keeping rest of the header ordering the same, let's go with that if it's feasible

Thanks! I will check if I can get a version without reordering.

massberg updated this revision to Diff 488976.Jan 13 2023, 6:00 AM

Clean up code and only mode definitions.

massberg retitled this revision from Move around structs and definitions to prevent incomplete types. to Move definitions to prevent incomplete types..Jan 13 2023, 6:00 AM

I have updated the code. It turned out that much less code has to be moved than I initially thought. :)

kadircet accepted this revision.Jan 13 2023, 6:32 AM

thanks, LGTM! (btw, i know it's too late already, but in theory clangd has a code action called move definition out-of-line, could help with such refactorings in the future, if you didn't know already)

This revision is now accepted and ready to land.Jan 13 2023, 6:32 AM
ilya-biryukov accepted this revision.Jan 13 2023, 6:57 AM

LGTM! Looks much cleaner now, BTW.

This revision was landed with ongoing or failed builds.Jan 13 2023, 7:45 AM
This revision was automatically updated to reflect the committed changes.