diff options
author | Jordan Rose <jordan_rose@apple.com> | 2013-04-02 00:26:15 +0000 |
---|---|---|
committer | Jordan Rose <jordan_rose@apple.com> | 2013-04-02 00:26:15 +0000 |
commit | a12643622ad3b85972dfdd80fe9006a3e8d8fb80 (patch) | |
tree | 27a231ef368ee15f32966304f5c43742f520f293 /test/Analysis | |
parent | f12a25b55bee5ac1802c595b3014db091bbe635b (diff) |
[analyzer] Allow suppressing diagnostics reported within the 'std' namespace
This is controlled by the 'suppress-c++-stdlib' analyzer-config flag.
It is currently off by default.
This is more suppression than we'd like to do, since obviously there can
be user-caused issues within 'std', but it gives us the option to wield
a large hammer to suppress false positives the user likely can't work
around.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178513 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/Inputs/system-header-simulator-cxx.h | 7 | ||||
-rw-r--r-- | test/Analysis/diagnostics/explicit-suppression.cpp | 71 |
2 files changed, 78 insertions, 0 deletions
diff --git a/test/Analysis/Inputs/system-header-simulator-cxx.h b/test/Analysis/Inputs/system-header-simulator-cxx.h index 03de527a02..eee0e31a6f 100644 --- a/test/Analysis/Inputs/system-header-simulator-cxx.h +++ b/test/Analysis/Inputs/system-header-simulator-cxx.h @@ -73,6 +73,13 @@ namespace std { struct nothrow_t {}; extern const nothrow_t nothrow; + + template<class InputIter, class OutputIter> + OutputIter copy(InputIter II, InputIter IE, OutputIter OI) { + while (II != IE) + *OI++ = *II++; + return OI; + } } void* operator new(std::size_t, const std::nothrow_t&) throw(); diff --git a/test/Analysis/diagnostics/explicit-suppression.cpp b/test/Analysis/diagnostics/explicit-suppression.cpp new file mode 100644 index 0000000000..6bc950f5d5 --- /dev/null +++ b/test/Analysis/diagnostics/explicit-suppression.cpp @@ -0,0 +1,71 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=false -verify %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-config suppress-c++-stdlib=true -DSUPPRESSED=1 -verify %s + +#ifdef SUPPRESSED +// expected-no-diagnostics +#endif + +#include "../Inputs/system-header-simulator-cxx.h" + +void clang_analyzer_eval(bool); + +void testCopyNull(int *I, int *E) { + std::copy(I, E, (int *)0); +#ifndef SUPPRESSED + // This line number comes from system-header-simulator-cxx.h. + // expected-warning@65 {{Dereference of null pointer}} +#endif +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +// PR15613: expected-* can't refer to diagnostics in other source files. +// The current implementation only matches line numbers, but has an upper limit +// of the number of lines in the main source file. |