ncm2 / ncm2-pyclang

Cached, fast C/C++ completion for ncm2
MIT License
45 stars 1 forks source link

[TODO] include file completion #5

Closed roxma closed 6 years ago

roxma commented 6 years ago

Just found that -### should be useful for this purpose:

clang -### -c hello.c

clang version 5.0.1-2~bpo9+1 (tags/RELEASE_501/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/roxma/.local/bin
 "/usr/lib/llvm-5.0/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "hello.c" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-coverage-notes-file" "/home/roxma/work/ncm2-ws/llvm/tools/clang/hello.gcno" "-resource-dir" "/usr/lib/llvm-5.0/lib/clang/5.0.1" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/llvm-5.0/lib/clang/5.0.1/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdebug-compilation-dir" "/home/roxma/work/ncm2-ws/llvm/tools/clang" "-ferror-limit" "19" "-fmessage-length" "0" "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-o" "hello.o" "-x" "c" "hello.c"

roxma-pc clang $ clang -### -c hello.cpp -I ./
clang version 5.0.1-2~bpo9+1 (tags/RELEASE_501/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/roxma/.local/bin
 "/usr/lib/llvm-5.0/bin/clang" "-cc1" "-triple" "x86_64-pc-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free" "-disable-llvm-verifier" "-discard-value-names" "-main-file-name" "hello.cpp" "-mrelocation-model" "static" "-mthread-model" "posix" "-mdisable-fp-elim" "-fmath-errno" "-masm-verbose" "-mconstructor-aliases" "-munwind-tables" "-fuse-init-array" "-target-cpu" "x86-64" "-dwarf-column-info" "-debugger-tuning=gdb" "-coverage-notes-file" "/home/roxma/work/ncm2-ws/llvm/tools/clang/hello.gcno" "-resource-dir" "/usr/lib/llvm-5.0/lib/clang/5.0.1" "-I" "./" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/x86_64-linux-gnu/c++/6.3.0" "-internal-isystem" "/usr/lib/gcc/x86_64-linux-gnu/6.3.0/../../../../include/c++/6.3.0/backward" "-internal-isystem" "/usr/include/clang/5.0.1/include/" "-internal-isystem" "/usr/local/include" "-internal-isystem" "/usr/lib/llvm-5.0/lib/clang/5.0.1/include" "-internal-externc-isystem" "/usr/include/x86_64-linux-gnu" "-internal-externc-isystem" "/include" "-internal-externc-isystem" "/usr/include" "-fdeprecated-macro" "-fdebug-compilation-dir" "/home/roxma/work/ncm2-ws/llvm/tools/clang" "-ferror-limit" "19" "-fmessage-length" "94" "-fobjc-runtime=gcc" "-fcxx-exceptions" "-fexceptions" "-fdiagnostics-show-option" "-fcolor-diagnostics" "-o" "hello.o" "-x" "c++" "hello.cpp"
roxma commented 6 years ago

After some research, I notice that libclang c interface has very limited functionalities.

I also notice that clang -code-completion-at is more robust than libclang based completion.

I don't know why it behaves like this.

Need more time to dig into clang.

If we need more powerful control over the clang dev library, we're gonna need C++ too, whilch will make the plugin setup more complicated.