[analyzer] Add werror flag for analyzer warnings
authorKeno Fischer <keno@alumni.harvard.edu>
Fri, 7 Jun 2019 23:34:00 +0000 (23:34 +0000)
committerKeno Fischer <keno@alumni.harvard.edu>
Fri, 7 Jun 2019 23:34:00 +0000 (23:34 +0000)
commit6f48c076207f49dde437d85dbd5e1bcdd580f973
treec0a4a617f8ea560da59aa4e67e12e82192e8fb42
parenta59aeb3f29a97b685eb10005f8d2f70bd7d894ec
[analyzer] Add werror flag for analyzer warnings

Summary:
We're using the clang static analyzer together with a number of
custom analyses in our CI system to ensure that certain invariants
are statiesfied for by the code every commit. Unfortunately, there
currently doesn't seem to be a good way to determine whether any
analyzer warnings were emitted, other than parsing clang's output
(or using scan-build, which then in turn parses clang's output).
As a simpler mechanism, simply add a `-analyzer-werror` flag to CC1
that causes the analyzer to emit its warnings as errors instead.
I briefly tried to have this be `Werror=analyzer` and make it go
through that machinery instead, but that seemed more trouble than
it was worth in terms of conflicting with options to the actual build
and special cases that would be required to circumvent the analyzers
usual attempts to quiet non-analyzer warnings. This is simple and it
works well.

Reviewed-By: NoQ, Szelethusw
Differential Revision: https://reviews.llvm.org/D62885

llvm-svn: 362855
clang/include/clang/Driver/CC1Options.td
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
clang/test/Analysis/override-werror.c