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