This is an archive of the discontinued LLVM Phabricator instance.

[clang][Interp] Fix diagnosing uninitialized ctor record arrays
ClosedPublic

Authored by tbaeder on Feb 5 2023, 2:12 AM.

Details

Summary

No idea why I used isa<RecordType>(ElemType.getTypePtr()) here, but it broke detecting that the element type is of record type.

Other than that, I think a previous patch made it possible to enable those two tests that have been disabled so far.

Diff Detail

Event Timeline

tbaeder created this revision.Feb 5 2023, 2:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 5 2023, 2:12 AM
tbaeder requested review of this revision.Feb 5 2023, 2:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 5 2023, 2:12 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
aaron.ballman added inline comments.Mar 1 2023, 12:12 PM
clang/lib/AST/Interp/Interp.cpp
389

The difference between these two is that isRecordType() is looking at the canonical type whereas isa<> is looking at the type under inspection rather than the canonical type. I'd expect these to have the same behavior in most cases, but only matter for cases involving typedefs.

I think you're correct about the test case below not needing these particular changes -- at least, I'm not seeing what's changed that should impact the test. Should this be split into two changes? 1) Expose the test, 2) Make this functional change + add a new test where the canonical type is different to demonstrate the fix.

shafik added inline comments.Mar 14 2023, 9:57 PM
clang/lib/AST/Interp/Interp.cpp
389

+1

tbaeder added inline comments.Mar 15 2023, 2:13 AM
clang/lib/AST/Interp/Interp.cpp
389

Can you come up with a small test case that would show the difference? You mentioned typedefs, but if the array is of a typedef type, the old isa<> version doesn't work either.

clang/test/AST/Interp/cxx20.cpp
182

This line actually needs the changes in this patch, the array is of record type.

aaron.ballman accepted this revision.May 16 2023, 10:48 AM

LG with a request for an additional test.

clang/lib/AST/Interp/Interp.cpp
389

Ah, I see what you mean, yeah. With a typedef type, the isa would have also failed. That's a good test case to add to this patch as well.

This revision is now accepted and ready to land.May 16 2023, 10:48 AM
This revision was landed with ongoing or failed builds.May 31 2023, 2:40 AM
This revision was automatically updated to reflect the committed changes.