Consider the file foo.c
:
#include <stdbool.h>
int six, bo;
int main(void) {
return six + b + sizeof(int);
}
Then clang
can be used to suggest possible code completions in line 15 column 19 (portion after the b
in the return
statement) as follows:
cat foo.c | clang -fsyntax-only -Xclang -code-completion-macros -Xclang -code-completion-at=-:5:19 -xc -
This gives
PREFERRED-TYPE: int
COMPLETION: bo : [#int#]bo
COMPLETION: bool : bool
Obviously the only right match would be bo
as an expression is expected.
Does clang
provide options so that completions that do not lead to an expression are automatically filtered out? Or needs this done manually?
Also, I could not really find any sources that document options for clang
like -code-completion-macros
or -code-completion-at
. The command above which uses these option is used in the vim-clang plugin. Are these documented somewhere (in hope there are further options).