This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Only check constructors for global variables
ClosedPublic

Authored by tbaeder on Dec 28 2022, 2:56 AM.

Details

Summary

This is a follow-up to https://reviews.llvm.org/D136694. I can also merge the two patches.

I couldn't come up with a better way of doing this than adding a new opcode which is only emitted from visitGlobalInitializer().

Diff Detail

Event Timeline

tbaeder created this revision.Dec 28 2022, 2:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2022, 2:56 AM
tbaeder requested review of this revision.Dec 28 2022, 2:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 28 2022, 2:56 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

So we are only checking global constructors b/c it is valid in a constant expression context to initialize a record and not initialize all their fields as long as we don't use any of those fields.

Note, cases that stem from this has been discussed as part of https://github.com/cplusplus/papers/issues/1380 but the issue is not resolved yet.

shafik accepted this revision.Feb 16 2023, 2:42 PM

LGTM

This revision is now accepted and ready to land.Feb 16 2023, 2:42 PM
This revision was landed with ongoing or failed builds.Mar 2 2023, 12:23 AM
This revision was automatically updated to reflect the committed changes.