This is an archive of the discontinued LLVM Phabricator instance.

New functionality for the consumed analysis
ClosedPublic

Authored by chriswailes on Aug 21 2013, 2:34 PM.

Details

Summary

The following functionality was added:

  • The same functionality is now supported for both CXXOperatorCallExprs and CXXMemberCallExprs.
  • Factored out some code in StmtVisitor.
  • Removed variables from the state map when their destructors are encountered.
  • Started adding documentation for the consumed analysis attributes.

Diff Detail

Event Timeline

I don't see any test cases related to warnUseOfTempWhileConsumed, but
aside from that, the patch LGTM. However, I defer to others on the
final check-off.

Thanks!

~Aaron

LGTM.

lib/Analysis/Consumed.cpp
446

Is the assumption here that calling a non-const method puts the object into an unknown state? That's a correct, conservative judgement.

However, an alternative is to assume that unmarked methods do not change the object state, which might be more user-friendly in the common case.

Aaron, you are correct. There is not currently a test for that. I can
either add one to this patch or ensure that one is in the next patch.

DeLesely: That was the assumption that David and I came up with. This will
produce more errors, but should catch more bugs. There could be a problem,
however, when a method does change internal state, but not state that is
relevant to the "consumed/unconsumed" status of the object. This method
couldn't be marked constant, and would therefor transition the object out
of its known state.

  • Chris
chriswailes updated this revision to Unknown Object (????).Aug 21 2013, 4:20 PM

Added a test for calling a 'CallableWhenUnconsumed' method on a temporary object in the consumed state.

Patch LGTM, thanks for the extra testcase!

~Aaron

dblaikie accepted this revision.Apr 5 2014, 4:23 PM

Already committed in 189059

dblaikie closed this revision.Apr 5 2014, 4:23 PM