我可以从模板参数生成Clang AST匹配器吗?

时间:2016-11-23 17:57:43

标签: c++ clang abstract-syntax-tree

我正在尝试使用Clang AST匹配器根据名称和模板参数查找函数decls。

我的方法的签名应该看起来像这样:

getFunctionDecl<T>(std::string name) {
  // return the function with name "name" and signature T... 
}

因此,要查找int foo(),其使用情况为getFunctionDecl<int()>("foo")

我知道如何通过name获取功能:

 match functionDecl(hasName(name))

但我不知道匹配签名T的最佳方法是什么。

是否有像hasSignature这样的匹配器?

 match functionDecl(allOf(hasName(name), hasSignature<T>()))

我可以自己制作ParmVarDecl个物品,但我想尽可能避免重新发明轮子。由于奇怪的签名如const std::unique_ptr<const int*>&,这里也有相当多的复杂性,所以我更喜欢经过充分测试的解决方案。

0 个答案:

没有答案
相关问题