[cfe-dev] Expression Templates for AST matchers

Richard legalize at xmission.com
Tue Apr 7 14:01:39 PDT 2015


OCLint, a lint checker using clang tooling, says:
<http://docs.oclint.org/en/dev/internals/rules.html>

    "Using AST matchers has more restrictions than AST visitor, and it
    takes much longer time in analysis, this could lower the
    performance of the tool. So, we always have to consider the
    trade-off, and choose wisely."

It seems that AST matchers, while convenient, are not the best
performing option for processing source files.  I've done some simplistic
measurements on clang-tidy and found that the majority of the execution
time is spent in the matchers.  I believe this is the result of the
matchers building runtime structures to match nodes.

Has anyone investigated using the technique of expression templates to
get the convenience of an AST matching domain-specific language (DSL)
with the runtime efficiency of an AST visitor?

If we were to pursue such a direction, would it be possible to use an
expression template library like those in Boost for the implementation?
I don't see any existing use of Boost in the LLVM/clang code base, so
I infer that there is some avoidance of Boost for whatever reason.  I
haven't done any expression template coding beyond using existing
expression template based libraries like Boost.Spirit.  I have no idea
what it would take to create an expression template based AST matcher
DSL for clang, but it seems like it would be worthwhile as it would
speed up all the tools that want to use the AST matcher style
interface.

Does anyone have any thoughts about this?  Pehraps Manuel Klimek?
-- 
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
     The Computer Graphics Museum <http://ComputerGraphicsMuseum.org>
         The Terminals Wiki <http://terminals.classiccmp.org>
  Legalize Adulthood! (my blog) <http://LegalizeAdulthood.wordpress.com>



More information about the cfe-dev mailing list