[cfe-dev] Finding function declaration?

Ben Laurie benl at google.com
Wed May 13 23:03:56 PDT 2015


On 11 May 2015 at 11:20, Manuel Klimek <klimek at google.com> wrote:

> On Sun, May 10, 2015 at 11:54 PM Nikola Smiljanic <popizdeh at gmail.com>
> wrote:
>
>> I think you'll need to use ParentMap from ASTContext.
>>
>
> Note that the parent-map is lazy-built (that is, the first time you get a
> parent, you build the parent-map for the whole TU), and thus has a pretty
> high cost. Usually we first try to get away with not using it.
>
> Can you give a bit more context on what you're trying to do?
>

Sorry for delay ... I am trying to label functions to have certain checks
done on their return values if an attribute is set on the function.

ParentMap appears not to work for this case (it stops finding parents once
you have the function body).

Currently, the only way I could make this work was to construct a map of
function bodies that have the attribute set in an AST observer, and then
using ParentMap to get back to the body, which is looked up in the map.

Doesn't seem optimal!


>
>>
>> On Mon, May 11, 2015 at 4:18 AM, Ben Laurie <benl at google.com> wrote:
>>
>>> If I have a checker for check::PreStmt<ReturnStmt>, how do I get from
>>> the ReturnStmt to the function it is part of (I want to check
>>> attributes on that function)?
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150514/055e7273/attachment.html>


More information about the cfe-dev mailing list