getting source location for the CXXMethodDecl result type

22 views
Skip to first unread message

Vyacheslav Egorov

unread,
Jul 16, 2013, 8:42:55 AM7/16/13
to cl...@chromium.org
Hi!

I am trying to write a small rewriting tool to perform automatic "hadlification" of the raw pointers. Among other things it means I need to rewrite signatures like:

X* foo(Y*, Z*);

into 

Result<X> foo(Y*, Handle<Z>)

if X and Z are heap allocated objects and Y is not.

Unfortunately I can't figure out a way to get to X* source locations in the declaration above after I have matched CXXMethodDecl as whole.

I guess I could get to Z* by getting ParamVarDecl and asking getTypeSourceInfo of it (I have not tried it yet) but I can't see anything similar for result type. 

Am I doing it wrong? 

--
Vyacheslav Egorov

Manuel Klimek

unread,
Jul 16, 2013, 8:59:01 AM7/16/13
to Vyacheslav Egorov, cl...@chromium.org
I think the trick is that the return type is part of the FunctionTypeLoc, which has a getResultLoc...

Cheers,
/Manuel

Vyacheslav Egorov

unread,
Jul 16, 2013, 10:30:31 AM7/16/13
to Manuel Klimek, cl...@chromium.org
Thanks Manuel, 

This seems to work!

Vyacheslav Egorov
Reply all
Reply to author
Forward
0 new messages