1 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=false -verify -analyzer-config eagerly-assume=false %s
2 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=true -DINLINE=1 -verify -analyzer-config eagerly-assume=false %s
3 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=false -DTEST_INLINABLE_ALLOCATORS -verify -analyzer-config eagerly-assume=false %s
4 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config c++-inlining=destructors -analyzer-config c++-container-inlining=true -DTEST_INLINABLE_ALLOCATORS -DINLINE=1 -verify -analyzer-config eagerly-assume=false %s
8 void clang_analyzer_eval(bool);
9 void clang_analyzer_checkInlined(bool);
12 #include "containers.cpp"
18 clang_analyzer_eval(set
.isEmpty());
20 // expected-warning@-2 {{TRUE}}
22 // expected-warning@-4 {{UNKNOWN}}
25 clang_analyzer_eval(set
.raw_begin() == set
.raw_end());
27 // expected-warning@-2 {{TRUE}}
29 // expected-warning@-4 {{UNKNOWN}}
32 clang_analyzer_eval(set
.begin().impl
== set
.end().impl
);
34 // expected-warning@-2 {{TRUE}}
36 // expected-warning@-4 {{UNKNOWN}}
40 void testSubclass(MySetSubclass
&sub
) {
41 sub
.useIterator(sub
.begin());
46 void testWrappers(BeginOnlySet
&w1
, IteratorStructOnlySet
&w2
,
47 IteratorTypedefOnlySet
&w3
, IteratorUsingOnlySet
&w4
) {
49 IteratorStructOnlySet local2
;
50 IteratorTypedefOnlySet local3
;
51 IteratorUsingOnlySet local4
;
53 clang_analyzer_eval(w1
.begin().impl
.impl
== w1
.begin().impl
.impl
);
55 // expected-warning@-2 {{TRUE}}
57 // expected-warning@-4 {{UNKNOWN}}
60 clang_analyzer_eval(w2
.start().impl
== w2
.start().impl
);
62 // expected-warning@-2 {{TRUE}}
64 // expected-warning@-4 {{UNKNOWN}}
67 clang_analyzer_eval(w3
.start().impl
== w3
.start().impl
);
69 // expected-warning@-2 {{TRUE}}
71 // expected-warning@-4 {{UNKNOWN}}
74 clang_analyzer_eval(w4
.start().impl
== w4
.start().impl
);
76 // expected-warning@-2 {{TRUE}}
78 // expected-warning@-4 {{UNKNOWN}}
85 #include "../Inputs/system-header-simulator-cxx.h"
91 MySet() : storage(0), size(0) {
92 clang_analyzer_checkInlined(true);
94 // expected-warning@-2 {{TRUE}}
98 MySet(unsigned n
) : storage(new int[n
]), size(n
) {
99 clang_analyzer_checkInlined(true);
101 // expected-warning@-2 {{TRUE}}
105 ~MySet() { delete[] storage
; }
108 clang_analyzer_checkInlined(true);
110 // expected-warning@-2 {{TRUE}}
118 iterator(int *p
) : impl(p
) {}
122 clang_analyzer_checkInlined(true);
124 // expected-warning@-2 {{TRUE}}
126 return iterator(storage
);
130 clang_analyzer_checkInlined(true);
132 // expected-warning@-2 {{TRUE}}
134 return iterator(storage
+size
);
137 typedef int *raw_iterator
;
139 raw_iterator
raw_begin() {
140 clang_analyzer_checkInlined(true);
142 // expected-warning@-2 {{TRUE}}
146 raw_iterator
raw_end() {
147 clang_analyzer_checkInlined(true);
149 // expected-warning@-2 {{TRUE}}
151 return storage
+ size
;
155 class MySetSubclass
: public MySet
{
158 clang_analyzer_checkInlined(true);
160 // expected-warning@-2 {{TRUE}}
164 void useIterator(iterator i
) {
165 clang_analyzer_checkInlined(true);
167 // expected-warning@-2 {{TRUE}}
176 MySet::iterator impl
;
177 typedef std::forward_iterator_tag iterator_category
;
179 IterImpl(MySet::iterator i
) : impl(i
) {
180 clang_analyzer_checkInlined(true);
182 // expected-warning@-2 {{TRUE}}
188 clang_analyzer_checkInlined(true);
190 // expected-warning@-2 {{TRUE}}
194 typedef IterImpl wrapped_iterator
;
196 wrapped_iterator
begin() {
197 clang_analyzer_checkInlined(true);
199 // expected-warning@-2 {{TRUE}}
201 return IterImpl(impl
.begin());
205 class IteratorTypedefOnlySet
{
209 IteratorTypedefOnlySet() {
210 clang_analyzer_checkInlined(true);
212 // expected-warning@-2 {{TRUE}}
216 typedef MySet::iterator iterator
;
219 clang_analyzer_checkInlined(true);
221 // expected-warning@-2 {{TRUE}}
227 class IteratorUsingOnlySet
{
231 IteratorUsingOnlySet() {
232 clang_analyzer_checkInlined(true);
234 // expected-warning@-2 {{TRUE}}
238 using iterator
= MySet::iterator
;
241 clang_analyzer_checkInlined(true);
243 // expected-warning@-2 {{TRUE}}
249 class IteratorStructOnlySet
{
253 IteratorStructOnlySet() {
254 clang_analyzer_checkInlined(true);
256 // expected-warning@-2 {{TRUE}}
265 clang_analyzer_checkInlined(true);
267 // expected-warning@-2 {{TRUE}}
269 return iterator
{impl
.begin().impl
};