[cfe-dev] AST matchers and thread safety
Vane, Edwin
edwin.vane at intel.com
Tue Sep 24 06:52:06 PDT 2013
Are you using a debug build of llvm/clang btw? Parsing is WAY slower in debug mode and if your translation unit you're matching on is very large you'll definitely see a difference between debug/release speeds.
> -----Original Message-----
> From: cfe-dev-bounces at cs.uiuc.edu [mailto:cfe-dev-bounces at cs.uiuc.edu] On
> Behalf Of Jesper Eskilson
> Sent: Tuesday, September 24, 2013 5:29 AM
> To: cfe-dev at cs.uiuc.edu
> Subject: Re: [cfe-dev] AST matchers and thread safety
>
> On 09/24/2013 10:41 AM, Gabor Kozar wrote:
> > Hi,
> > Since the AST should be immutable once created, and AST matchers are
> > only a high-level wrapper for RecursiveASTVisitor, so I'd expect no
> > problems with multithreading. This definitely needs to be confirmed
> > though by someone who actually knows what they are talking about. :)
> > Just out of curiosity, what is your use case? Navigating the AST is
> > fast, especially compared to the cost of building the AST. Are you
> > running a huge number of matchers?
>
> I have a legacy C++ code base which I'm trying to extract useful information out
> of. For example, a single matcher which matches all method definitions of a
> particular class takes around 8 seconds on my machine, varying a little with the
> complexity of the matcher.
>
> Is the AST kept around for the lifetime of the "ClangTool" object, or is it
> recreated each time the "run" method is invoked? Some of my matchers depend
> on information gathered by other matchers (one matcher gathers method
> definitions so they can be consumed by when matching the corresponding class
> declarations). For example:
>
> MatchCallback cb1, cb2;
> MatchFinder finder1
>
> finder1.addMatcher(m1, &cb1);
> finder1.addMatcher(m2, &cb2);
>
> tool->run(newFrontendActionFactory(&finder1));
>
> MatchCallback cb3, cb4;
> MatchFinder finder2
>
> finder2.addMatcher(m3, &cb3);
> finder2.addMatcher(m4, &cb4);
>
> tool->run(newFrontendActionFactory(&finder2));
>
> Will this build the AST twice or just once? Is there any guarantee concerning the
> order in which the matcher callbacks are invoked?
>
> > --
> > Gábor Kozár -- ShdNx
> > kozargabor at gmail.com
> > On Tue, Sep 24, 2013, at 10:15, Jesper Eskilson wrote:
> >> Hi,
> >> Are the AST matchers thread safe? I have a bunch of matchers which I
> >> would like to run in separate threads for performance reasons. Is
> >> that expected to work, or am I overly optimistic?
> >> /Jesper
> >> --
> >> *Jesper Eskilson* /Development Engineer/ IAR Systems AB Box 23051,
> >> Strandbodgatan 1
> >> SE-750 23 Uppsala, SWEDEN
> >> E-mail: jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.com>
> >> <mailto:jesper.eskilson at iar.com>
> >> Website: www.iar.com
> >> <http://www.iar.com> Twitter: www.twitter.com/iarsystems
> >> <http://www.twitter.com/iarsystems>
> >> _________________________________________________
> >> cfe-dev mailing list
> >> cfe-dev at cs.uiuc.edu <mailto:cfe-dev at cs.uiuc.edu>
> >> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
> --
> *Jesper Eskilson* /Development Engineer/ IAR Systems AB Box 23051,
> Strandbodgatan 1
> SE-750 23 Uppsala, SWEDEN
> E-mail: jesper.eskilson at iar.com <mailto:jesper.eskilson at iar.com>
> Website: www.iar.com
> <http://www.iar.com> Twitter: www.twitter.com/iarsystems
> <http://www.twitter.com/iarsystems>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list