Issue |
93958
|
Summary |
[clang-format] patch number changes format output
|
Labels |
clang-format
|
Assignees |
|
Reporter |
mattangus
|
I ran into an issue with CI patch number differing from our CI patch number of `clang-format`. CI and my local `clang-format` produced different results. I can reproduce this with the following:
```c++
// test_file.cxx
#include <iomanip>
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout
<< std::fixed
<< std::setprecision(1)
<< " - "
<< std::setw(02)
<< 10
<< " | "
<< std::setw(12)
<< "hello"
<< " | "
<< "test: ("
<< std::setw(04)
<< 1
<< ", "
<< std::setw(04)
<< 2
<< ", "
<< std::setw(04)
<< 3
<< ", "
<< std::setw(04)
<< 5
<< ") | "
<< std::endl;
return 0;
}
```
Running the commands:
```bash
$ cat .clang-format
---
BasedOnStyle: Google
ColumnLimit: 120
SpaceBeforeCpp11BracedList: true
Cpp11BracedListStyle: true
AlignAfterOpenBracket: BlockIndent
BinPackArguments: false
BinPackParameters: false
InsertTrailingCommas: Wrapped
BreakConstructorInitializers: BeforeColon
PackConstructorInitializers: CurrentLine
SpacesInParentheses: false
AlignOperands: Align
BreakBeforeBinaryOperators: false
PenaltyIndentedWhitespace: 1
IndentPPDirectives: BeforeHash
$ clang-format-18 --version
Ubuntu clang-format version 18.1.6 (++20240518023229+1118c2e05e67-1~exp1~20240518143321.130)
$ clang-format-18 --style=file test_file.cxx
#include <iomanip>
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout << std::fixed << std::setprecision(1) << " - " << std::setw(02) << 10 << " | " << std::setw(12) << "hello"
<< " | "
<< "test: (" << std::setw(04) << 1 << ", " << std::setw(04) << 2 << ", " << std::setw(04) << 3 << ", "
<< std::setw(04) << 5 << ") | " << std::endl;
return 0;
}
```
Then with a different version of `clang-format`
```bash
$ clang-format-18 --version
Ubuntu clang-format version 18.1.3 (1)
$ clang-format-18 --style=file test_file.cxx
#include <iomanip>
#include <iostream>
int main(int argc, char const *argv[]) {
std::cout << std::fixed << std::setprecision(1) << " - " << std::setw(02) << 10 << " | " << std::setw(12) << "hello"
<< " | " << "test: (" << std::setw(04) << 1 << ", " << std::setw(04) << 2 << ", " << std::setw(04) << 3
<< ", " << std::setw(04) << 5 << ") | " << std::endl;
return 0;
}
```
I suspect that a bug was introduced somewhere between `18.1.3` and `18.1.6`.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs