This is an archive of the discontinued LLVM Phabricator instance.

[analyzer][NFC] Make the API of CallDescription safer slightly
ClosedPublic

Authored by steakhal on Nov 10 2021, 10:45 AM.

Details

Summary

The new deleted constructor overload makes sure that no implicit
conversion from 0 would happen to ArrayRef<const char*>.

Also adds nodiscard to the CallDescriptionMap::lookup()

Diff Detail

Event Timeline

steakhal created this revision.Nov 10 2021, 10:45 AM

The new deleted constructor overload makes sure that no implicit
conversion from 0 would happen to ArrayRef<const char*>.

Did you encounter a call with a nullptr?

Are there other classes in LLVM taking a single ArrayRef in the constructor? Are they using similar techniques to avoid potential problems?

The new deleted constructor overload makes sure that no implicit
conversion from 0 would happen to ArrayRef<const char*>.

Did you encounter a call with a nullptr?

I did not. But it makes sense to delete: https://quuxplusone.github.io/blog/2021/10/17/equals-delete-means/

Are there other classes in LLVM taking a single ArrayRef in the constructor?

I don't know.

Are they using similar techniques to avoid potential problems?

They should.

Szelethus accepted this revision.Nov 15 2021, 3:17 AM

I guess this constructor prevents us from to just put this into ArrayRef:

/// Construct an ArrayRef from a single element.
/*implicit*/ ArrayRef(const T &OneElt)
  : Data(&OneElt), Length(1) {}

I guess this is a "why not" patch, so, LGTM!

This revision is now accepted and ready to land.Nov 15 2021, 3:17 AM
steakhal closed this revision.Nov 17 2021, 6:58 AM

I've accidentally committed this without mentioning the Differential Revision stuff in the commit message. :(
This landed with 35ff3a0095d5b2dafa2fc8dd762377342aef9c50

How to address this?

I've accidentally committed this without mentioning the Differential Revision stuff in the commit message. :(
This landed with 35ff3a0095d5b2dafa2fc8dd762377342aef9c50

How to address this?

There is no way, as we do not have rights to force push the official upstream master.
The link is good enough. Maybe some Phabricator admin can force the connection manually.

Otherwise, whatever. The commit is in, that's it.

How to address this?

I think mentioning this is already enough. :)