This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR38888
ClosedPublic

Authored by lebedev.ri on Sep 10 2018, 12:35 PM.

Details

Summary

I have hit this the rough way, while trying to use this in D51870.

There is no particular point in storing the pointers, and moreover
the pointers are assumed to be non-null, and that assumption is not
enforced. If they are null, it won't be able to do anything good
with them anyway.

Initially i thought about simply adding asserts() that they are
not null, but taking/storing references looks like even cleaner solution?

Fixes PR38888

Diff Detail

Event Timeline

lebedev.ri created this revision.Sep 10 2018, 12:35 PM
lebedev.ri added inline comments.Sep 10 2018, 12:36 PM
clang-tidy/utils/ExprMutationAnalyzer.cpp
209–214

Hm, looks like i failed to rebase the patch :)
Will fix momentarily.

lebedev.ri marked an inline comment as done.

Fixed diff.

shuaiwang accepted this revision.Sep 10 2018, 12:52 PM

LGTM :)

This revision is now accepted and ready to land.Sep 10 2018, 12:52 PM

I am in favor of the change.

I feel that the findMutation... functions that take raw pointers should get the assertions though, at least the ones in the public interface. Having them for the private ones won't hurt either.

LGTM :)

Thank you for the review!

I feel that the findMutation... functions that take raw pointers should get the assertions though, at least the ones in the public interface. Having them for the private ones won't hurt either.

I could do that.
But should that come with tests?
Or do we want to also take references there?

This revision was automatically updated to reflect the committed changes.

I think you dont need tests there. Its just life insurance :)

I'd stick with pointers because working with the AST always results in
pointers. It is more convenient to stay in pointerland there.

I feel that the findMutation... functions that take raw pointers should get the assertions though, at least the ones in the public interface. Having them for the private ones won't hurt either.

I could do that.
But should that come with tests?
Or do we want to also take references there?