Issue 97759
Summary clangd gets confused by `-U...` in command line
Labels new issue
Assignees
Reporter jpalus
    For input file `test.c`:
```c
#include <stdio.h>

#ifndef MSG
#define MSG "hello world"
#endif

void hello() {
  printf(MSG);
}
```
and `compile_commands.json`:
```json
[
  {      
    "directory": "/tmp",      
    "command": "clang -UMSG -c -o test.o test.c'", 
    "file": "test.c",            
    "output": "test.o"            
  }      
]
```
clangd reports false positive:
```console
$ clangd --check=test.c
...
I[21:05:56.452] Indexing headers...
I[21:05:56.472] Building AST...
E[21:05:56.491] [undeclared_var_use] Line 8: use of undeclared identifier 'MSG'
I[21:05:56.491] Indexing AST...
I[21:05:56.492] Building inlay hints
I[21:05:56.492] Building semantic highlighting
I[21:05:56.492] Testing features at each token (may be slow in large files)
I[21:05:56.493] Found definition heuristically using nearby identifier MSG
I[21:05:56.493] Found definition heuristically using nearby identifier MSG
I[21:05:56.501] All checks completed, 1 errors
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to