1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -std=c++11 -verify %s 2f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,cplusplus.NewDelete,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -std=c++11 -DINLINE=1 -verify %s 3f4a2713aSLionel Sambuc 4f4a2713aSLionel Sambuc #include "../Inputs/system-header-simulator-cxx.h" 5f4a2713aSLionel Sambuc 6f4a2713aSLionel Sambuc void clang_analyzer_eval(bool); 7f4a2713aSLionel Sambuc testVector(std::vector<int> & nums)8f4a2713aSLionel Sambucvoid testVector(std::vector<int> &nums) { 9f4a2713aSLionel Sambuc if (nums.begin()) return; 10f4a2713aSLionel Sambuc if (nums.end()) return; 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuc clang_analyzer_eval(nums.size() == 0); 13f4a2713aSLionel Sambuc #if INLINE 14f4a2713aSLionel Sambuc // expected-warning@-2 {{TRUE}} 15f4a2713aSLionel Sambuc #else 16f4a2713aSLionel Sambuc // expected-warning@-4 {{UNKNOWN}} 17f4a2713aSLionel Sambuc #endif 18f4a2713aSLionel Sambuc } 19f4a2713aSLionel Sambuc testException(std::exception e)20f4a2713aSLionel Sambucvoid testException(std::exception e) { 21f4a2713aSLionel Sambuc // Notice that the argument is NOT passed by reference, so we can devirtualize. 22f4a2713aSLionel Sambuc const char *x = e.what(); 23f4a2713aSLionel Sambuc clang_analyzer_eval(x == 0); 24f4a2713aSLionel Sambuc #if INLINE 25f4a2713aSLionel Sambuc // expected-warning@-2 {{TRUE}} 26f4a2713aSLionel Sambuc #else 27f4a2713aSLionel Sambuc // expected-warning@-4 {{UNKNOWN}} 28f4a2713aSLionel Sambuc #endif 29f4a2713aSLionel Sambuc } 30f4a2713aSLionel Sambuc testList_pop_front(std::list<int> list)31f4a2713aSLionel Sambucvoid testList_pop_front(std::list<int> list) { 32f4a2713aSLionel Sambuc while(!list.empty()) 33f4a2713aSLionel Sambuc list.pop_front(); // no-warning 34f4a2713aSLionel Sambuc } 35f4a2713aSLionel Sambuc testBasicStringSuppression()36f4a2713aSLionel Sambucvoid testBasicStringSuppression() { 37f4a2713aSLionel Sambuc std::basic_string<uint8_t> v; 38f4a2713aSLionel Sambuc v.push_back(1); // no-warning 39f4a2713aSLionel Sambuc } 40f4a2713aSLionel Sambuc testBasicStringSuppression_append()41f4a2713aSLionel Sambucvoid testBasicStringSuppression_append() { 42f4a2713aSLionel Sambuc std::basic_string<char32_t> v; 43f4a2713aSLionel Sambuc v += 'c'; // no-warning 44f4a2713aSLionel Sambuc } 45*0a6a1f1dSLionel Sambuc testBasicStringSuppression_assign(std::basic_string<char32_t> & v,const std::basic_string<char32_t> & v2)46*0a6a1f1dSLionel Sambucvoid testBasicStringSuppression_assign(std::basic_string<char32_t> &v, 47*0a6a1f1dSLionel Sambuc const std::basic_string<char32_t> &v2) { 48*0a6a1f1dSLionel Sambuc v = v2; 49*0a6a1f1dSLionel Sambuc } 50