ccls
ccls copied to clipboard
Go to definition not working properly with cross-file redefined macros
Observed behavior
-
.ccls
:
clang
-
test.cc
:
#include "other.h"
#undef LOG
#define LOG(args) fprintf(stderr, args)
int main()
{
LOG("Log\n");
return 0;
}
-
other.h
#include <stdio.h>
#define LOG(args) fprintf(stdout, "Other: " args);
Expected behavior
When using LSP "go to definition" on the LOG
macro use inside the main()
function I would expect my cursor to jump to the definition in test.cc
. Otherwise my client either lists every definition, or worse, jumps to the first one it wants.
This is not right as there is clearly no doubt about which macro is being in use from the compiler point of view.
Note: Maybe similar to https://github.com/MaskRay/ccls/issues/885
Steps to reproduce
- Create a new project with the provided files above
- Use your LSP client and try "go to definition" on the LOG
System information
- ccls version:
Debian ccls version 0.20210330-12-g74458915
clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63
- OS: Debian
- Editor: Neovim NVIM v0.7.2
- Language client (and version): neovim-lspconfig