clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
639 stars 113 forks source link

clangd doesn't find include paths #717

Open thewh1teagle opened 1 week ago

thewh1teagle commented 1 week ago

Clang doesn't format the files and throw errors that it failed to find imports from external libraries (I use cmake)

#include "sherpa-onnx/c-api/c-api.h"
'sherpa-onnx/c-api/c-api.h' file not foundclang(pp_file_not_found)

the headers available in build/_deps/sherpa-src/include.

The project compiles successfuly with cmake. I also tried to produce compile_commands.json and place it in root folder. it didn't helped.

https://github.com/thewh1teagle/loud.cpp

Also clangd says there's too many errors and it doesn't do anything except for showing the error. no formatting etc.

Logs Please attach the clangd log from the "Output" window if you can. If possible, run with --log=verbose - note that the logs will include the contents of open files!

```console I[16:27:21.492] <-- shutdown(46) I[16:27:21.492] --> reply:shutdown(46) 0 ms I[16:27:21.492] <-- exit I[16:27:21.492] LSP finished, exiting with status 0 I[16:27:21.580] Homebrew clangd version 18.1.8 I[16:27:21.582] Features: mac+xpc I[16:27:21.582] PID: 73143 I[16:27:21.582] Working directory: /Volumes/Internal/loud.cpp I[16:27:21.582] argv[0]: /opt/homebrew/opt/llvm/bin/clangd I[16:27:21.582] argv[1]: --compile-commands-dir=/Volumes/Internal/loud.cpp/build I[16:27:21.582] argv[2]: --completion-style=detailed I[16:27:21.582] argv[3]: --header-insertion=never I[16:27:21.582] Starting LSP over stdin/stdout I[16:27:21.583] <-- initialize(0) I[16:27:21.594] --> reply:initialize(0) 11 ms I[16:27:21.594] <-- initialized I[16:27:21.597] <-- textDocument/didOpen I[16:27:21.599] <-- textDocument/didOpen I[16:27:21.599] <-- textDocument/didOpen I[16:27:21.600] <-- textDocument/didOpen I[16:27:21.601] Loaded compilation database from /Volumes/Internal/loud.cpp/build/compile_commands.json I[16:27:21.602] --> window/workDoneProgress/create(0) I[16:27:21.602] Enqueueing 11 commands for indexing I[16:27:21.602] <-- reply(0) I[16:27:21.602] ASTWorker building file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector version 1 with command inferred from /Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/ggml-aarch64.c [/Volumes/Internal/loud.cpp/build/_deps/whisper-build/ggml/src] /usr/bin/clang -DACCELERATE_LAPACK_ILP64 -DACCELERATE_NEW_LAPACK -DGGML_METAL_EMBED_LIBRARY -DGGML_SCHED_MAX_COPIES=4 -DGGML_USE_ACCELERATE -DGGML_USE_BLAS -DGGML_USE_METAL -DGGML_USE_OPENMP -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE=600 -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/../include -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/. -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/libomp/include -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -Xclang -fopenmp -c -x c-header -std=gnu11 -resource-dir=/opt/homebrew/Cellar/llvm/18.1.8/lib/clang/18 -- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector I[16:27:21.602] --> $/progress I[16:27:21.602] ASTWorker building file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iostream version 1 with command inferred from /Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/ggml-aarch64.c [/Volumes/Internal/loud.cpp/build/_deps/whisper-build/ggml/src] /usr/bin/clang -DACCELERATE_LAPACK_ILP64 -DACCELERATE_NEW_LAPACK -DGGML_METAL_EMBED_LIBRARY -DGGML_SCHED_MAX_COPIES=4 -DGGML_USE_ACCELERATE -DGGML_USE_BLAS -DGGML_USE_METAL -DGGML_USE_OPENMP -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE=600 -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/../include -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/. -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/libomp/include -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -Xclang -fopenmp -c -x c-header -std=gnu11 -resource-dir=/opt/homebrew/Cellar/llvm/18.1.8/lib/clang/18 -- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iostream I[16:27:21.602] --> $/progress I[16:27:21.602] ASTWorker building file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdio.h version 1 with command inferred from /Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/ggml-aarch64.c [/Volumes/Internal/loud.cpp/build/_deps/whisper-build/ggml/src] /usr/bin/clang -DACCELERATE_LAPACK_ILP64 -DACCELERATE_NEW_LAPACK -DGGML_METAL_EMBED_LIBRARY -DGGML_SCHED_MAX_COPIES=4 -DGGML_USE_ACCELERATE -DGGML_USE_BLAS -DGGML_USE_METAL -DGGML_USE_OPENMP -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE=600 -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/../include -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/. -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/libomp/include -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -Werror=implicit-int -Werror=implicit-function-declaration -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wunreachable-code-break -Wunreachable-code-return -Wdouble-promotion -Xclang -fopenmp -c -x c-header -std=gnu11 -resource-dir=/opt/homebrew/Cellar/llvm/18.1.8/lib/clang/18 -- /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdio.h I[16:27:21.602] ASTWorker building file /Volumes/Internal/loud.cpp/src/main.cpp version 33 with command inferred from /Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/ggml-backend.cpp [/Volumes/Internal/loud.cpp/build/_deps/whisper-build/ggml/src] /usr/bin/clang++ --driver-mode=g++ -DACCELERATE_LAPACK_ILP64 -DACCELERATE_NEW_LAPACK -DGGML_METAL_EMBED_LIBRARY -DGGML_SCHED_MAX_COPIES=4 -DGGML_USE_ACCELERATE -DGGML_USE_BLAS -DGGML_USE_METAL -DGGML_USE_OPENMP -D_DARWIN_C_SOURCE -D_XOPEN_SOURCE=600 -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/../include -I/Volumes/Internal/loud.cpp/build/_deps/whisper-src/ggml/src/. -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/System/Library/Frameworks -isystem /opt/homebrew/opt/libomp/include -g -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Wmissing-declarations -Wmissing-noreturn -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi -Xclang -fopenmp -c -std=gnu++11 -resource-dir=/opt/homebrew/Cellar/llvm/18.1.8/lib/clang/18 -- /Volumes/Internal/loud.cpp/src/main.cpp I[16:27:21.603] --> textDocument/clangd.fileStatus I[16:27:21.603] --> textDocument/clangd.fileStatus I[16:27:21.603] --> textDocument/clangd.fileStatus I[16:27:21.604] --> textDocument/clangd.fileStatus I[16:27:21.614] <-- textDocument/documentSymbol(1) I[16:27:21.614] <-- textDocument/codeAction(2) I[16:27:21.644] <-- textDocument/documentLink(3) I[16:27:21.644] <-- textDocument/inlayHint(4) I[16:27:21.690] Built preamble of size 1030776 for file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdio.h version 1 in 0.09 seconds I[16:27:21.690] --> workspace/semanticTokens/refresh(1) I[16:27:21.690] Indexing c17 standard library in the context of /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/stdio.h I[16:27:21.692] <-- reply(1) I[16:27:21.692] <-- textDocument/semanticTokens/full(5) I[16:27:21.704] --> textDocument/publishDiagnostics I[16:27:21.704] --> textDocument/inactiveRegions I[16:27:21.704] --> textDocument/clangd.fileStatus I[16:27:21.748] Built preamble of size 1367316 for file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/vector version 1 in 0.14 seconds I[16:27:21.748] --> workspace/semanticTokens/refresh(2) I[16:27:21.749] <-- reply(2) I[16:27:21.764] Indexed c17 standard library: 3636 symbols, 38 filtered I[16:27:21.811] <-- textDocument/foldingRange(6) I[16:27:21.812] --> reply:textDocument/foldingRange(6) 0 ms I[16:27:21.873] Built preamble of size 1995712 for file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/iostream version 1 in 0.27 seconds I[16:27:21.873] --> workspace/semanticTokens/refresh(3) I[16:27:21.877] <-- reply(3) I[16:27:21.905] --> textDocument/publishDiagnostics I[16:27:21.905] --> textDocument/publishDiagnostics I[16:27:21.906] --> textDocument/inactiveRegions I[16:27:21.906] --> textDocument/clangd.fileStatus I[16:27:21.908] --> textDocument/inactiveRegions I[16:27:21.908] --> textDocument/clangd.fileStatus I[16:27:21.911] <-- textDocument/documentSymbol(7) I[16:27:22.046] Built preamble of size 6797848 for file /Volumes/Internal/loud.cpp/src/main.cpp version 33 in 0.44 seconds I[16:27:22.047] --> workspace/semanticTokens/refresh(4) I[16:27:22.047] Indexing c++11 standard library in the context of /Volumes/Internal/loud.cpp/src/main.cpp I[16:27:22.047] <-- reply(4) E[16:27:22.113] IncludeCleaner: Failed to get an entry for resolved path : No such file or directory E[16:27:22.113] IncludeCleaner: Failed to get an entry for resolved path : No such file or directory E[16:27:22.113] IncludeCleaner: Failed to get an entry for resolved path : No such file or directory I[16:27:22.114] --> textDocument/publishDiagnostics I[16:27:22.114] --> textDocument/inactiveRegions I[16:27:22.115] --> reply:textDocument/documentSymbol(1) 501 ms I[16:27:22.115] --> reply:textDocument/codeAction(2) 501 ms I[16:27:22.115] --> reply:textDocument/documentLink(3) 470 ms I[16:27:22.115] --> reply:textDocument/inlayHint(4) 470 ms I[16:27:22.115] --> reply:textDocument/semanticTokens/full(5) 422 ms I[16:27:22.115] --> reply:textDocument/documentSymbol(7) 204 ms I[16:27:22.115] --> textDocument/clangd.fileStatus I[16:27:22.374] <-- textDocument/codeAction(8) I[16:27:22.375] --> reply:textDocument/codeAction(8) 0 ms I[16:27:22.375] --> textDocument/clangd.fileStatus I[16:27:22.506] --> $/progress I[16:27:22.506] --> $/progress I[16:27:22.558] <-- textDocument/semanticTokens/full/delta(9) I[16:27:22.558] --> reply:textDocument/semanticTokens/full/delta(9) 0 ms I[16:27:22.558] --> textDocument/clangd.fileStatus I[16:27:22.790] Indexed c++11 standard library: 9460 symbols, 2322 filtered ```

System information Clangd version (from the log, or clangd --version):

Apple clangd version 15.0.0 (clang-1500.3.9.4)
Features: mac+xpc
Platform: x86_64-apple-darwin23.5.0; target=arm64-apple-darwin23.5.0

clangd extension version: v0.1.29 Operating system: macos

JVApen commented 1 week ago

This bug actually belongs on clangd/clangd Regardless, do you have the entry of the compile_commands.json for that file?

HighCommander4 commented 6 days ago

Also, could you attach logs taken with --log=verbose please?