1 // RUN: %clang_analyze_cc1 -std=c++11\
2 // RUN: -analyzer-checker=core,cplusplus\
3 // RUN: -analyzer-checker=debug.DebugIteratorModeling,debug.ExprInspection\
4 // RUN: -analyzer-config aggressive-binary-operation-simplification=true\
5 // RUN: -analyzer-config c++-container-inlining=false %s -verify
7 // RUN: %clang_analyze_cc1 -std=c++11\
8 // RUN: -analyzer-checker=core,cplusplus\
9 // RUN: -analyzer-checker=debug.DebugIteratorModeling,debug.ExprInspection\
10 // RUN: -analyzer-config aggressive-binary-operation-simplification=true\
11 // RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify
13 #include "Inputs/system-header-simulator-cxx.h"
15 template <typename Container
>
16 long clang_analyzer_container_begin(const Container
&);
17 template <typename Container
>
18 long clang_analyzer_container_end(const Container
&);
19 template <typename Iterator
>
20 long clang_analyzer_iterator_position(const Iterator
&);
21 template <typename Iterator
>
22 void* clang_analyzer_iterator_container(const Iterator
&);
23 template <typename Iterator
>
24 bool clang_analyzer_iterator_validity(const Iterator
&);
25 void clang_analyzer_denote(long, const char*);
26 void clang_analyzer_express(long);
27 void clang_analyzer_dump(const void*);
28 void clang_analyzer_eval(bool);
30 void iterator_position(const std::vector
<int> v0
) {
31 auto b0
= v0
.begin(), e0
= v0
.end();
33 clang_analyzer_denote(clang_analyzer_container_begin(v0
), "$b0");
34 clang_analyzer_denote(clang_analyzer_container_end(v0
), "$e0");
36 clang_analyzer_express(clang_analyzer_iterator_position(b0
)); // expected-warning{{$b0}}
37 clang_analyzer_express(clang_analyzer_iterator_position(e0
)); // expected-warning{{$e0}}
41 clang_analyzer_express(clang_analyzer_iterator_position(b0
)); // expected-warning{{$b0 + 1}}
44 void iterator_container(const std::vector
<int> v0
) {
47 clang_analyzer_dump(&v0
); //expected-warning{{&v0}}
48 clang_analyzer_eval(clang_analyzer_iterator_container(b0
) == &v0
); // expected-warning{{TRUE}}
51 void iterator_validity(std::vector
<int> v0
) {
53 clang_analyzer_eval(clang_analyzer_iterator_validity(b0
)); //expected-warning{{TRUE}}
57 clang_analyzer_eval(clang_analyzer_iterator_validity(b0
)); //expected-warning{{FALSE}}