Doubts regarding clang-format


I am working on a clang format. I want to customize it:

  1. For if-else condition I want that for one line statement written in multiple lines should get wrapped in braces and also if there are only nested if-else then that code should be wrapped in braces. I have seen clang-tidy and in that google-readability-braces-around-statements.ShortStatementLines with value 2 gives expected results to me but I want that it should be done with clang-format.

  2. For some comments the indent level should be more or the clang-format should accept some comment intend level as it.

I want to make these changes in my clang-format. Please can you suggest some way to get these results?



Generally the goal of clang-format is to only modify whitespace (I think sorting includes is one place where that goal is intentionally violated, so it’s not a completely hard rule. -though includes may be easier to identify with certainty and modify with some certainty it shouldn’t affect the result), so (1) would be out of scope for clang-format, and appropriately implemented in clang-tidy as you’ve seen.

Can’t say I know much about (2) - seems like it could be implemented, but probably not something anyone’s tried to do, I would’ve thought - so I doubt there’s much infrastructure for it.