Merge pull request #1556 from hzeller/20221209-update-smoketest
Update smoketest expectations.
diff --git a/.github/bin/run-clang-format.sh b/.github/bin/run-clang-format.sh
index 73ac1d1..2fdfb04 100755
--- a/.github/bin/run-clang-format.sh
+++ b/.github/bin/run-clang-format.sh
@@ -24,7 +24,10 @@
if [ -s ${FORMAT_OUT} ]; then
echo "Style not matching (see https://github.com/chipsalliance/verible/blob/master/CONTRIBUTING.md#style)"
- echo "On your *.h, *.cc files, please run clang-format -i --style=file <your changed files>"
+ echo "Run"
+ echo " .github/bin/run-clang-format.sh"
+ echo "-------------------------------------------------"
+ echo
cat ${FORMAT_OUT}
exit 1
fi
diff --git a/common/formatting/layout_optimizer.cc b/common/formatting/layout_optimizer.cc
index ee18ab7..39e599d 100644
--- a/common/formatting/layout_optimizer.cc
+++ b/common/formatting/layout_optimizer.cc
@@ -570,10 +570,14 @@
}
}
}
+ // std::max(hanging_indentation, 0) serves to resolve a case where
+ // the subsequent nodes will try to be indented below zero following
+ // a less-indented token eg. a macro
const int hanging_indentation =
(node.Children().size() > 1)
- ? (node.Children()[1].Value().IndentationSpaces() -
- node.Value().IndentationSpaces())
+ ? std::max(node.Children()[1].Value().IndentationSpaces() -
+ node.Value().IndentationSpaces(),
+ 0)
: 0;
return factory_.Wrap(layouts.begin(), layouts.end(), false,
diff --git a/verilog/formatting/formatter_test.cc b/verilog/formatting/formatter_test.cc
index 8f00b0a..8642878 100644
--- a/verilog/formatting/formatter_test.cc
+++ b/verilog/formatting/formatter_test.cc
@@ -434,6 +434,10 @@
" aaaa == zzz;\n"
" ggg == vv::w;,\n"
" \"Failed to ..........\")\n"},
+ {// macro call nested with function call containing an ifdef
+ "`J(D(`ifdef e))\n",
+ "`J(D(\n"
+ " `ifdef e))\n"},
// `uvm macros indenting
{