[cfe-dev] Clang-based autocompletion speed

Maksym Taran via cfe-dev cfe-dev at lists.llvm.org
Thu Jan 7 13:34:10 PST 2016


Hello!

I'm looking into improving how an autocomplete system at Google
computes semantic
autocompletions for a given C++ file + line + column. Currently, it's
mostly just calling out to clang_codeCompleteAt
<https://github.com/llvm-mirror/clang/blob/52ed5ec631b0bbf5c714baa0cd83c33ebfe0c6aa/tools/libclang/CIndexCodeCompletion.cpp#L798>,
and that's where we've been seeing high latency.

A particular problem we're having is that when we try to autocomplete just
within some scope (that is, just inside a function body, rather than after
a . or -> etc), calling that method returns *all* possible autocompletion
results, which includes all constants and class names defined in all the
transitively included files as far as I can tell. This is technically
correct, but in practice takes on the order of seconds to return, which is
much longer than the desired timeframe for autocompletion results. So I'd
like to know if there's some way I can get a smaller set of autocompletions
more quickly, e.g. by asking clang to complete only on method names and
locals, or by giving a time limit to get results. I didn't see how I might
do that in the documentation
<http://clang.llvm.org/doxygen/group__CINDEX__CODE__COMPLET.html#ga50fedfa85d8d1517363952f2e10aa3bf>
so
I'm wondering if there are some other APIs I'm not seeing.

I took a look at YouCompleteMe <https://github.com/Valloric/YouCompleteMe>
and it's using the same API
<https://github.com/Valloric/ycmd/blob/master/cpp/ycm/ClangCompleter/TranslationUnit.cpp#L176>,
so I suspect it might have the same problem. If there's no way to do
something like this using the current API methods, I'd be interested to
know how possible/difficult would it be to implement additional methods or
options?

Thank you!
Maksym
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160107/826daad2/attachment.html>


More information about the cfe-dev mailing list