Debian Codegraph @

clang/test/Analysis/Checkers/WebKit/ref-allowing-partially-destroyed.cpp

raw
1 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2 // expected-no-diagnostics
3
4 #include "mock-types.h"
5
6 template <typename T> struct RefAllowingPartiallyDestroyed {
7 T *t;
8
9 RefAllowingPartiallyDestroyed() : t{} {};
10 RefAllowingPartiallyDestroyed(T &) {}
11 T *get() { return t; }
12 T *ptr() { return t; }
13 T *operator->() { return t; }
14 operator const T &() const { return *t; }
15 operator T &() { return *t; }
16 };
17
18 template <typename T> struct RefPtrAllowingPartiallyDestroyed {
19 T *t;
20
21 RefPtrAllowingPartiallyDestroyed() : t(new T) {}
22 RefPtrAllowingPartiallyDestroyed(T *t) : t(t) {}
23 T *get() { return t; }
24 T *operator->() { return t; }
25 const T *operator->() const { return t; }
26 T &operator*() { return *t; }
27 RefPtrAllowingPartiallyDestroyed &operator=(T *) { return *this; }
28 operator bool() { return t; }
29 };
30
31 class RefCounted {
32 public:
33 void ref() const;
34 void deref() const;
35 void someFunction();
36 };
37
38 RefAllowingPartiallyDestroyed<RefCounted> object1();
39 RefPtrAllowingPartiallyDestroyed<RefCounted> object2();
40
41 void testFunction() {
42 object1()->someFunction();
43 object2()->someFunction();
44 }