This is an archive of the discontinued LLVM Phabricator instance.

[clang] Skip defaulted functions in zero-as-null-pointer-constant.
ClosedPublic

Authored by massberg on Nov 25 2022, 9:12 AM.

Details

Summary

The zero-as-null-pointer-constant check should not fire if it is inside
a defaulted function, e.g. defaulted spaceship operators.
Add C++20 tests with spaceship operators.

Fixes #50221

Diff Detail

Event Timeline

massberg created this revision.Nov 25 2022, 9:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 25 2022, 9:12 AM
massberg requested review of this revision.Nov 25 2022, 9:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 25 2022, 9:12 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
massberg updated this revision to Diff 478227.Nov 28 2022, 6:50 AM

Sync to head.

massberg updated this revision to Diff 478261.Nov 28 2022, 8:53 AM

Run clang-format on changed files.

ilya-biryukov accepted this revision.Nov 28 2022, 9:03 AM

LGTM with a few NITs. Thanks!

clang/lib/Sema/Sema.cpp
600

NIT: maybe even shorten to "ignore in defaulted comparison operators"

clang/test/SemaCXX/warn-zero-nullptr-cxx20.cpp
4

NIT: I believe you don't need it as you don't use definitions like NULL or SYSTEM_MACRO from this header.
Similarly, -isystem %S/Inputs is not required.

This revision is now accepted and ready to land.Nov 28 2022, 9:03 AM
massberg updated this revision to Diff 478477.Nov 29 2022, 12:26 AM

Fixed comments and removed unnecessary includes.

massberg marked 2 inline comments as done.Nov 29 2022, 1:12 AM

Thanks for the comments!

Note: The build failures are in parts of the code that isn't effected by this change.

This revision was landed with ongoing or failed builds.Nov 29 2022, 2:56 AM
This revision was automatically updated to reflect the committed changes.