This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Fix copy constructors of structs with array members
ClosedPublic

Authored by tbaeder on Sep 21 2022, 7:16 AM.

Details

Summary

This implements ArrayInitLoopExprs in initializers and fixes a few issues I encountered along the way, with copy constructors generally.

Diff Detail

Event Timeline

tbaeder created this revision.Sep 21 2022, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 7:16 AM
tbaeder requested review of this revision.Sep 21 2022, 7:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2022, 7:16 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Sep 28 2022, 5:32 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
643
656–666

In all of these cases we're leaving ArrayIndex set to I instead of None, is that intentional? (Might be worth an RAII object to handle this sort of thing.)

tbaeder marked an inline comment as done.Sep 28 2022, 5:42 AM
tbaeder added inline comments.
clang/lib/AST/Interp/ByteCodeExprGen.cpp
656–666

Heh :) Good you notice this as well. Yes, that's something I was worried about. It's not intentional at all. I'll try adding a RAII object.

tbaeder updated this revision to Diff 463522.Sep 28 2022, 6:17 AM
tbaeder marked an inline comment as done.
This revision is now accepted and ready to land.Sep 28 2022, 6:22 AM
shafik added inline comments.Sep 28 2022, 10:02 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
651

Curious what case requires this check?

clang/lib/AST/Interp/ByteCodeExprGen.h
382

Why an Optional? Your not checking it and I don't see how it won't be set?

tbaeder added inline comments.Sep 28 2022, 10:07 AM
clang/lib/AST/Interp/ByteCodeExprGen.cpp
651

I don't think there's a real test case for this, we could as well change the initializer to *classify(SubExpr->getType());. It's just the pattern used everywhere else. We could also use classifyPrim instead.

clang/lib/AST/Interp/ByteCodeExprGen.h
382

The first time we see an ArrayInitLoopExpr, the ByteCodeExprGen<Emitter>::ArrayIndex will be None, so we need to use this here (note: just writing this right now, it's pretty late for me, I didn't test just using a uint64_t)

This revision was landed with ongoing or failed builds.Oct 14 2022, 1:22 AM
This revision was automatically updated to reflect the committed changes.