| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=webkit.NoUncountedMemberChecker -verify %s |
| 2 |
|
| 3 |
#include "mock-types.h" |
| 4 |
#include "mock-system-header.h" |
| 5 |
|
| 6 |
namespace members { |
| 7 |
struct Foo { |
| 8 |
private: |
| 9 |
RefCountable* a = nullptr; |
| 10 |
// expected-warning@-1{{Member variable 'a' in 'members::Foo' is a raw pointer to ref-countable type 'RefCountable'}} |
| 11 |
|
| 12 |
[[clang::suppress]] |
| 13 |
RefCountable* a_suppressed = nullptr; |
| 14 |
|
| 15 |
protected: |
| 16 |
RefPtr<RefCountable> b; |
| 17 |
|
| 18 |
public: |
| 19 |
RefCountable silenceWarningAboutInit; |
| 20 |
RefCountable& c = silenceWarningAboutInit; |
| 21 |
// expected-warning@-1{{Member variable 'c' in 'members::Foo' is a reference to ref-countable type 'RefCountable'}} |
| 22 |
Ref<RefCountable> d; |
| 23 |
}; |
| 24 |
|
| 25 |
template<class T> |
| 26 |
struct FooTmpl { |
| 27 |
T* a; |
| 28 |
// expected-warning@-1{{Member variable 'a' in 'members::FooTmpl<RefCountable>' is a raw pointer to ref-countable type 'RefCountable'}} |
| 29 |
}; |
| 30 |
|
| 31 |
void forceTmplToInstantiate(FooTmpl<RefCountable>) {} |
| 32 |
|
| 33 |
struct [[clang::suppress]] FooSuppressed { |
| 34 |
private: |
| 35 |
RefCountable* a = nullptr; |
| 36 |
}; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
namespace ignore_unions { |
| 41 |
union Foo { |
| 42 |
RefCountable* a; |
| 43 |
RefPtr<RefCountable> b; |
| 44 |
Ref<RefCountable> c; |
| 45 |
}; |
| 46 |
|
| 47 |
template<class T> |
| 48 |
union RefPtr { |
| 49 |
T* a; |
| 50 |
}; |
| 51 |
|
| 52 |
void forceTmplToInstantiate(RefPtr<RefCountable>) {} |
| 53 |
} |
| 54 |
|
| 55 |
namespace ignore_system_header { |
| 56 |
|
| 57 |
void foo(RefCountable* t) { |
| 58 |
MemberVariable<RefCountable> var { t }; |
| 59 |
var.obj->method(); |
| 60 |
} |
| 61 |
|
| 62 |
} // ignore_system_header |