clang - 符号(变量、函数、类型等)定义或声明或引用
请有人知道 clang 是否可以选择返回符号定义或声明(或引用)?
我的意思是:有一个名为 -code-completion-at=path_to_file:line:coloumn 的 clang 可执行文件选项 clang 将查看代码并返回完成字符串(即,如果有) std::string_type_variable。 ..它返回您可以从 std::string 调用的所有方法和属性。
现在我想要的是,让 clang 返回文件和坐标,其中符号的定义开始..所以如果它 std::string_type_variable - 我想返回我的坐标,我在其中写入了 std::string 变量;在代码中。
我想在 vim 中使用它而不是 cscope/ctags 过时的功能(在 vim 中使用 ctags/cscope 的标签系统不知道上下文 - 它在更大的项目中根本不可用) 我知道有 clang 后续(http://blog.wuwon.id.au/2011/10/vim-plugin-for-navigating-c-with.html),但它不能正常工作(实际上对我来说根本不起作用)
这可能吗?应该没那么难,如果它能返回完成,它可能已经知道,他从哪里读取变量的定义......
Please do anyone know if clang has option to return symbol definition or declaration(or reference)?
I mean: there is option for clang executable called -code-completion-at=path_to_file:line:coloumn
the clang will look into code and returns you completion strings(ie if there is for example
std::string_type_variable. ..it returns to you all the methods and attributes you can call from std::string.
Now what i want is, for clang to return the file and coordinates, where the definition of the symbols starts .. so if it std::string_type_variable - i want to return to me coordinates, where i have writte std::string variable; in the code.
I want to use it in vim instead of cscope/ctags obsolete functionality(tags system using ctags/cscope in vim doesnt know context - its not usable at all in bigger projects)
I know there is clang followup(http://blog.wuwon.id.au/2011/10/vim-plugin-for-navigating-c-with.html) but it doesnt work correctly(actually doesnt work for me at all)
Is it even possible? it shouldn't be that hard, if it can return the completion, it probably already knows, where from he read the definition of the variable...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Clang 通过 libclang 共享库提供了此类功能,但有一个简单的示例说明如何使用它。如果您从源代码构建 clang,请查看 c-index-test 可执行文件。它的源代码位于tools/c-index-test。
Clang provides such functionality by libclang shared library, but there is a simple example on how to use it. If you built clang from source, take a look at c-index-test executable. It's source located in tools/c-index-test.