[clang] [clang-format] Limit how much work guessLanguage() can do (PR #78925)
Nathan Ridge via cfe-commits
cfe-commits at lists.llvm.org
Sun Jan 21 19:05:19 PST 2024
HighCommander4 wrote:
A few additional notes:
* I chose the value `1 << 20` for `MaxLinesToProcess` empirically to get `guessLanguage()` to return in about 1 second on my (average-for-a-developer-machine) hardware. I don't feel strongly about the value and I'm happy to go with a different one.
* The reason I didn't try to impose the limit on all uses of `UnwrappedLineParser` is that I wasn't sure what the impact would be on the results of trying to format an affected file. As such, trying to format such a file still hangs / OOMs, but that's still an issue that fewer people will run into than the `guessLanguage()` hang which occurs any time such a file is even opened in clangd. As such, I think the patch in its currently form still has a lot of value.
https://github.com/llvm/llvm-project/pull/78925
More information about the cfe-commits
mailing list