-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang-format crash with --lines and CompactNamespaces: true NamespaceIndentation: All
#56352
Labels
Comments
CompactNamespaces: true NamespaceIndentation: All
CompactNamespaces: true NamespaceIndentation: All
@llvm/issue-subscribers-clang-format |
Clang-format |
Closed
issue-subscribers-clang-format |
Closed
@panukulv: Please use preview for sandbox purposes. There is no need to spam project with test issues and comments. |
Revision URI: https://reviews.llvm.org/D129064 |
mem-frob
pushed a commit
to draperlaboratory/hope-llvm-project
that referenced
this issue
Oct 7, 2022
Fixes llvm/llvm-project#56352. Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay Differential Revision: https://reviews.llvm.org/D129064
owenca
pushed a commit
that referenced
this issue
May 24, 2023
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 the previous indentation level. In case of the --lines option configured 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 #56352 to fix a crash. Our commit here essentially reverts that crash fix. It seemed to have been incorrect. The proper fix is to set the AnnotedLine::Level of joined lines correctly (=> change in LineJoiner::join()). See #59178 (comment) for some more details. Fixes #58464. Fixes #59178. Differential Revision: https://reviews.llvm.org/D151047
llvmbot
pushed a commit
to llvm/llvm-project-release-prs
that referenced
this issue
May 24, 2023
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 the previous indentation level. In case of the --lines option configured 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 llvm/llvm-project#56352 to fix a crash. Our commit here essentially reverts that crash fix. It seemed to have been incorrect. The proper fix is to set the AnnotedLine::Level of joined lines correctly (=> change in LineJoiner::join()). See llvm/llvm-project#59178 (comment) for some more details. Fixes #58464. Fixes #59178. Differential Revision: https://reviews.llvm.org/D151047 (cherry picked from commit 72ab89e)
owenca
pushed a commit
that referenced
this issue
Jul 18, 2023
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
jdoerfert
pushed a commit
to jdoerfert/llvm-project
that referenced
this issue
Jul 24, 2023
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 (llvm#56352) to fix a crash. Our commit here essentially reverts that crash fix. It was incorrect/incomplete. Fixes llvm#58464. Fixes llvm#59178. Fixes llvm#62799. Differential Revision: https://reviews.llvm.org/D151047
veselypeta
pushed a commit
to veselypeta/cherillvm
that referenced
this issue
Aug 23, 2024
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 the previous indentation level. In case of the --lines option configured 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 llvm/llvm-project#56352 to fix a crash. Our commit here essentially reverts that crash fix. It seemed to have been incorrect. The proper fix is to set the AnnotedLine::Level of joined lines correctly (=> change in LineJoiner::join()). See llvm/llvm-project#59178 (comment) for some more details. Fixes #58464. Fixes #59178. Differential Revision: https://reviews.llvm.org/D151047
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
I've had this issue for several versions of clang-format.
Currently using
I tried to make a minimal example where I have the issue:
Given the source code in attached
test.txt (I can't attach something with .hpp or something more cpp like)
and using a
.clang-format
file with following settings:if I then run
clang-format --lines=1:1 test.txt
then I get the following report:
The text was updated successfully, but these errors were encountered: