我使用libclang来解析源文件并引用某些类型CXType,比如它是" const std::__1::basic_string<char>"(如报告所述 clang_getTypeSpelling).如何获得相同类型的引用但没有const限定符?
小智 0
我可以通过访问类型的光标的子项来做到这一点。例如,给定 CXCursor '光标',
CXType type = clang_getCursorType(cursor);
if (clang_isConstQualifiedType(type))
{
auto RemoveConstFromType = [](CXCursor c, CXCursor, CXClientData d)
{
*(CXType*)d = clang_getCursorType(c);
return (clang_isConstQualifiedType(*(CXType*)d) ? CXChildVisit_Recurse : CXChildVisit_Break);
};
clang_visitChildren(cursor, RemoveConstFromType, &type);
}
Run Code Online (Sandbox Code Playgroud)
我希望这有帮助。=)
| 归档时间: |
|
| 查看次数: |
99 次 |
| 最近记录: |