1 // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -verify %s
2 // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
3 // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
4 // RUN: %clang_analyze_cc1 -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
5 // RUN: %clang_analyze_cc1 -analyzer-inline-max-stack-depth 2 -analyzer-config ipa-always-inline-size=2 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -verify %s
6 // RUN: %clang_analyze_cc1 -analyzer-inline-max-stack-depth 2 -analyzer-config ipa-always-inline-size=2 -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -verify %s
7 // RUN: %clang_analyze_cc1 -analyzer-inline-max-stack-depth 2 -analyzer-config ipa-always-inline-size=2 -analyzer-checker=core,cplusplus.NewDelete -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
8 // RUN: %clang_analyze_cc1 -analyzer-inline-max-stack-depth 2 -analyzer-config ipa-always-inline-size=2 -analyzer-checker=core,cplusplus.NewDeleteLeaks -DLEAKS -std=c++11 -DTEST_INLINABLE_ALLOCATORS -verify %s
10 // expected-no-diagnostics
12 #include "Inputs/system-header-simulator-cxx.h"
14 typedef enum memory_order
{
15 memory_order_relaxed
= __ATOMIC_RELAXED
,
16 memory_order_consume
= __ATOMIC_CONSUME
,
17 memory_order_acquire
= __ATOMIC_ACQUIRE
,
18 memory_order_release
= __ATOMIC_RELEASE
,
19 memory_order_acq_rel
= __ATOMIC_ACQ_REL
,
20 memory_order_seq_cst
= __ATOMIC_SEQ_CST
28 return __c11_atomic_fetch_add((volatile _Atomic(int) *)&RefCnt
, 1,
29 memory_order_relaxed
);
33 return __c11_atomic_fetch_sub((volatile _Atomic(int) *)&RefCnt
, 1,
34 memory_order_relaxed
);
44 IntrusivePtr(Obj
*Ptr
) : Ptr(Ptr
) {
48 IntrusivePtr(const IntrusivePtr
&Other
) : Ptr(Other
.Ptr
) {
53 // We should not take the path on which the object is deleted.
54 if (Ptr
->decRef() == 1)
58 Obj
*getPtr() const { return Ptr
; } // no-warning
61 void testDestroyLocalRefPtr() {
62 IntrusivePtr
p1(new Obj());
67 // p1 still maintains ownership. The object is not deleted.
68 p1
.getPtr()->foo(); // no-warning
71 void testDestroySymbolicRefPtr(const IntrusivePtr
&p1
) {
76 // p1 still maintains ownership. The object is not deleted.
77 p1
.getPtr()->foo(); // no-warning