[cfe-dev] Get filename from ASTVisitor

Gábor Kozár kozargabor at gmail.com
Sun Apr 21 10:03:21 PDT 2013


Hi,

You can get the SourceLocation of the Decl using getLocStart(), getLocEnd()
or getLocation(). Then you can use SourceManager :: getBufferName() to get
the name of the file containing the SourceLocation.

Hope this helps.

Gabor


2013/4/21 suppamax <max.giacometti at gmail.com>

> I am using a RecursiveASTVisitor to get the declaration statements of my
> code.
> I took inspiration from the example shown here:
>
> http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang/
>
> I extended the example so to include "included" files in the AST (this is
> necessary to be able to identify variable declarations that use non-basic
> data types).
>
> Now I want to filter all variable declarations that are not part of the
> file
> that I want to analyze.
> How can I do this?
>
>
> Thanks a lot,
> Max
>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/Get-filename-from-ASTVisitor-tp4031615.html
> Sent from the Clang Developers mailing list archive at Nabble.com.
> _______________________________________________
> 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/20130421/2e8739b0/attachment.html>


More information about the cfe-dev mailing list