10f88caeeSAdam Balogh // RUN: %clang_analyze_cc1 -std=c++11\ 20f88caeeSAdam Balogh // RUN: -analyzer-checker=core,cplusplus\ 30f88caeeSAdam Balogh // RUN: -analyzer-checker=debug.DebugIteratorModeling,debug.ExprInspection\ 40f88caeeSAdam Balogh // RUN: -analyzer-config aggressive-binary-operation-simplification=true\ 50f88caeeSAdam Balogh // RUN: -analyzer-config c++-container-inlining=false %s -verify 60f88caeeSAdam Balogh 70f88caeeSAdam Balogh // RUN: %clang_analyze_cc1 -std=c++11\ 80f88caeeSAdam Balogh // RUN: -analyzer-checker=core,cplusplus\ 90f88caeeSAdam Balogh // RUN: -analyzer-checker=debug.DebugIteratorModeling,debug.ExprInspection\ 100f88caeeSAdam Balogh // RUN: -analyzer-config aggressive-binary-operation-simplification=true\ 110f88caeeSAdam Balogh // RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s -verify 120f88caeeSAdam Balogh 130f88caeeSAdam Balogh #include "Inputs/system-header-simulator-cxx.h" 140f88caeeSAdam Balogh 150f88caeeSAdam Balogh template <typename Container> 160f88caeeSAdam Balogh long clang_analyzer_container_begin(const Container&); 170f88caeeSAdam Balogh template <typename Container> 180f88caeeSAdam Balogh long clang_analyzer_container_end(const Container&); 190f88caeeSAdam Balogh template <typename Iterator> 200f88caeeSAdam Balogh long clang_analyzer_iterator_position(const Iterator&); 210f88caeeSAdam Balogh template <typename Iterator> 220f88caeeSAdam Balogh void* clang_analyzer_iterator_container(const Iterator&); 230f88caeeSAdam Balogh template <typename Iterator> 240f88caeeSAdam Balogh bool clang_analyzer_iterator_validity(const Iterator&); 250f88caeeSAdam Balogh void clang_analyzer_denote(long, const char*); 260f88caeeSAdam Balogh void clang_analyzer_express(long); 270f88caeeSAdam Balogh void clang_analyzer_dump(const void*); 280f88caeeSAdam Balogh void clang_analyzer_eval(bool); 290f88caeeSAdam Balogh iterator_position(const std::vector<int> v0)300f88caeeSAdam Baloghvoid iterator_position(const std::vector<int> v0) { 310f88caeeSAdam Balogh auto b0 = v0.begin(), e0 = v0.end(); 320f88caeeSAdam Balogh 33*9a08a3faSAdam Balogh clang_analyzer_denote(clang_analyzer_container_begin(v0), "$b0"); 34*9a08a3faSAdam Balogh clang_analyzer_denote(clang_analyzer_container_end(v0), "$e0"); 350f88caeeSAdam Balogh 360f88caeeSAdam Balogh clang_analyzer_express(clang_analyzer_iterator_position(b0)); // expected-warning{{$b0}} 370f88caeeSAdam Balogh clang_analyzer_express(clang_analyzer_iterator_position(e0)); // expected-warning{{$e0}} 380f88caeeSAdam Balogh 390f88caeeSAdam Balogh ++b0; 400f88caeeSAdam Balogh 410f88caeeSAdam Balogh clang_analyzer_express(clang_analyzer_iterator_position(b0)); // expected-warning{{$b0 + 1}} 420f88caeeSAdam Balogh } 430f88caeeSAdam Balogh iterator_container(const std::vector<int> v0)440f88caeeSAdam Baloghvoid iterator_container(const std::vector<int> v0) { 450f88caeeSAdam Balogh auto b0 = v0.begin(); 460f88caeeSAdam Balogh 470f88caeeSAdam Balogh clang_analyzer_dump(&v0); //expected-warning{{&v0}} 480f88caeeSAdam Balogh clang_analyzer_eval(clang_analyzer_iterator_container(b0) == &v0); // expected-warning{{TRUE}} 490f88caeeSAdam Balogh } 500f88caeeSAdam Balogh iterator_validity(std::vector<int> v0)510f88caeeSAdam Baloghvoid iterator_validity(std::vector<int> v0) { 520f88caeeSAdam Balogh auto b0 = v0.begin(); 530f88caeeSAdam Balogh clang_analyzer_eval(clang_analyzer_iterator_validity(b0)); //expected-warning{{TRUE}} 540f88caeeSAdam Balogh 550f88caeeSAdam Balogh v0.clear(); 560f88caeeSAdam Balogh 570f88caeeSAdam Balogh clang_analyzer_eval(clang_analyzer_iterator_validity(b0)); //expected-warning{{FALSE}} 580f88caeeSAdam Balogh } 59