This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Fix lambda CheckForDefaultedFunction(...) so that it checks the CXXMethodDecl is a special member function before attempting to call DefineDefaultedFunction(...)
ClosedPublic

Authored by shafik on Aug 29 2022, 6:54 PM.

Details

Summary

In Sema::CheckCompletedCXXClass(...) It used a lambda CheckForDefaultedFunction the CXXMethodDecl passed to CheckForDefaultedFunction may not be a special member function and so before attempting to apply functions that only apply to special member functions it needs to check. It fails to do this before calling DefineDefaultedFunction(...). This PR adds that check and test to verify we no longer crash.

This fixes https://github.com/llvm/llvm-project/issues/57431

Diff Detail

Event Timeline

shafik created this revision.Aug 29 2022, 6:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 29 2022, 6:54 PM
shafik requested review of this revision.Aug 29 2022, 6:54 PM
aaron.ballman accepted this revision.Aug 30 2022, 12:20 PM

LGTM aside from a minor test formatting nit. Please be sure to also write a release note for the fix.

clang/test/SemaCXX/constant-expression-cxx2a.cpp
1478–1482
This revision is now accepted and ready to land.Aug 30 2022, 12:20 PM
shafik updated this revision to Diff 456827.Aug 30 2022, 6:03 PM
  • Fixed formatting in test
  • Added release note
shafik added inline comments.Aug 30 2022, 6:05 PM
clang/lib/Sema/SemaDeclCXX.cpp
6957–6958

I realized that based on the constraints on the functions called in DefineDefaultedFunction we also should be checking isDeleted() as well but based on the way I drafted this PR I should just do a follow-up.

This revision was landed with ongoing or failed builds.Aug 30 2022, 6:13 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 6:13 PM