This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Fix crash in `modernize-use-default-member-init`
ClosedPublic

Authored by AMS21 on Jun 13 2023, 5:11 AM.

Details

Summary

This was causes by getValueOfValueInit unconditionally calling
getScalarTypeKind on the member type, which would then trigger an
assertions since arrays are not scalar type.

This fixes llvm#63285

Diff Detail

Event Timeline

AMS21 created this revision.Jun 13 2023, 5:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 5:11 AM
Herald added a subscriber: xazax.hun. · View Herald Transcript
AMS21 requested review of this revision.Jun 13 2023, 5:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2023, 5:11 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
AMS21 edited the summary of this revision. (Show Details)Jun 13 2023, 5:34 AM
PiotrZSL added inline comments.Jun 13 2023, 5:38 AM
clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
274–276

instead of ignoring array types, better would be just not provide FixItHints for them, so WRN would stil be emited.

AMS21 updated this revision to Diff 530892.Jun 13 2023, 6:47 AM
AMS21 marked an inline comment as done.

Still issue a warning just no fixit

Maybe we should still support arrays.... in some way

clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
273
const bool ValueInit = isa<ImplicitValueInitExpr>(InitExpression) && !isa<ArrayType>(InitType);

This should do a trick.

AMS21 updated this revision to Diff 530921.Jun 13 2023, 8:28 AM
AMS21 marked an inline comment as done.

Should now properly handle arrays

Thanks for fixing this issue.

This revision is now accepted and ready to land.Jun 13 2023, 10:24 AM

Great, would someone be so kind and push this on by behalf :)

This revision was automatically updated to reflect the committed changes.