[PATCH] Fixes and features for Consumed analysis

David Blaikie dblaikie at gmail.com
Wed Aug 21 13:53:40 PDT 2013

On Wed, Aug 21, 2013 at 11:54 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> On Wed, Aug 21, 2013 at 2:39 PM, Christian Wailes
> <chriswailes at google.com> wrote:
>> The tests that for making sure warnings are issued when attributes are
>> attached to the wrong kind of thing aren't in warn-consumed-analysis.cpp.
>> Like I said, they are in warn-consumed-parsing.cpp.
> Apologies for the reading comprehension failure.
> The SemaCXX/warn-consumed-parsing.cpp does have some of the tests I
> was looking for (it's missing ones for constructors and destructors),
> and brings up an improvement I'd like to see (at some point):
> void function0(void) CONSUMES; // expected-warning {{'consumes'
> attribute only applies to methods}}
> This is a very confusing warning for the user since the attribute is
> applied to a method.  I think warn_attribute_wrong_decl_type and
> err_attribute_wrong_decl_type should have a new field for instance
> methods (or are static member functions also acceptable?).

Ideally, eventually, I think - these attributes should apply to member
functions and non-member (or static member) functions alike. In the
non-member case (maybe even in the member case?) they should annotate
a parameter (or otherwise reference a parameter that the function
annotation attaches to) to describe that /that/ parameter is consumed
(or initialized, or must be in some state, etc) by the function call.

I haven't followed exactly where we are with that just yet. I think
currently we assume non-const reference parameters (& non-const member
functions) consume?

- David

More information about the cfe-commits mailing list