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().
Paths 
  |  Differential  D140723  
[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 TimelineComment Actions 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. 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 Closed by commit rG569222e172e5: [clang][Interp] Only check constructors for global variables (authored by tbaeder).  ·  Explain Why This revision was automatically updated to reflect the committed changes. 
Revision Contents 
 
Diff 485480 clang/lib/AST/Interp/ByteCodeExprGen.h
 clang/lib/AST/Interp/Interp.h
 clang/lib/AST/Interp/Interp.cpp
 clang/lib/AST/Interp/Opcodes.td
 clang/test/AST/Interp/cxx20.cpp
  | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||