bkramer is right. However, the distance is not even used to *create* the dynamic matchers. It is only used for the completion used by clang-query. So a cheap and simple isBaseOf() should do it. The distance could be separate. http://reviews.llvm.org/D5577