3

To investigate new files I'm used to run ctags with the appropriate options, the problem is that apparently this program doesn't support C++11 and I was just using it fine until I discovered that the development of this program ended years ago .

Now I need an equivalent tool for C++11 and beyond, and I remember that clang alone is able to output the AST of any given file so I was wondering if the fronted had similar functionalities that were comparable to what I used to do with ctags .

For example this are the entities that you can easily list with ctags in C++ mode

ctags --list-kinds=c++
c  classes
d  macro definitions
e  enumerators (values inside an enumeration)
f  function definitions
g  enumeration names
l  local variables [off]
m  class, struct, and union members
n  namespaces
p  function prototypes [off]
s  structure names
t  typedefs
u  union names
v  variable definitions
x  external and forward variable declarations [off]

Does clang is able to perform a similar task ?

4

2 回答 2

6

看看rtags工具。它使用 clang 重新编译您的整个项目。之后,您可以使用它来浏览源。唯一的问题是 AST 是在预处理器运行后构建的,因此被宏禁用的代码不可用于导航。

这些项目维护一组 elisp 绑定,允许您RTags从 emacs 进行控制。要在 vim 中集成,请参阅lyutsShane Harper的第三方项目。

于 2014-11-17T14:53:59.473 回答
0

llvm/clang 项目不包含从 ast 生成标记文件的工具。但是,github上有几个项目使用clang来执行此操作,可以通过以下方式找到:https ://github.com/search?utf8=%E2%9C%93&q=clang+tags

以下两个项目得到了一些关注(星星、问题、拉取请求)

不幸的是,最近没有提交,但是,作者仍然对提出的问题做出回应。

免责声明我知道不鼓励仅链接的答案。当我有时间测试项目并查看它们与Exuberant-ctagsUniversal-ctags的比较时,我将扩展这个问题。

于 2016-11-02T09:14:29.330 回答