[cfe-dev] Extra parameters to Traverse* functions in ASTVisitor

mats petersson mats at planetcatfish.com
Mon Apr 27 02:03:13 PDT 2015


I've not worked directly with RecurisiveASTVisitor, but in my own compiler,
I have my own ASTVisitor class, and the way I pass "extra information" is
to add it to the class that is doing the visiting. In the
RecursiveASTVisitor, that would mean adding it to the `Derived` class that
is the template parameter. You then call `getDerived()` to get the derived
class and dig out your extra argument that way. Would that work for your
case?

--
Mats

On 27 April 2015 at 07:04, Saswat Padhi <padhi at cs.ucla.edu> wrote:

> Hello everyone,
>
> I am new to Clang and am trying to build a Static Checker for one of my
> projects. I am currently using a RecursiveASTVisitor to walk through the
> AST. But I also need to pass some state to the Traverse* functions, while
> walking through the AST. For example, when I call TraverseStmt recursively,
> I need to pass some extra arguments, but the Traverse* functions only
> accept single arguments. Is there any way I could achieve this?
>
> I can keep a local stack within the ASTVisitor, but I was wondering if
> there would be a cleaner way to do it.
>
> Thanks,
> Saswat
> _______________________________________________
> 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/20150427/5511d5e4/attachment.html>


More information about the cfe-dev mailing list