我正在为 clang 静态分析器开发一个自定义检查器,用于检查 CPython API 的不正确使用。我取得了一些进展,但我被卡住了:我怎样才能得到一个给定类型名称的 clang::QualType
值?
例如,我想写这样的东西:
QualType ty = findTheTypeNamed("Py_ssize_t");
我花时间查看了 clang::ASTContext
和 clang::QualType
的代码,但我迷路了。
如何从类型名称中获取 clang::QualType
?
最佳答案
asString
narrowing matcher将一个字符串变成一个 qualtype。
这是相关的文档:
Matches if the matched type is represented by the given string.
Given
class Y { public: void x(); };
void z() { Y* y; y->x(); }
cxxMemberCallExpr(on(hasType(asString("class Y *"))))
matches y->x()
关于c++ - 如何从字符串中获取 clang::QualType?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39585653/