[cfe-dev] Get the header file in which a function is declared

Sean Silva chisophugis at gmail.com
Mon Apr 6 16:09:33 PDT 2015


Try one of the methods that returns a SourceLocation (or SourceRange). E.g.
getLocStart() which it inherits from Decl.
http://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html

-- Sean Silva

On Mon, Apr 6, 2015 at 1:27 PM, Riyad Parvez <riyad.parvez at gmail.com> wrote:

> Hi,
>
> I'm trying to get header file in which a function is declared using
> libtooling in clang.
>
>
> #include <stdio.h>
>
> int main() {
>   void *ptr = malloc(10);
>   return 0;
> }
>
> In above example, I can get "FunctionDecl" object of "malloc". But how can
> I get in which header file "malloc" is declared (in above example, it's
> "stdio.h") provided that I've "FunctionDecl" object?
>
> Thanks
> Riyad
> _______________________________________________
> 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/20150406/9e9db657/attachment.html>


More information about the cfe-dev mailing list