blob: 7f3bcdab5ec5e31a751094aa321f76efa2369d71 [file] [log] [blame]
Jordan Rosec63a4602013-04-02 00:26:35 +00001// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=false -verify %s
2// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-container-inlining=true -analyzer-config c++-stdlib-inlining=true -DINLINE=1 -verify %s
Jordan Rose81fb50e2012-09-10 21:27:35 +00003
Chandler Carruth1b22cec2012-09-12 01:11:10 +00004#include "../Inputs/system-header-simulator-cxx.h"
Jordan Rose81fb50e2012-09-10 21:27:35 +00005
6void clang_analyzer_eval(bool);
7
8void 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
20void 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}
Anna Zaks8b625a32013-07-04 02:38:10 +000030
31void testList_pop_front(std::list<int> list) {
32 while(!list.empty())
33 list.pop_front(); // no-warning
34}
35