HighCommander4 wrote:

> The OOM is not limited to `guessLanguage()`. [...]  It occurs even if you 
> rename the header files to .cpp files and clang-format the renamed files 
> directly.

I'm aware of that.

However, for clangd users, a crucial difference between `guessLanguage()` vs. 
other code in libFormat that uses `UnwrappedLineParser`, is that 
`guessLanguage()` gets called as soon as a file is opened in the editor, while 
the other code is only called if the user explicitly tries to format the file.

For the files affected by this OOM (single-file libraries like 
[miniaudio](https://github.com/mackron/miniaudio/blob/master/miniaudio.h), 
[mathlink](https://github.com/clangd/clangd/issues/1384), 
[minilzo](http://www.oberhumer.com/opensource/lzo/#minilzo), 
[blis](https://github.com/llvm/llvm-project/issues/60151), where the large 
number of configuration-related preprocessor branches and the large number of 
lines in the file conspire to make the combined length of all permutations 
intractable to work with), the number of users who merely use these libraries 
(and so may open them in the editor to look at the header, but will not try to 
format it) far exceeds the number of users who actually develop these libraries 
(who would edit and format the header). Thus, by avoiding the problem in 
`guessLanguage()`, we would resolve the issue for >99% of clangd users that run 
into it, which would be a significant improvement.

> (See 
> [119a728](https://github.com/llvm/llvm-project/commit/119a72866f0e143127355fe6e03f57c4f8bab1ae)
>  for an improvement to the performance of `guessLanguage()`.)

Thanks for this improvement. However, it does not meaningfully help avoid the 
OOM for the above libaries (the OOM happens while we're still in 
[`UnwrappedLineParser::parse()`](https://github.com/llvm/llvm-project/blob/04fbc461e0fd1c6f2b014761e9c03ca80d17b33b/clang/lib/Format/TokenAnalyzer.cpp#L113)).

https://github.com/llvm/llvm-project/pull/78925
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to