]> granicus.if.org Git - clang/commit
[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)
commitcea7d5c5fcd82bdf56a8d494237fb3de41da17de
tree07c9c6ebd1acfe9df52ea2e53d53da4c478f42ba
parent85890113ee5ed22c885e52b51f2f532c30201c96
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@362855 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Driver/CC1Options.td
include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
lib/Frontend/CompilerInvocation.cpp
lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
test/Analysis/override-werror.c