This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Directly create opaque pointers
ClosedPublic

Authored by nikic on Jun 9 2023, 1:18 AM.

Details

Summary

In CGTypes, directly create opaque pointers, without computing the LLVM element type. This is not as straightforward as I though it would be, because apparently computing the LLVM type also causes a number of side effects, such as -Wpacked diagnostics or -fdump-record-layouts.

I've adjusted tests accordingly, but there is still one failure in test/Modules/compare-record.c. It fails to emit the error for CompareIndirectStructPointer and I'm not really sure what to do about it.

Diff Detail

Event Timeline

nikic created this revision.Jun 9 2023, 1:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2023, 1:18 AM
Herald added a subscriber: StephenFan. · View Herald Transcript
nikic requested review of this revision.Jun 9 2023, 1:18 AM

I really dislike that these diagnostics are being triggered by requesting layout. I don't expect you to fix that, of course, I'm just registering my disapproval.

I think it's fine that we're not triggering the diagnostic anymore in that indirect-pointer test. We'd trigger it if we actually did something in this translation unit that depended on the layout of that struct, which is what matters.

nikic updated this revision to Diff 531220.Jun 14 2023, 12:50 AM

Update compare-record.c test to no longer expected diagnostic for pointer type.

rjmccall accepted this revision.Jun 14 2023, 9:53 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jun 14 2023, 9:53 AM
This revision was landed with ongoing or failed builds.Jun 15 2023, 12:09 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 15 2023, 12:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript