This is an archive of the discontinued LLVM Phabricator instance.

[CFG] [analyzer] Add construction contexts for C++ objects returned from Objective-C messages.
ClosedPublic

Authored by NoQ on Jun 26 2018, 2:17 PM.

Details

Summary

This patch extends D44120 to Objective-C messages that can also sometimes return C++ objects (in Objective-C++), but aren't inheriting from CallExpr. We'll now be able to properly destroy temporaries returned from such messages and/or materialize them. The analyzer picks up the newly added context automatically, as demonstrated by the new test case.

I removed the getCallReturnType() check because most of its branches aren't useful in our case.

Diff Detail

Repository
rC Clang

Event Timeline

NoQ created this revision.Jun 26 2018, 2:17 PM
george.karpenkov requested changes to this revision.Jun 26 2018, 5:31 PM

Minor nits: would like some more comments.

include/clang/Analysis/CFG.h
185

Can we have a comment on why are filtering out GLValues here?

lib/Analysis/CFG.cpp
815

It's tempting to factor this tower of if's into a function returning bool.
Then an appropriate name could be used to indicate semantics, which I'm currently not sure about.

819

Do we want to cleanup construction context here even if the condition below is not met?

This revision now requires changes to proceed.Jun 26 2018, 5:31 PM
NoQ updated this revision to Diff 153165.Jun 27 2018, 1:34 PM

Code re-use!

And the comment.

NoQ marked 2 inline comments as done.Jun 27 2018, 1:34 PM
NoQ added inline comments.
lib/Analysis/CFG.cpp
819

Yeah, most certainly. Failure to create construction context from existing layers indicates that we've encountered a valid set of layers that's currently not supported. We still need to inform the rest of the builder that these layers were taken into account rather than leaked.

george.karpenkov accepted this revision.Jul 2 2018, 10:34 AM
This revision is now accepted and ready to land.Jul 2 2018, 10:34 AM
This revision was automatically updated to reflect the committed changes.