| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s |
| 2 |
|
| 3 |
typedef unsigned long size_t; |
| 4 |
template<typename T, size_t N> |
| 5 |
struct Obj { |
| 6 |
constexpr static size_t Size = N; |
| 7 |
|
| 8 |
constexpr T& operator[](size_t i) { return components[i]; } |
| 9 |
constexpr const T& operator[](size_t i) const { return components[i]; } |
| 10 |
|
| 11 |
constexpr size_t size() const { return Size; } |
| 12 |
|
| 13 |
T components[N]; |
| 14 |
}; |
| 15 |
|
| 16 |
template<typename T, size_t N> |
| 17 |
constexpr bool operator==(const Obj<T, N>& a, const Obj<T, N>& b) |
| 18 |
{ |
| 19 |
for (size_t i = 0; i < N; ++i) { |
| 20 |
if (a[i] == b[i]) |
| 21 |
continue; |
| 22 |
return false; |
| 23 |
} |
| 24 |
|
| 25 |
return true; |
| 26 |
} |
| 27 |
|
| 28 |
struct NonTrivial { |
| 29 |
NonTrivial(); |
| 30 |
NonTrivial(const NonTrivial&); |
| 31 |
bool operator==(const NonTrivial& other) const { return value == other.value; } |
| 32 |
float value; |
| 33 |
}; |
| 34 |
|
| 35 |
class Component { |
| 36 |
public: |
| 37 |
void ref() const; |
| 38 |
void deref() const; |
| 39 |
|
| 40 |
Obj<float, 4> unresolvedComponents() const { return m_components; } |
| 41 |
Obj<NonTrivial, 4> unresolvedNonTrivialComponents() const { return m_nonTrivialComponents; } |
| 42 |
|
| 43 |
bool isEqual(const Component& other) const { |
| 44 |
return unresolvedComponents() == other.unresolvedComponents(); |
| 45 |
} |
| 46 |
|
| 47 |
bool isNonTrivialEqual(const Component& other) const { |
| 48 |
return unresolvedNonTrivialComponents() == other.unresolvedNonTrivialComponents(); |
| 49 |
} |
| 50 |
|
| 51 |
private: |
| 52 |
Obj<float, 4> m_components; |
| 53 |
Obj<NonTrivial, 4> m_nonTrivialComponents; |
| 54 |
}; |
| 55 |
|
| 56 |
Component* provide(); |
| 57 |
bool someFunction(Component* other) { |
| 58 |
return provide()->isEqual(*other); |
| 59 |
} |
| 60 |
|
| 61 |
bool otherFunction(Component* other) { |
| 62 |
return provide()->isNonTrivialEqual(*other); |
| 63 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 64 |
} |