This came up as a question in https://chromium-review.googlesource.com/1085064, which I'm forwarding here.
third_party/blink/renderer/core/workers/worklet_pending_tasks.cc had code that looked like this:
void WorkletPendingTasks::DecrementCounter() {
if (counter != -1) {
--counter_;
if (counter == 0)
resolver_->Resolve();
}
}
which https://chromium-review.googlesource.com/1062795 later changed to
...
if (counter != 1) {
--counter_;
if (counter == 0)
worket_->FinishPendingTasks(this);
resolver_->Resolve();
}
...
that is 'goto fail'-esque and was only caught by a GCC build with -Wmisleading-indentation.
nhiroki@ was wondering why git-cl format didn't reformat the code and automatically cause a git-cl presubmit failure. It turns out running 'clang-format -style file third_party/blink/renderer/core/workers/worklet_pending_tasks.cc' does cause the file to be reformatted as expected, but the presubmit code actually calls git diff with -U0 and passes the output to clang-format-diff.py.
clang-format-diff.py only got a single line and couldn't really reason if the indentation was wrong or not:
@@ -41,0 +49 @@ void WorkletPendingTasks::DecrementCounter() {
+ worklet_->FinishPendingTasks(this);
I then wonder if git-cl should be passing more context to clang-format-diff, or if there's anything to be done to clang-format-diff itself, or even if there's any movement in the LLVM community to have something similar to -Wmisleading-indentation.
Comment 1 by raphael....@intel.com
, Jun 5 2018