[cfe-dev] Extracting variable name from VarDecl* Clang

Jonathan Roelofs via cfe-dev cfe-dev at lists.llvm.org
Sat Jun 4 10:30:56 PDT 2016



On 6/4/16 11:07 AM, Dhriti Khanna wrote:
> I can know the name of source file like this:
>
> SourceManager &srcManager = astContext->getSourceManager();
> srcManager.getFilename(decl->getLocation()).str() << "\n";
>
> but I want to just bypass all the nodes in other files (except for the
> source file) without this check.

Comparing SourceLocations is the only way to do it.

>
> On Sat, Jun 4, 2016 at 10:16 PM, Dhriti Khanna <dhritik at iiitd.ac.in
> <mailto:dhritik at iiitd.ac.in>> wrote:
>
>     Thank you. Just one more thing: How do I restrict the AST to a
>     single source file (passed as an argument to the clang tool)
>     excluding the functions from headers and other third party libraries
>     (if any).
>
>     On Sat, Jun 4, 2016 at 7:26 PM, Jonathan Roelofs
>     <jonathan at codesourcery.com <mailto:jonathan at codesourcery.com>> wrote:


-- 
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded



More information about the cfe-dev mailing list