LLVM. How to access to struct fields based on their names?

时间秒杀一切 提交于 2019-11-30 10:00:53

You cannot access the fields of the struct by name, only by index. This information is just normally not there when you compile with Clang.

There is one exception to this, and this is if you compiled with debug information. In that case, you'll have ample data about the type; specifically, you'll get the order of the fields, along with a metadata entry for each field which contains its name (and other useful stuff, such as its offset from the beginning of the type).

Read more about this on the Source Level Debugging guide - and particularly, see this section about struct encoding, with its very nice example.

Take a look at DebugInfo.h for classes to help on querying debug info, though I think you're going to have to do some manually digging anyway.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!