| Issue |
208044
|
| Summary |
[clang][clangd] Clang hangs using `code-completion` related to macro
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
hongtaihu
|
https://godbolt.org/z/eqeh79KGa
```c
#define VALUE 1
#define F(x, y) ((x) + (y))
int sink = F(VALUE, ::i1);
```
and
```
-x c -std=c23 -fsyntax-only -Xclang -code-completion-at=example.c:2:28
```
clang hangs:
```
clang: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument]
Killed - processing time exceeded
Program terminated with signal: SIGKILL
Compiler returned: 143
```
## Local profiling
Locally, the same reproducer keeps one CPU core busy until killed. An 8 second perf sample shows nearly all time spent
in parser lookahead / type annotation:
```
30.21% clang::Preprocessor::LookAhead(unsigned int)
29.84% clang::Parser::TryAnnotateTypeOrScopeToken(...)
24.27% clang::Parser::TryAnnotateTypeOrScopeTokenAfterScopeSpec(...)
15.68% clang::Parser::isTypeSpecifierQualifier(clang::Token const&)
```
GDB sampling repeatedly interrupts in the same path:
```
#0 clang::Preprocessor::LookAhead(unsigned int)
#1 clang::Parser::isTypeSpecifierQualifier(clang::Token const&)
#2 clang::Parser::ParseParenExpression(...)
#3 clang::Parser::ParseCastExpression(...)
#4 clang::Parser::ParseCastExpression(...)
#5 clang::Parser::ParseRHSOfBinaryExpression(...)
#6 clang::Parser::ParseExpression(...)
#7 clang::Parser::ParseParenExpression(...)
#8 clang::Parser::ParseCastExpression(...)
#9 clang::Parser::ParseCastExpression(...)
#10 clang::Parser::ParseAssignmentExpression(...)
#11 clang::Parser::ParseInitializer(clang::Decl*)
```
Not sure whether related to https://github.com/llvm/llvm-project/issues/58482
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs