[ORC] Fail materialization in tasks that are destroyed before running.
[llvm-project.git] / clang / test / Analysis / Checkers / WebKit / ref-allowing-partially-destroyed.cpp
blob6d96c14102a902cc31e3a4f5104bb4b9f51a54aa
1 // RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s
2 // expected-no-diagnostics
4 #include "mock-types.h"
6 template <typename T> struct RefAllowingPartiallyDestroyed {
7 T *t;
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; }
18 template <typename T> struct RefPtrAllowingPartiallyDestroyed {
19 T *t;
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; }
31 class RefCounted {
32 public:
33 void ref() const;
34 void deref() const;
35 void someFunction();
38 RefAllowingPartiallyDestroyed<RefCounted> object1();
39 RefPtrAllowingPartiallyDestroyed<RefCounted> object2();
41 void testFunction() {
42 object1()->someFunction();
43 object2()->someFunction();