diff options
Diffstat (limited to 'test/Analysis/iterator-range.cpp')
-rw-r--r-- | test/Analysis/iterator-range.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/Analysis/iterator-range.cpp b/test/Analysis/iterator-range.cpp new file mode 100644 index 0000000000000..79b45188ab5db --- /dev/null +++ b/test/Analysis/iterator-range.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-eagerly-assume -analyzer-config c++-container-inlining=false %s -verify +// RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,cplusplus,alpha.cplusplus.IteratorRange -analyzer-eagerly-assume -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify + +#include "Inputs/system-header-simulator-cxx.h" + +void clang_analyzer_warnIfReached(); + +void simple_good_end(const std::vector<int> &v) { + auto i = v.end(); + if (i != v.end()) { + clang_analyzer_warnIfReached(); + *i; // no-warning + } +} + +void simple_bad_end(const std::vector<int> &v) { + auto i = v.end(); + *i; // expected-warning{{Iterator accessed outside of its range}} +} |