[PATCH] D95538: [clang][Format] Evaluate FallbackStyle only if needed

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 27 22:39:21 PST 2021


kadircet added a comment.

Sure adding tests, sorry for leaving them out the first time.

To give more insights, `format::getStyle()` tries to figure out `FallbackStyle` at the beginning of the function, and errors out if it can't. But in most cases `FallbackStyle` is not needed, e.g. there's already a `.clang-format` file in parent directories and `StyleName` is `"file"`, or `StyleName` is a predefined/custom one.
This patch changes `getStyle()`s behaviour to succeed in such cases, even with an invalid `FallbackStyle`. As for a real world sample you can check https://github.com/clangd/coc-clangd/issues/39#issuecomment-703189067.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95538/new/

https://reviews.llvm.org/D95538



More information about the cfe-commits mailing list