[compiler-wrapper] Handle double build for clang-tidy

For clang-tidy, the equivalent of -Werror is --warnings-as-errors (or
-warnings-as-errors).  The error message will also have
"warnings-as-errors".  So,
1. Trigger double-build if "warnings-as-errors" is in *stdout*.
Clang-tidy will also fail if clang issues a Werror diagnostic.  In this
case, we'd get "clang-diagnostic" in stdout.  Do a re-build in both
these cases.
2. Remove flags containing "-warnings-as-errors" in the rerun.  Unlike
-Werror/Wno-error, clang-tidy doesn't have a -no-warnings-as-errors to
override a prior -warnings-as-errors.  Existing double-build processing
will disable -Werror flags to Clang.

Originally reviewed at
https://android-review.googlesource.com/c/platform/external/toolchain-utils/+/1322200.

BUG=None
TEST=go test

Change-Id: I18de245972da81e0ac3600f9098b71cec82e9e96
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2239370
Commit-Queue: Pirama Arumuga Nainar <pirama@google.com>
Tested-by: Pirama Arumuga Nainar <pirama@google.com>
Reviewed-by: George Burgess <gbiv@chromium.org>
3 files changed