[cfe-dev] clangd, completion in header files

Fāng-ruì Sòng via cfe-dev cfe-dev at lists.llvm.org
Wed Mar 28 12:58:31 PDT 2018


Another heuristic solution:

Enumerate all compilation database entries and calculate the matching score
for each entry with the target file
Bonus for common leading components
Penalty for diverged path components
Bonus for common trailing characters sans filename extension (e.g. Match.cc
Match.h are the same sans extension)

This heuristic is used in cquery.

Add another point for textDocument/didOpen on an unseen filename:
The inferred command line options are not authoritative, they should be
overriden by other translation units when later it turns out the header
file is included by some entry in the compilation database.


On Wed, Mar 28, 2018 at 7:12 AM Christian Dullweber via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> Hi,
>
> I recently tried to use clangd for Chromium in vscode and hit the same
> issue.
> I experimented a bit with generating a compile_commands.json file with
> valid rules for headers and came to this solution:
> https://gist.github.com/xchrdw/bfd2b3a5f765f4195a55d6351daf1b48
> I sorted all .cc filenames and then looked up the index of the closest
> match for each header using binary search. As there were some edge cases
> like the first or last file in a directory, I additionally compared which
> file at the index has the largest prefix with the header.
> I found a few issues with system headers and some generated protobuf
> headers but otherwise it works well.
> Native support from clangd would be amazing :)
>
> Thanks,
> Christian
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>


-- 
宋方睿
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180328/dd5a3eca/attachment.html>


More information about the cfe-dev mailing list