max-winkler wrote:

The crash can be reproduced by `clangd --check=test.c` for the file

```
#if( FOO
&& BAR)
#endif
```
The crash occurs only in clangd, because its preamble scan sets 
`PreprocessorOptions::SingleFileParseMode`. Without it (e.g. in plain clang) 
the code path is not reached.

The behavior can be generalized to any directive that contains an undefined 
identifier and ends with an unfinished subexpression (e.g. due to unclosed 
parenthesis). This triggers an assertion in `DiscardUntilEndOfDirective(...)`. 
Note also that all other callers of that function do this in case of 
`Tok.isNot(tok::eod)` only.

Since `SingleFileParseMode` cannot be set from the command line, a lit test is 
not possible. The fix is therefore covered by two unit tests in LexerTest.cpp.

https://github.com/llvm/llvm-project/pull/234992
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to