[cfe-dev] How do I get the EndLoc for a function prototype?

scott constable via cfe-dev cfe-dev at lists.llvm.org
Wed Aug 3 11:14:18 PDT 2016


UPDATE: My mistake, my code was incorrect :). I was using
FunctionDecl::hasBody() to detect whether or not a FunctionDecl is a
prototype, whereas I should have been using
FunctionDecl::doesThisDeclarationHaveABody().

On Wed, Aug 3, 2016 at 10:59 AM, scott constable <sdconsta at syr.edu> wrote:

> Hi All,
>
> This seems really simple, but I just can't get it to work. Suppose I'm
> running a libtool over the following code:
>
> int foo(int);
>
> int foo(int i) {
>   return ++i;
> }
>
> When I intercept the first foo FunctionDecl (the prototype) with a
> RecursiveASTVisitor and I get the SourceRange, I would expect it to be
>
> int foo(int);
> ^begin      ^end
>
> int foo(int i) {
>   return ++i;
> }
>
> But instead I get
>
> int foo(int);
> ^begin
>
> int foo(int i) {
>   return ++i;
> }
> ^end
>
> Any advice would be much appreciated.
>
> Thanks in advance,
>
> Scott Constable
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160803/08bb35f5/attachment.html>


More information about the cfe-dev mailing list