[clang] [clang-format] Limit how much work guessLanguage() can do (PR #78925)

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 22 22:14:53 PST 2024


owenca wrote:

> > If we add a `bool GuessObjC` parameter to `guessLanguage()`, would that solve the problem?
> 
> I assume you mean making it so that when clangd calls into `guessLanguage()`, the ObjC guessing algorithm is skipped entirely.

I'm not familiar with clangd use cases, but I thought the `GuessObjC` flag would allow clangd to skip the guessing ObjC part for those "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)". If it wouldn't work as you pointed out, then we probably need a new ObjC guesser that only relies on the lexer, similar to what's done in [IntegerLiteralSeparatorFixer::process()](https://github.com/llvm/llvm-project/blob/afd469023aad10786eaea3d444047a558ad8d5c1/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp#L45).

https://github.com/llvm/llvm-project/pull/78925


More information about the cfe-commits mailing list