[llvm-bugs] [Bug 52466] New: clang-format not idempotent with long comment containing tabs
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 10 02:29:17 PST 2021
https://bugs.llvm.org/show_bug.cgi?id=52466
Bug ID: 52466
Summary: clang-format not idempotent with long comment
containing tabs
Product: clang
Version: 13.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Formatter
Assignee: unassignedclangbugs at nondot.org
Reporter: felix.widmaier at tue.mpg.de
CC: djasper at google.com, klimek at google.com,
llvm-bugs at lists.llvm.org
Created attachment 25437
--> https://bugs.llvm.org/attachment.cgi?id=25437&action=edit
Example file for which the described issue occurs.
The output of `clang-format` changes multiple times on this example containing
a long comment with tabs (this is extracted from a real-world example, reduced
to the offending line):
> // // for(auto const& value: sze) cout << value<<" ";
(the file is also added as attachment).
I am testing with version "13.0.0 (https://github.com/llvm/llvm-project
d7b669b3a30345cfcdb2fde2af6f48aa4b94845d)".
Expected behaviour
==================
Calling `clang-format` a second time on any file should not result in any
additional changes, i.e. the output of
$ clang-format file.cpp | clang-format --dry-run
should always be empty.
Actual behaviour
================
On the given example,
$ clang-format file.cpp | clang-format --dry-run
results in the following output:
> <stdin>:1:37: warning: code should be clang-formatted [-Wclang-format-violations]
> // // for(auto const& value: sze)
> ^
> <stdin>:1:42: warning: code should be clang-formatted [-Wclang-format-violations]
> // // for(auto const& value: sze)
> ^
> <stdin>:2:1: warning: code should be clang-formatted [-Wclang-format-violations]
> // cout << value<<" ";
> ^
Actually, I have to call it four times until there are no changes anymore.
One run
-------
$ clang-format file.cpp
// //
for(auto const& value: sze)
// cout << value<<" ";
Two runs
--------
$ clang-format file.cpp | clang-format
// //
for(auto const& value:
// sze) cout << value<<" ";
Three runs
----------
$ clang-format file.cpp | clang-format | clang-format
// //
for(auto const&
// value: sze) cout << value<<" ";
Four runs
---------
$ clang-format file.cpp | clang-format | clang-format | clang-format
// //
for(auto
// const& value: sze) cout << value<<" ";
>From here there are no more changes.
I noticed that when I replace the tabs with spaces, I don't have this issue.
--
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/20211110/990991bb/attachment.html>
More information about the llvm-bugs
mailing list