This is an archive of the discontinued LLVM Phabricator instance.

[CFG] [analyzer] Add stubs for argument construction contexts for arguments of C++ constructors and Objective-C messages.
ClosedPublic

Authored by NoQ on Jun 15 2018, 4:19 PM.

Details

Summary

This is similar to D45650. Constructors of pass-by-value arguments aren't similar to other temporary constructors, we should treat them differently. For now we don't handle them, so we shouldn't produce temporary-like construction contexts for them. D45650 fixed this bug for call-expressions, but construct-expressions and Objective-C message expressions both aren't call-expressions, so they need a separate fix.

Diff Detail

Event Timeline

NoQ created this revision.Jun 15 2018, 4:19 PM
NoQ updated this revision to Diff 151584.Jun 15 2018, 4:20 PM

Whoops, that was an old patch.

chh added a subscriber: chh.Jun 18 2018, 9:35 AM
george.karpenkov requested changes to this revision.Jun 26 2018, 6:14 PM
george.karpenkov added inline comments.
lib/Analysis/CFG.cpp
2414

Would appreciate a top-level comment that this is specifically for constructors passing arguments by value.

4287

I think we can do better then duplicating the same code block three times with an exact comment as well. I do understand that it's painful due to call expressions not having a common superclass, but maybe it would be sufficient to just have a function iterating over arguments?

This revision now requires changes to proceed.Jun 26 2018, 6:14 PM
NoQ updated this revision to Diff 153155.Jun 27 2018, 12:42 PM

Code re-use!

NoQ updated this revision to Diff 153157.Jun 27 2018, 12:47 PM

Actually, yeah, add the comment.

NoQ marked 2 inline comments as done.Jun 27 2018, 12:47 PM
george.karpenkov requested changes to this revision.Jul 3 2018, 11:34 AM

Minor nit: request for code reuse.

lib/Analysis/CFG.cpp
694

Who needs inheritance if one has templates.
This is pretty bad though, I wish we could add another interface to those three, if anything just to have arguments()

lib/Analysis/ConstructionContext.cpp
115

Could we refactor the check into isCallable or whatever would be the appropriate name here?

This revision now requires changes to proceed.Jul 3 2018, 11:34 AM
NoQ retitled this revision from [analyzer] Add stubs for argument construction contexts for arguments of C++ constructors and Objective-C messages. to [CFG] [analyzer] Add stubs for argument construction contexts for arguments of C++ constructors and Objective-C messages..Jul 16 2018, 5:48 PM
george.karpenkov accepted this revision.Jul 30 2018, 5:14 PM
This revision is now accepted and ready to land.Jul 30 2018, 5:14 PM
NoQ closed this revision.Jul 31 2018, 12:41 PM

Committed in rC338425 but i accidentally screwed up the revision link.