clangd icon indicating copy to clipboard operation
clangd copied to clipboard

"too many errors emitted" as the only error

Open jendrikw opened this issue 1 year ago • 3 comments

Image

I know it's not minimal, but you can reproduce by cloning https://github.com/jendrikw/pokeemerald, checking out the clangd branch and opening include/metatile_behaviour.h in vscode.

Logs

https://gist.github.com/jendrikw/763e4cc9f1a1c88af4438dba4bb5a4c2

System information

Output of clangd --version: clangd version 19.1.7 Features: linux Platform: x86_64-pc-linux-gnu

Editor/LSP plugin: llvm-vs-code-extensions.vscode-clangd

Operating system: arch linux

jendrikw avatar Apr 15 '25 13:04 jendrikw

you can reproduce by cloning https://github.com/jendrikw/pokeemerald, checking out the clangd branch and opening include/metatile_behaviour.h in vscode.

You didn't mention anything about generating a compile_commands.json file.

Please have a look at https://clangd.llvm.org/installation#project-setup.

HighCommander4 avatar Apr 17 '25 06:04 HighCommander4

I can't use a compile_commands.json because the project is compiled with a custom compiler that bear doesn't recognize. The compiler also has no -E option, so I can't use query driver either, so I'm using a .clangd with compiler flags.

jendrikw avatar Apr 17 '25 08:04 jendrikw

Thanks for the added context.

Note that if a project's code cannot be compiled with clang, clangd may not work well either, since clangd uses the clang frontend to analyze the code. I guess it depends on how portable the project's code is.

In such a scenario, if clangd gives you diagnostics that you don't get when compiling there could be a few reasons:

  • The flags provided in .clangd are different from what the compiler is getting (or their equivalents)
  • The compiler may do some things implicitly (e.g. pre-define a macro) that needs to be done explicitly for clangd
  • The compiler may just support a code pattern that clang's frontend does not

As someone familiar with the custom compiler in question, you're probably in a better position to investigate such diagnostics than I am, though I'm happy to try and help.

For what it's worth, I checked out the clangd branch of the repository, built it, and opened the file you mentioned (include/metatile_behavior.h), and I did not get any diagnostics in this file.

HighCommander4 avatar Apr 18 '25 06:04 HighCommander4