[cfe-dev] Ignore the content from the included files with RecursiveASTVisitor

Richard Smith richard at metafoo.co.uk
Mon Mar 17 17:51:42 PDT 2014


It appears that nabble.com failed to send your AST dump and code snippet to
the mailing list. Snippets listed below.

On Mon, Mar 17, 2014 at 4:13 PM, Etienne <eollivier at bsu.edu> wrote:

> Hello,
> I am working on a project where I am using the RecursiveASTVisitor to get
> metrics from files.
> I would like to exclude the parts of the AST that are from included files,
> so the metrics I get concern only the file I want to analyze.
> I tried to check the location of the Statements, Declarations etc and
> exclude them if their location is not the file I am analyzing.
> However this solution doesn't really work.
> As an example if I call a function from cstdarg:
>

va_start(args, count);


> As the dump shows, the location of the CallExpr is in stdarg.h so my method
> excludes it, even if I would like to keep it since it appears in my source
> file
>

-CallExpr 0x6080720 </**/../lib/clang/3.5/include/stdarg.h:33:29, col:57>
'void'
 |-ImplicitCastExpr 0x6080708 <col:29> 'void (*)(__va_list_tag *, ...)'
<BuiltinFnToFnPtr>
 | `-DeclRefExpr 0x6080630 <col:29> '<builtin fn type>' Function 0x60804f0
'__builtin_va_start' 'void (__va_list_tag *, ...)'
 |-ImplicitCastExpr 0x6080758 <myfile.cpp:68:14> '__va_list_tag *'
<ArrayToPointerDecay>
 | `-DeclRefExpr 0x6080658 <col:14> 'va_list':'__va_list_tag [1]' lvalue
Var 0x607fe40 'args' 'va_list':'__va_list_tag [1]'
 `-DeclRefExpr 0x6080680 <col:20> 'int' lvalue ParmVar 0x607fc00 'count'
'int'


> Would you have a suggestion to avoid this problem or an other method that
> could work?
> Thank you
> Etienne
>
>
>
> --
> View this message in context:
> http://clang-developers.42468.n3.nabble.com/Ignore-the-content-from-the-included-files-with-RecursiveASTVisitor-tp4038480.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/20140317/afa2a29f/attachment.html>


More information about the cfe-dev mailing list