[llvm-bugs] [Bug 42598] New: clang-format-diff.py doesn't format impacted scope.
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Jul 12 07:02:06 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=42598
Bug ID: 42598
Summary: clang-format-diff.py doesn't format impacted scope.
Product: clang
Version: unspecified
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: yvesg at google.com
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
To reproduce, remove conditional scope in the following code:
; code1 ...
if (predicate) {
; code2 ...
}
So we get:
; code1 ...
; code2 ...
Then clang-diff-format.py won't unindent `code2` block, since it wasn't
touched.
A real-life example involving scoped lock is shown [here][1].
I know we are pretty close from "works as intended" and that an obvious
workaround is to clang-format whole file.
That being said, I'd like to offer some suggestions:
### Suggestion 0
Drop this script altogether and always format whole files. That would improve
consistency.
### Suggestion 1
Introduce an option in `clang-format` to fix impacted lines as well (transitive
formatting).
### Suggestion 2
Pass formatting range to be [min_line_changed:max_line_changed+1].
That's less drastic than #0 and I think it would do the right thing more often.
### Suggestion 3
Document this very caveat.
[1]
https://webrtc-review.googlesource.com/c/src/+/125240/2/media/engine/webrtc_video_engine.cc#723
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190712/e46465c8/attachment.html>
More information about the llvm-bugs
mailing list