[PATCH] D39050: Add index-while-building support to Clang

Argyrios Kyrtzidis via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 10:50:10 PST 2017


akyrtzi added a comment.

@malaperle, to clarify we are not suggesting that you write your own parser, the suggestion is to use clang in 'fast-scan' mode to get the structure of the declarations of a single file, see `CXTranslationUnit_SingleFileParse` (along with enabling skipping of bodies). We have found clang is super fast when you only try to get the structure of a file like this. We can make convenient APIs to provide the syntactic structure of declarations based on their location.

But let's say we added the end-loc, is it enough ? If you want to implement the 'peek the definition' like Eclipse, then it is not enough, you also need to figure out if there are documentation comments associated with the declaration and also show those. Also what if you want to highlight the type signature of a function, then just storing the location of the closing brace of its body is not enough. There can be any arbitrary things you may want to get from the structure of the declaration (e.g. the parameter ranges), but we could provide an API to gather any syntactic structure info you may want.

I would encourage you to try `CXTranslationUnit_SingleFileParse|CXTranslationUnit_SkipFunctionBodies`, you will be pleasantly surprised with how fast this mode is. The `c-index-test` option is `-single-file-parse`.


https://reviews.llvm.org/D39050





More information about the cfe-commits mailing list