[all-commits] [llvm/llvm-project] 0570cc: [clang-format] Fix indent for selective formatting
Sedenion via All-commits
all-commits at lists.llvm.org
Tue Jul 18 14:11:09 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 0570cc568f5c8047267be7ab5056f8c4f45349b5
https://github.com/llvm/llvm-project/commit/0570cc568f5c8047267be7ab5056f8c4f45349b5
Author: Sedenion <39583823+Sedeniono at users.noreply.github.com>
Date: 2023-07-18 (Tue, 18 Jul 2023)
Changed paths:
M clang/lib/Format/UnwrappedLineFormatter.cpp
M clang/unittests/Format/FormatTestSelective.cpp
Log Message:
-----------
[clang-format] Fix indent for selective formatting
The problem was that the LevelIndentTracker remembered
the indentation level of previous deeper levels when
leaving a scope. Afterwards, when it entered again a
deeper level, it blindly reused the previous
indentation level. In case the --lines option was used
such that the previous deeper level was not formatted,
that previous level was whatever happened to be there
in the source code. The formatter simply believed it.
This is fixed by letting the LevelIndentTracker forget
the previous deeper levels when stepping out of them
(=> change in LevelIndentTracker::nextLine()).
Note that this used to be the case until LLVM 14.0.6,
but was changed in https://reviews.llvm.org/D129064
(#56352) to fix a crash. Our commit here essentially
reverts that crash fix. It was incorrect/incomplete.
Fixes #58464.
Fixes #59178.
Fixes #62799.
Differential Revision: https://reviews.llvm.org/D151047
More information about the All-commits
mailing list