[cfe-dev] Clang-format on specific lines: absolute indentation

Justin Bogner via cfe-dev cfe-dev at lists.llvm.org
Thu Jul 19 22:38:39 PDT 2018


Arnaud Coomans via cfe-dev <cfe-dev at lists.llvm.org> writes:
> I’m trying to tackle a bug about indentation in clang-format for when
> formatting should be done on certain lines only
> (https://bugs.llvm.org/show_bug.cgi?id=37975).
>
> What’s the expected behavior? One could expect:
> - absolute indentation: the indentation one would get if the whole
>   file were formatted; or
> - relative indentation: keep the indentation relative to the previous
>   lines, even if those are not indented correctly and are not in the
>   range of lines to format
>
> Judging from the tests, the relative indentation has been adopted; but
> I could see both cases being valid.
>
> Are we ok with relative indentation by default?
> Would we be ok to add a new parameter to specify absolute indentation?
>
> Any opinion/advice?

IMO relative indentation is more useful. It doesn't make much sense if
you try to format a specific block of code but the indentation is only
reasonable if the whole file was already formatted.

That is to say, if I understand the PR correctly, I don't think there's
a bug here.



More information about the cfe-dev mailing list