[cfe-dev] Ownership attribute for malloc etc. checking

Ted Kremenek kremenek at apple.com
Mon Jun 28 18:27:13 PDT 2010


On Jun 28, 2010, at 6:16 PM, Andrew McGregor wrote:

> Hmm, but which is cleaner and clearer... have the checker know that arguments might be attributed as well, or have the parser push attributes from arguments onto the function?  The latter is probably less code, but might be rather obscure.  On the other hand, that whole attribute parser is pretty obscure, and is full of 'fixme's saying it deserves redesigned.
> 


I don't think we want to duplicate attributes; attributes on the ParmVarDecls should only be on the ParmVarDecls, unless of course we want to incorporate the the attributes into the function's type.  The AST should have high fidelity to the actual source code.

That said, I don't think the checker should be in the business of having to reason about how the function was annotated.  The checker just cares about the semantics, while it's up to the parser and the attributes to handle the syntax.

One possible solution is to provide a static function(s) to OwnershipAttr et al that allows one to query a FunctionDecl for the relevant annotations.  Then the checker just cares if a parameter is annotated, but it doesn't care how it was written.



More information about the cfe-dev mailing list