xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/inlining/stl.cpp (revision 0b98e8aad89f2bd4ba80b523d73cf29e9dd82ce1)
1 // 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
2 // 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
3 
4 #include "../Inputs/system-header-simulator-cxx.h"
5 
6 void clang_analyzer_eval(bool);
7 
8 void testVector(std::vector<int> &nums) {
9   if (nums.begin()) return;
10   if (nums.end()) return;
11 
12   clang_analyzer_eval(nums.size() == 0);
13 #if INLINE
14   // expected-warning@-2 {{TRUE}}
15 #else
16   // expected-warning@-4 {{UNKNOWN}}
17 #endif
18 }
19 
20 void testException(std::exception e) {
21   // Notice that the argument is NOT passed by reference, so we can devirtualize.
22   const char *x = e.what();
23   clang_analyzer_eval(x == 0);
24 #if INLINE
25   // expected-warning@-2 {{TRUE}}
26 #else
27   // expected-warning@-4 {{UNKNOWN}}
28 #endif
29 }
30 
31 void testList_pop_front(std::list<int> list) {
32   while(!list.empty())
33     list.pop_front();  // no-warning
34 }
35 
36 void testBasicStringSuppression() {
37   std::basic_string<uint8_t> v;
38   v.push_back(1); // no-warning
39 }
40 
41 void testBasicStringSuppression_append() {
42   std::basic_string<char32_t> v;
43   v += 'c'; // no-warning
44 }
45