[LLVMdev] The line number range of a function in source code level

Hongxu Chen leftcopy.chx at gmail.com
Fri Apr 12 04:48:56 PDT 2013


"liuml07 [via LLVM]" <ml-node+s1065342n56664h75 at n5.nabble.com> writes:

There is a `std::reverse_iterator' that might be useful. See this page
below for more information.

https://github.com/jirislaby/LLVMSlicer/blob/master/src/Slicing/FunctionStaticSlicer.cpp#L331

> Hi all,
>
> I need to know the line number range of a function. The start of the function
> line number can be found by the definition point, which is stored at the
> subprogram metadata: DISubprogram::getLineNumber().
>
> However, there is no API (or the metadata in the first place) to know the end of
> the function.
>
> I have to visit all the instructions of the function and maintain the max line
> number of the instructions. I use the inst_begin(func): inst_end(func) as the
> iterator. But I don't think it's effective to iterate all the instructions from
> the beginning. It's supposed that we can iterate the instructions reversely and
> the first one who has attached metadata should be treated as the end of the
> function. Unfortunately, there is no reverse iterator of a function.
>
> Any idea?
>
> Thank you very much!

-- 
Regards,
Hongxu Chen




--
View this message in context: http://llvm.1065342.n5.nabble.com/The-line-number-range-of-a-function-in-source-code-level-tp56664p56667.html
Sent from the LLVM - Dev mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130412/978ffa91/attachment.html>


More information about the llvm-dev mailing list