MaskRay / ccls

C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting
Apache License 2.0
3.73k stars 254 forks source link

Go to definition not working properly with cross-file redefined macros #894

Open xarkes opened 2 years ago

xarkes commented 2 years ago

Observed behavior

undef LOG

define LOG(args) fprintf(stderr, args)

int main() { LOG("Log\n"); return 0; }

* `other.h`
```cpp
#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

  1. Create a new project with the provided files above
  2. Use your LSP client and try "go to definition" on the LOG

System information