Skip to content

Commit 714d927

Browse files
committed
[#81064] Bump clang-format, fix formatting
Signed-off-by: Artur Bieniek <abieniek@internships.antmicro.com>
1 parent ccff55e commit 714d927

9 files changed

Lines changed: 28 additions & 20 deletions

File tree

.ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ test-and-lint:
88
image: "verilator/verilator:v5.016"
99
tags: ['ace-x86_64']
1010
script:
11-
- apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-14 mold ninja-build shellcheck
11+
- apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-15 mold ninja-build shellcheck
1212
- cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -G Ninja -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=mold" -DCMAKE_SHARED_LINKER_FLAGS="-fuse-ld=mold"
1313
- cmake --build build -j"$(nproc)"
1414
- PATH="$PWD/build:$PWD/scripts:$PATH" && make -j"$(nproc)" -O -k --no-print-directory -f check.mk

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ BasedOnStyle: Chromium
33
ColumnLimit: 100
44
IndentWidth: 4
55
AlignEscapedNewlines: DontAlign
6+
InsertBraces: true

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
steps:
1313
- uses: actions/checkout@v4
1414
- name: Install deps
15-
run: apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-14 shellcheck
15+
run: apt-get -qqy update && apt-get -qqy --no-install-recommends install cmake build-essential git ca-certificates python3 clang-format-15 shellcheck
1616
- name: Build
1717
run: |
1818
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo

check.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ autofix: autofmt shellcheck_autofix
1212

1313
.PHONY: autofmt
1414
autofmt:
15-
clang-format-14 -i source/*.cpp source/*.hpp
15+
clang-format-15 -i source/*.cpp source/*.hpp
1616

1717
.PHONY: test
1818
test:
@@ -25,7 +25,7 @@ lint: fmt_check shellcheck
2525
fmt_check:
2626
FMT_FAILED=0; \
2727
for i in source/*.cpp source/*.hpp; do \
28-
diff "$$i" <(clang-format-14 "$$i") --label "original $$i" --label "formatted $$i" --color=always -u || FMT_FAILED=1; \
28+
diff "$$i" <(clang-format-15 "$$i") --label "original $$i" --label "formatted $$i" --color=always -u || FMT_FAILED=1; \
2929
done; \
3030
exit "$$FMT_FAILED"
3131
@echo # blank line for consistency

source/OneTimeRewriter.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ class OneTimeRewriter : public SyntaxRewriter<TDerived> {
4444
void visitDefault(T&& node) {
4545
for (uint32_t i = 0; i < node.getChildCount(); i++) {
4646
auto child = node.childNode(i);
47-
if (child)
47+
if (child) {
4848
child->visit(*DERIVED, node.isChildOptional(i));
49+
}
4950
}
50-
if (node.getChildCount() == 0) // leaf node
51+
if (node.getChildCount() == 0) { // leaf node
5152
node.visit(*DERIVED, true);
53+
}
5254
}
5355

5456
// Do some state bookkeeping, try to call type-specific handler, and visit node's children.

source/PairRemovers.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,9 @@ class PortMapper : public ASTVisitor<PortMapper, true, true, true> {
5454
void handle(const InstanceSymbol& instance) {
5555
std::unordered_set<SourceRange> connectedPortDefs;
5656
for (auto conn : instance.getPortConnections()) {
57-
if (!conn)
57+
if (!conn) {
5858
continue;
59+
}
5960

6061
SourceRange defLocation = getPortDefLoc(&conn->port);
6162
SourceRange useLocation = SourceRange::NoLocation;

source/PairRemovers.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ class PairRemover : public SyntaxRewriter<PairRemover> {
3535
void visitDefault(T&& node) {
3636
for (uint32_t i = 0; i < node.getChildCount(); i++) {
3737
auto child = node.childNode(i);
38-
if (child)
38+
if (child) {
3939
child->visit(*this, node.isChildOptional(i));
40+
}
4041
}
4142
}
4243

source/SvBugpoint.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,13 @@ bool SvBugpoint::test(std::shared_ptr<SyntaxTree>& tree, AttemptStats& stats) {
102102
}
103103

104104
char* getNextDelim(char* line, char* end) {
105-
if (line > end)
105+
if (line > end) {
106106
return nullptr;
107+
}
107108
while (line < end) {
108-
if (*line == '\n')
109-
return line;
110-
if (*line == '\r')
111-
return line;
112-
if (*line == '\0')
109+
if (*line == '\n' || *line == '\r' || *line == '\0') {
113110
return line;
111+
}
114112
line++;
115113
}
116114
return end;
@@ -460,16 +458,18 @@ void SvBugpoint::processCommandFiles(fs::path file) {
460458
void SvBugpoint::parseCommandLine(std::string_view argList,
461459
CommandLine::ParseOptions parseOptions) {
462460
if (!cmdLine.parse(argList, parseOptions)) {
463-
for (auto& err : cmdLine.getErrors())
461+
for (auto& err : cmdLine.getErrors()) {
464462
std::cerr << err << std::endl;
463+
}
465464
exit(1);
466465
}
467466
}
468467

469468
void SvBugpoint::parseCommandLine(int argc, char** argv) {
470469
if (!cmdLine.parse(argc, argv)) {
471-
for (auto& err : cmdLine.getErrors())
470+
for (auto& err : cmdLine.getErrors()) {
472471
std::cerr << err << std::endl;
472+
}
473473
exit(1);
474474
}
475475
}

source/Utils.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ class TreePrinter : public SyntaxVisitor<TDerived> {
5959
}
6060

6161
void printIndent() {
62-
for (int i = 0; i < indentLevel; ++i)
62+
for (int i = 0; i < indentLevel; ++i) {
6363
out << " ";
64+
}
6465
}
6566

6667
template <typename T>
@@ -110,8 +111,9 @@ class AstPrinter : public ASTVisitor<AstPrinter, true, true, true> {
110111
out << "node: " << STRINGIZE_NODE_TYPE(T) << " " << toString(node.kind) << " "
111112
<< "\n";
112113
if constexpr (requires { node.getSyntax(); }) {
113-
if (node.getSyntax())
114+
if (node.getSyntax()) {
114115
out << node.getSyntax()->toString() << "\n";
116+
}
115117
}
116118
visitDefault(node);
117119
}
@@ -126,12 +128,13 @@ void printAst(const RootSymbol& root, std::ostream& file) {
126128
}
127129

128130
std::string toString(SourceRange sourceRange) {
129-
if (sourceRange == SourceRange::NoLocation)
131+
if (sourceRange == SourceRange::NoLocation) {
130132
return "NO_LOCATION";
131-
else
133+
} else {
132134
return "buffer:" + std::to_string(sourceRange.start().buffer().getId()) +
133135
", offsetStart: " + std::to_string(sourceRange.start().offset()) +
134136
", offsetEnd: " + std::to_string(sourceRange.end().offset());
137+
}
135138
}
136139

137140
void copyFile(const std::string& from, const std::string& to) {

0 commit comments

Comments
 (0)