If you weren't aware of this (I wasn't until a couple days ago), there is actually a whole subfield of computer science dedicated to pattern matching. You may find some big inspiration by browsing the literature.
I mention this because I recently stumbled upon the existence of this subfield in the context of the Mathematica programming language, and this hasAncestor match is extremely similar to something that happens in the Mathematica programming language when an "upvalue" is matched, although upvalues are much more general. In Mathematica, for example, you can do: g /: g[x_] + g[y_] := gplus[x, y] which roughly means "whenever you see `g` as you traverse the expression tree, check if the expression tree structure surrounding it looks like g[<arbitrary expression to be bound to `x`>] + g[<arbitrary expression to be bound to `y`>], and if it does, then rewrite that subtree to be `gplus[x,y]`". The behavior needed to perform such matching efficiently seems to be highly relevant to hasAncestor. --Sean Silva http://llvm-reviews.chandlerc.com/D36 _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
