| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s |
| 2 |
|
| 3 |
#include "mock-types.h" |
| 4 |
#include "mock-system-header.h" |
| 5 |
|
| 6 |
void WTFBreakpointTrap(); |
| 7 |
void WTFCrashWithInfo(int, const char*, const char*, int); |
| 8 |
void WTFReportAssertionFailure(const char* file, int line, const char* function, const char* assertion); |
| 9 |
|
| 10 |
void WTFCrash(void); |
| 11 |
void WTFCrashWithSecurityImplication(void); |
| 12 |
|
| 13 |
inline void compilerFenceForCrash() |
| 14 |
{ |
| 15 |
asm volatile("" ::: "memory"); |
| 16 |
} |
| 17 |
|
| 18 |
inline void isIntegralOrPointerType() { } |
| 19 |
|
| 20 |
template<typename T, typename... Types> |
| 21 |
void isIntegralOrPointerType(T, Types... types) |
| 22 |
{ |
| 23 |
static_assert(sizeof(char) < sizeof(short), "All types need to be bitwise_cast-able to integral type for logging"); |
| 24 |
isIntegralOrPointerType(types...); |
| 25 |
} |
| 26 |
|
| 27 |
#define CRASH_WITH_INFO(...) do { \ |
| 28 |
isIntegralOrPointerType(__VA_ARGS__); \ |
| 29 |
compilerFenceForCrash(); \ |
| 30 |
WTFBreakpointTrap(); \ |
| 31 |
__builtin_unreachable(); \ |
| 32 |
} while (0) |
| 33 |
|
| 34 |
#define RELEASE_ASSERT(assertion, ...) do { \ |
| 35 |
if (!(assertion)) \ |
| 36 |
CRASH_WITH_INFO(__VA_ARGS__); \ |
| 37 |
} while (0) |
| 38 |
|
| 39 |
#define ASSERT(assertion, ...) do { \ |
| 40 |
if (!(assertion)) { \ |
| 41 |
WTFReportAssertionFailure(__FILE__, __LINE__, __PRETTY_FUNCTION__, #assertion); \ |
| 42 |
CRASH_WITH_INFO(__VA_ARGS__); \ |
| 43 |
} \ |
| 44 |
} while (0) |
| 45 |
|
| 46 |
#if !defined(ALWAYS_INLINE) |
| 47 |
#define ALWAYS_INLINE inline |
| 48 |
#endif |
| 49 |
|
| 50 |
void WTFCrashWithInfoImpl(int line, const char* file, const char* function, int counter, unsigned long reason); |
| 51 |
void WTFCrashWithInfo(int line, const char* file, const char* function, int counter); |
| 52 |
|
| 53 |
template<typename T> |
| 54 |
ALWAYS_INLINE unsigned long wtfCrashArg(T* arg) { return reinterpret_cast<unsigned long>(arg); } |
| 55 |
|
| 56 |
template<typename T> |
| 57 |
ALWAYS_INLINE unsigned long wtfCrashArg(T arg) { return arg; } |
| 58 |
|
| 59 |
template<typename T> |
| 60 |
void WTFCrashWithInfo(int line, const char* file, const char* function, int counter, T reason) |
| 61 |
{ |
| 62 |
WTFCrashWithInfoImpl(line, file, function, counter, wtfCrashArg(reason)); |
| 63 |
} |
| 64 |
|
| 65 |
template<typename ToType, typename FromType> |
| 66 |
ToType bitwise_cast(FromType from); |
| 67 |
|
| 68 |
namespace std { |
| 69 |
|
| 70 |
template<typename T> |
| 71 |
T* addressof(T& arg); |
| 72 |
|
| 73 |
template<typename T> |
| 74 |
T&& forward(T& arg); |
| 75 |
|
| 76 |
template<typename T> |
| 77 |
T&& move( T&& t ); |
| 78 |
|
| 79 |
} // namespace std |
| 80 |
|
| 81 |
bool isMainThread(); |
| 82 |
bool isMainThreadOrGCThread(); |
| 83 |
bool isMainRunLoop(); |
| 84 |
bool isWebThread(); |
| 85 |
bool isUIThread(); |
| 86 |
bool mayBeGCThread(); |
| 87 |
|
| 88 |
enum class Flags : unsigned short { |
| 89 |
Flag1 = 1 << 0, |
| 90 |
Flag2 = 1 << 1, |
| 91 |
Flag3 = 1 << 2, |
| 92 |
}; |
| 93 |
|
| 94 |
template<typename E> class OptionSet { |
| 95 |
public: |
| 96 |
using StorageType = unsigned short; |
| 97 |
|
| 98 |
static constexpr OptionSet fromRaw(StorageType rawValue) { |
| 99 |
return OptionSet(static_cast<E>(rawValue), FromRawValue); |
| 100 |
} |
| 101 |
|
| 102 |
constexpr OptionSet() = default; |
| 103 |
|
| 104 |
constexpr OptionSet(E e) |
| 105 |
: m_storage(static_cast<StorageType>(e)) { |
| 106 |
} |
| 107 |
|
| 108 |
constexpr StorageType toRaw() const { return m_storage; } |
| 109 |
|
| 110 |
constexpr bool isEmpty() const { return !m_storage; } |
| 111 |
|
| 112 |
constexpr explicit operator bool() const { return !isEmpty(); } |
| 113 |
|
| 114 |
constexpr bool contains(E option) const { return containsAny(option); } |
| 115 |
constexpr bool containsAny(OptionSet optionSet) const { |
| 116 |
return !!(*this & optionSet); |
| 117 |
} |
| 118 |
|
| 119 |
constexpr bool containsAll(OptionSet optionSet) const { |
| 120 |
return (*this & optionSet) == optionSet; |
| 121 |
} |
| 122 |
|
| 123 |
constexpr void add(OptionSet optionSet) { m_storage |= optionSet.m_storage; } |
| 124 |
|
| 125 |
constexpr void remove(OptionSet optionSet) |
| 126 |
{ |
| 127 |
m_storage &= ~optionSet.m_storage; |
| 128 |
} |
| 129 |
|
| 130 |
constexpr void set(OptionSet optionSet, bool value) |
| 131 |
{ |
| 132 |
if (value) |
| 133 |
add(optionSet); |
| 134 |
else |
| 135 |
remove(optionSet); |
| 136 |
} |
| 137 |
|
| 138 |
constexpr friend OptionSet operator|(OptionSet lhs, OptionSet rhs) { |
| 139 |
return fromRaw(lhs.m_storage | rhs.m_storage); |
| 140 |
} |
| 141 |
|
| 142 |
constexpr friend OptionSet operator&(OptionSet lhs, OptionSet rhs) { |
| 143 |
return fromRaw(lhs.m_storage & rhs.m_storage); |
| 144 |
} |
| 145 |
|
| 146 |
constexpr friend OptionSet operator-(OptionSet lhs, OptionSet rhs) { |
| 147 |
return fromRaw(lhs.m_storage & ~rhs.m_storage); |
| 148 |
} |
| 149 |
|
| 150 |
constexpr friend OptionSet operator^(OptionSet lhs, OptionSet rhs) { |
| 151 |
return fromRaw(lhs.m_storage ^ rhs.m_storage); |
| 152 |
} |
| 153 |
|
| 154 |
private: |
| 155 |
enum InitializationTag { FromRawValue }; |
| 156 |
constexpr OptionSet(E e, InitializationTag) |
| 157 |
: m_storage(static_cast<StorageType>(e)) { |
| 158 |
} |
| 159 |
StorageType m_storage { 0 }; |
| 160 |
}; |
| 161 |
|
| 162 |
int atoi(const char* str); |
| 163 |
|
| 164 |
class Number { |
| 165 |
public: |
| 166 |
Number(int v) : v(v) { } |
| 167 |
Number(double); |
| 168 |
Number(const char* str) : v(atoi(str)) { } |
| 169 |
Number operator+(const Number&); |
| 170 |
Number& operator++() { ++v; return *this; } |
| 171 |
Number operator++(int) { Number returnValue(v); ++v; return returnValue; } |
| 172 |
const int& value() const { return v; } |
| 173 |
void someMethod(); |
| 174 |
|
| 175 |
private: |
| 176 |
int v; |
| 177 |
}; |
| 178 |
|
| 179 |
class DerivedNumber : public Number { |
| 180 |
public: |
| 181 |
DerivedNumber(char c) : Number(c - '0') { } |
| 182 |
DerivedNumber(const char* str) : Number(atoi(str)) { } |
| 183 |
}; |
| 184 |
|
| 185 |
class ComplexNumber { |
| 186 |
public: |
| 187 |
ComplexNumber() : realPart(0), complexPart(0) { } |
| 188 |
ComplexNumber(int real, const char* str) : realPart(real), complexPart(str) { } |
| 189 |
ComplexNumber(const ComplexNumber&); |
| 190 |
ComplexNumber& operator++() { realPart.someMethod(); return *this; } |
| 191 |
ComplexNumber operator++(int); |
| 192 |
ComplexNumber& operator<<(int); |
| 193 |
ComplexNumber& operator+(); |
| 194 |
|
| 195 |
const Number& real() const { return realPart; } |
| 196 |
|
| 197 |
private: |
| 198 |
Number realPart; |
| 199 |
Number complexPart; |
| 200 |
}; |
| 201 |
|
| 202 |
class ObjectWithNonTrivialDestructor { |
| 203 |
public: |
| 204 |
ObjectWithNonTrivialDestructor() { } |
| 205 |
ObjectWithNonTrivialDestructor(unsigned v) : v(v) { } |
| 206 |
~ObjectWithNonTrivialDestructor() { } |
| 207 |
|
| 208 |
unsigned value() const { return v; } |
| 209 |
|
| 210 |
private: |
| 211 |
unsigned v { 0 }; |
| 212 |
}; |
| 213 |
|
| 214 |
class ObjectWithMutatingDestructor { |
| 215 |
public: |
| 216 |
ObjectWithMutatingDestructor() : n(0) { } |
| 217 |
ObjectWithMutatingDestructor(int n) : n(n) { } |
| 218 |
~ObjectWithMutatingDestructor() { n.someMethod(); } |
| 219 |
|
| 220 |
unsigned value() const { return n.value(); } |
| 221 |
|
| 222 |
private: |
| 223 |
Number n; |
| 224 |
}; |
| 225 |
|
| 226 |
class RefCounted { |
| 227 |
public: |
| 228 |
void ref() const; |
| 229 |
void deref() const; |
| 230 |
|
| 231 |
void method(); |
| 232 |
void someFunction(); |
| 233 |
int otherFunction(); |
| 234 |
unsigned recursiveTrivialFunction(int n) { return !n ? 1 : recursiveTrivialFunction(n - 1); } |
| 235 |
unsigned recursiveComplexFunction(int n) { return !n ? otherFunction() : recursiveComplexFunction(n - 1); } |
| 236 |
unsigned mutuallyRecursiveFunction1(int n) { return n < 0 ? 1 : (n % 2 ? mutuallyRecursiveFunction2(n - 2) : mutuallyRecursiveFunction1(n - 1)); } |
| 237 |
unsigned mutuallyRecursiveFunction2(int n) { return n < 0 ? 1 : (n % 3 ? mutuallyRecursiveFunction2(n - 3) : mutuallyRecursiveFunction1(n - 2)); } |
| 238 |
unsigned mutuallyRecursiveFunction3(int n) { return n < 0 ? 1 : (n % 5 ? mutuallyRecursiveFunction3(n - 5) : mutuallyRecursiveFunction4(n - 3)); } |
| 239 |
unsigned mutuallyRecursiveFunction4(int n) { return n < 0 ? 1 : (n % 7 ? otherFunction() : mutuallyRecursiveFunction3(n - 3)); } |
| 240 |
unsigned recursiveFunction5(unsigned n) { return n > 100 ? 2 : (n % 2 ? recursiveFunction5(n + 1) : recursiveFunction6(n + 2)); } |
| 241 |
unsigned recursiveFunction6(unsigned n) { return n > 100 ? 3 : (n % 2 ? recursiveFunction6(n % 7) : recursiveFunction7(n % 5)); } |
| 242 |
unsigned recursiveFunction7(unsigned n) { return n > 100 ? 5 : recursiveFunction7(n * 5); } |
| 243 |
|
| 244 |
void mutuallyRecursive8() { mutuallyRecursive9(); someFunction(); } |
| 245 |
void mutuallyRecursive9() { mutuallyRecursive8(); } |
| 246 |
|
| 247 |
int trivial1() { return 123; } |
| 248 |
float trivial2() { return 0.3; } |
| 249 |
float trivial3() { return (float)0.4; } |
| 250 |
float trivial4() { return 0.5f; } |
| 251 |
char trivial5() { return 'a'; } |
| 252 |
const char *trivial6() { return "abc"; } |
| 253 |
int trivial7() { return (1); } |
| 254 |
Number trivial8() { return Number { 5 }; } |
| 255 |
int trivial9() { return 3 + 4; } |
| 256 |
int trivial10() { return 0x1010 | 0x1; } |
| 257 |
int trivial11(int v) { return v + 1; } |
| 258 |
const char *trivial12(char *p) { return p ? "str" : "null"; } |
| 259 |
int trivial13(int v) { |
| 260 |
if (v) |
| 261 |
return 123; |
| 262 |
else |
| 263 |
return 0; |
| 264 |
} |
| 265 |
int trivial14(int v) { |
| 266 |
switch (v) { |
| 267 |
case 1: |
| 268 |
return 100; |
| 269 |
case 2: |
| 270 |
return 200; |
| 271 |
default: |
| 272 |
return 300; |
| 273 |
} |
| 274 |
return 0; |
| 275 |
} |
| 276 |
void *trivial15() { return static_cast<void*>(this); } |
| 277 |
unsigned long trivial16() { return *reinterpret_cast<unsigned long*>(this); } |
| 278 |
RefCounted& trivial17() const { return const_cast<RefCounted&>(*this); } |
| 279 |
RefCounted& trivial18() const { RELEASE_ASSERT(this, "this must be not null"); return const_cast<RefCounted&>(*this); } |
| 280 |
void trivial19() const { return; } |
| 281 |
|
| 282 |
static constexpr unsigned numBits = 4; |
| 283 |
int trivial20() { return v >> numBits; } |
| 284 |
|
| 285 |
const int* trivial21() { return number ? &number->value() : nullptr; } |
| 286 |
|
| 287 |
enum class Enum : unsigned short { |
| 288 |
Value1 = 1, |
| 289 |
Value2 = 2, |
| 290 |
}; |
| 291 |
bool trivial22() { return enumValue == Enum::Value1; } |
| 292 |
|
| 293 |
bool trivial23() const { return OptionSet<Flags>::fromRaw(v).contains(Flags::Flag1); } |
| 294 |
int trivial24() const { ASSERT(v); return v; } |
| 295 |
unsigned trivial25() const { return __c11_atomic_load((volatile _Atomic(unsigned) *)&v, __ATOMIC_RELAXED); } |
| 296 |
bool trivial26() { bool hasValue = v; return !hasValue; } |
| 297 |
bool trivial27(int v) { bool value; value = v ? 1 : 0; return value; } |
| 298 |
bool trivial28() { return true; } |
| 299 |
bool trivial29() { return false; } |
| 300 |
unsigned trivial30(unsigned v) { unsigned r = 0xff; r |= v; return r; } |
| 301 |
int trivial31(int* v) { return v[0]; } |
| 302 |
unsigned trivial32() { return sizeof(int); } |
| 303 |
unsigned trivial33() { return ~0xff; } |
| 304 |
template <unsigned v> unsigned trivial34() { return v; } |
| 305 |
void trivial35() { v++; } |
| 306 |
void trivial36() { ++(*number); } |
| 307 |
void trivial37() { (*number)++; } |
| 308 |
void trivial38() { v++; if (__builtin_expect(!!(number), 1)) (*number)++; } |
| 309 |
int trivial39() { return -v; } |
| 310 |
int trivial40() { return v << 2; } |
| 311 |
unsigned trivial41() { v = ++s_v; return v; } |
| 312 |
unsigned trivial42() { return bitwise_cast<unsigned long>(nullptr); } |
| 313 |
Number* trivial43() { return std::addressof(*number); } |
| 314 |
Number* trivial44() { return new Number(1); } |
| 315 |
ComplexNumber* trivial45() { return new ComplexNumber(); } |
| 316 |
void trivial46() { ASSERT(isMainThread()); } |
| 317 |
void trivial47() { ASSERT(isMainThreadOrGCThread()); } |
| 318 |
void trivial48() { ASSERT(isMainRunLoop()); } |
| 319 |
void trivial49() { ASSERT(isWebThread()); } |
| 320 |
void trivial50() { ASSERT(isUIThread()); } |
| 321 |
void trivial51() { ASSERT(mayBeGCThread()); } |
| 322 |
void trivial52() { WTFCrash(); } |
| 323 |
void trivial53() { WTFCrashWithSecurityImplication(); } |
| 324 |
unsigned trivial54() { return ComplexNumber().real().value(); } |
| 325 |
Number&& trivial55() { return std::forward(*number); } |
| 326 |
unsigned trivial56() { Number n { 5 }; return std::move(n).value(); } |
| 327 |
void trivial57() { do { break; } while (1); } |
| 328 |
void trivial58() { do { continue; } while (0); } |
| 329 |
void trivial59() { |
| 330 |
do { goto label; } |
| 331 |
while (0); |
| 332 |
label: |
| 333 |
return; |
| 334 |
} |
| 335 |
unsigned trivial60() { return ObjectWithNonTrivialDestructor { 5 }.value(); } |
| 336 |
unsigned trivial61() { return DerivedNumber('7').value(); } |
| 337 |
|
| 338 |
static RefCounted& singleton() { |
| 339 |
static RefCounted s_RefCounted; |
| 340 |
s_RefCounted.ref(); |
| 341 |
return s_RefCounted; |
| 342 |
} |
| 343 |
|
| 344 |
Number nonTrivial1() { return Number(3) + Number(4); } |
| 345 |
Number nonTrivial2() { return Number { 0.3 }; } |
| 346 |
int nonTrivial3() { return v ? otherFunction() : 0; } |
| 347 |
int nonTrivial4() { |
| 348 |
if (v) |
| 349 |
return 8; |
| 350 |
else |
| 351 |
return otherFunction(); |
| 352 |
} |
| 353 |
|
| 354 |
int nonTrivial5() { |
| 355 |
if (v) |
| 356 |
return otherFunction(); |
| 357 |
else |
| 358 |
return 9; |
| 359 |
} |
| 360 |
|
| 361 |
int nonTrivial6() { |
| 362 |
if (otherFunction()) |
| 363 |
return 1; |
| 364 |
else |
| 365 |
return 0; |
| 366 |
} |
| 367 |
|
| 368 |
int nonTrivial7() { |
| 369 |
switch (v) { |
| 370 |
case 1: |
| 371 |
return otherFunction(); |
| 372 |
default: |
| 373 |
return 7; |
| 374 |
} |
| 375 |
} |
| 376 |
|
| 377 |
int nonTrivial8() { |
| 378 |
switch (v) { |
| 379 |
case 1: |
| 380 |
return 9; |
| 381 |
default: |
| 382 |
return otherFunction(); |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
int nonTrivial9() { |
| 387 |
switch (otherFunction()) { |
| 388 |
case 0: |
| 389 |
return -1; |
| 390 |
default: |
| 391 |
return 12; |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
static unsigned* another(); |
| 396 |
unsigned nonTrivial10() const { |
| 397 |
return __c11_atomic_load((volatile _Atomic(unsigned) *)another(), __ATOMIC_RELAXED); |
| 398 |
} |
| 399 |
|
| 400 |
void nonTrivial11() { |
| 401 |
Number num(0.3); |
| 402 |
} |
| 403 |
|
| 404 |
bool nonTrivial12() { |
| 405 |
bool val = otherFunction(); |
| 406 |
return val; |
| 407 |
} |
| 408 |
|
| 409 |
int nonTrivial13() { return ~otherFunction(); } |
| 410 |
int nonTrivial14() { int r = 0xff; r |= otherFunction(); return r; } |
| 411 |
void nonTrivial15() { ++complex; } |
| 412 |
void nonTrivial16() { complex++; } |
| 413 |
ComplexNumber nonTrivial17() { return complex << 2; } |
| 414 |
ComplexNumber nonTrivial18() { return +complex; } |
| 415 |
ComplexNumber* nonTrivial19() { return new ComplexNumber(complex); } |
| 416 |
unsigned nonTrivial20() { return ObjectWithMutatingDestructor { 7 }.value(); } |
| 417 |
unsigned nonTrivial21() { return Number("123").value(); } |
| 418 |
unsigned nonTrivial22() { return ComplexNumber(123, "456").real().value(); } |
| 419 |
unsigned nonTrivial23() { return DerivedNumber("123").value(); } |
| 420 |
|
| 421 |
static unsigned s_v; |
| 422 |
unsigned v { 0 }; |
| 423 |
Number* number { nullptr }; |
| 424 |
ComplexNumber complex; |
| 425 |
Enum enumValue { Enum::Value1 }; |
| 426 |
}; |
| 427 |
|
| 428 |
unsigned RefCounted::s_v = 0; |
| 429 |
|
| 430 |
RefCounted* refCountedObj(); |
| 431 |
|
| 432 |
void test() |
| 433 |
{ |
| 434 |
refCountedObj()->someFunction(); |
| 435 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 436 |
} |
| 437 |
|
| 438 |
class UnrelatedClass { |
| 439 |
RefPtr<RefCounted> Field; |
| 440 |
bool value; |
| 441 |
|
| 442 |
public: |
| 443 |
RefCounted &getFieldTrivial() { return *Field.get(); } |
| 444 |
RefCounted *getFieldTernary() { return value ? Field.get() : nullptr; } |
| 445 |
|
| 446 |
void test() { |
| 447 |
getFieldTrivial().trivial1(); // no-warning |
| 448 |
getFieldTrivial().trivial2(); // no-warning |
| 449 |
getFieldTrivial().trivial3(); // no-warning |
| 450 |
getFieldTrivial().trivial4(); // no-warning |
| 451 |
getFieldTrivial().trivial5(); // no-warning |
| 452 |
getFieldTrivial().trivial6(); // no-warning |
| 453 |
getFieldTrivial().trivial7(); // no-warning |
| 454 |
getFieldTrivial().trivial8(); // no-warning |
| 455 |
getFieldTrivial().trivial9(); // no-warning |
| 456 |
getFieldTrivial().trivial10(); // no-warning |
| 457 |
getFieldTrivial().trivial11(1); // no-warning |
| 458 |
getFieldTrivial().trivial12(nullptr); // no-warning |
| 459 |
getFieldTrivial().trivial13(0); // no-warning |
| 460 |
getFieldTrivial().trivial14(3); // no-warning |
| 461 |
getFieldTrivial().trivial15(); // no-warning |
| 462 |
getFieldTrivial().trivial16(); // no-warning |
| 463 |
getFieldTrivial().trivial17(); // no-warning |
| 464 |
getFieldTrivial().trivial18(); // no-warning |
| 465 |
getFieldTrivial().trivial19(); // no-warning |
| 466 |
getFieldTrivial().trivial20(); // no-warning |
| 467 |
getFieldTrivial().trivial21(); // no-warning |
| 468 |
getFieldTrivial().trivial22(); // no-warning |
| 469 |
getFieldTrivial().trivial23(); // no-warning |
| 470 |
getFieldTrivial().trivial24(); // no-warning |
| 471 |
getFieldTrivial().trivial25(); // no-warning |
| 472 |
getFieldTrivial().trivial26(); // no-warning |
| 473 |
getFieldTrivial().trivial27(5); // no-warning |
| 474 |
getFieldTrivial().trivial28(); // no-warning |
| 475 |
getFieldTrivial().trivial29(); // no-warning |
| 476 |
getFieldTrivial().trivial30(7); // no-warning |
| 477 |
int a[] = {1, 2}; |
| 478 |
getFieldTrivial().trivial31(a); // no-warning |
| 479 |
getFieldTrivial().trivial32(); // no-warning |
| 480 |
getFieldTrivial().trivial33(); // no-warning |
| 481 |
getFieldTrivial().trivial34<7>(); // no-warning |
| 482 |
getFieldTrivial().trivial35(); // no-warning |
| 483 |
getFieldTrivial().trivial36(); // no-warning |
| 484 |
getFieldTrivial().trivial37(); // no-warning |
| 485 |
getFieldTrivial().trivial38(); // no-warning |
| 486 |
getFieldTrivial().trivial39(); // no-warning |
| 487 |
getFieldTrivial().trivial40(); // no-warning |
| 488 |
getFieldTrivial().trivial41(); // no-warning |
| 489 |
getFieldTrivial().trivial42(); // no-warning |
| 490 |
getFieldTrivial().trivial43(); // no-warning |
| 491 |
getFieldTrivial().trivial44(); // no-warning |
| 492 |
getFieldTrivial().trivial45(); // no-warning |
| 493 |
getFieldTrivial().trivial46(); // no-warning |
| 494 |
getFieldTrivial().trivial47(); // no-warning |
| 495 |
getFieldTrivial().trivial48(); // no-warning |
| 496 |
getFieldTrivial().trivial49(); // no-warning |
| 497 |
getFieldTrivial().trivial50(); // no-warning |
| 498 |
getFieldTrivial().trivial51(); // no-warning |
| 499 |
getFieldTrivial().trivial52(); // no-warning |
| 500 |
getFieldTrivial().trivial53(); // no-warning |
| 501 |
getFieldTrivial().trivial54(); // no-warning |
| 502 |
getFieldTrivial().trivial55(); // no-warning |
| 503 |
getFieldTrivial().trivial56(); // no-warning |
| 504 |
getFieldTrivial().trivial57(); // no-warning |
| 505 |
getFieldTrivial().trivial58(); // no-warning |
| 506 |
getFieldTrivial().trivial59(); // no-warning |
| 507 |
getFieldTrivial().trivial60(); // no-warning |
| 508 |
getFieldTrivial().trivial61(); // no-warning |
| 509 |
|
| 510 |
RefCounted::singleton().trivial18(); // no-warning |
| 511 |
RefCounted::singleton().someFunction(); // no-warning |
| 512 |
|
| 513 |
getFieldTrivial().recursiveTrivialFunction(7); // no-warning |
| 514 |
getFieldTrivial().recursiveComplexFunction(9); |
| 515 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 516 |
getFieldTrivial().mutuallyRecursiveFunction1(11); // no-warning |
| 517 |
getFieldTrivial().mutuallyRecursiveFunction2(13); // no-warning |
| 518 |
getFieldTrivial().mutuallyRecursiveFunction3(17); |
| 519 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 520 |
getFieldTrivial().mutuallyRecursiveFunction4(19); |
| 521 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 522 |
getFieldTrivial().recursiveFunction5(23); // no-warning |
| 523 |
getFieldTrivial().recursiveFunction6(29); // no-warning |
| 524 |
getFieldTrivial().recursiveFunction7(31); // no-warning |
| 525 |
|
| 526 |
getFieldTrivial().mutuallyRecursive8(); |
| 527 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 528 |
getFieldTrivial().mutuallyRecursive9(); |
| 529 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 530 |
|
| 531 |
getFieldTrivial().someFunction(); |
| 532 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 533 |
getFieldTrivial().nonTrivial1(); |
| 534 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 535 |
getFieldTrivial().nonTrivial2(); |
| 536 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 537 |
getFieldTrivial().nonTrivial3(); |
| 538 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 539 |
getFieldTrivial().nonTrivial4(); |
| 540 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 541 |
getFieldTrivial().nonTrivial5(); |
| 542 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 543 |
getFieldTrivial().nonTrivial6(); |
| 544 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 545 |
getFieldTrivial().nonTrivial7(); |
| 546 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 547 |
getFieldTrivial().nonTrivial8(); |
| 548 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 549 |
getFieldTrivial().nonTrivial9(); |
| 550 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 551 |
getFieldTrivial().nonTrivial10(); |
| 552 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 553 |
getFieldTrivial().nonTrivial11(); |
| 554 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 555 |
getFieldTrivial().nonTrivial12(); |
| 556 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 557 |
getFieldTrivial().nonTrivial13(); |
| 558 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 559 |
getFieldTrivial().nonTrivial14(); |
| 560 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 561 |
getFieldTrivial().nonTrivial15(); |
| 562 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 563 |
getFieldTrivial().nonTrivial16(); |
| 564 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 565 |
getFieldTrivial().nonTrivial17(); |
| 566 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 567 |
getFieldTrivial().nonTrivial18(); |
| 568 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 569 |
getFieldTrivial().nonTrivial19(); |
| 570 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 571 |
getFieldTrivial().nonTrivial20(); |
| 572 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 573 |
getFieldTrivial().nonTrivial21(); |
| 574 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 575 |
getFieldTrivial().nonTrivial22(); |
| 576 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 577 |
getFieldTrivial().nonTrivial23(); |
| 578 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 579 |
} |
| 580 |
}; |
| 581 |
|
| 582 |
class UnrelatedClass2 { |
| 583 |
RefPtr<UnrelatedClass> Field; |
| 584 |
|
| 585 |
public: |
| 586 |
UnrelatedClass &getFieldTrivial() { return *Field.get(); } |
| 587 |
RefCounted &getFieldTrivialRecursively() { return getFieldTrivial().getFieldTrivial(); } |
| 588 |
RefCounted *getFieldTrivialTernary() { return Field ? Field->getFieldTernary() : nullptr; } |
| 589 |
|
| 590 |
void test() { |
| 591 |
getFieldTrivialRecursively().trivial1(); // no-warning |
| 592 |
getFieldTrivialTernary()->trivial2(); // no-warning |
| 593 |
getFieldTrivialRecursively().someFunction(); |
| 594 |
// expected-warning@-1{{Call argument for 'this' parameter is uncounted and unsafe}} |
| 595 |
} |
| 596 |
}; |
| 597 |
|
| 598 |
RefPtr<RefCounted> object(); |
| 599 |
void someFunction(const RefCounted&); |
| 600 |
|
| 601 |
void test2() { |
| 602 |
someFunction(*object()); |
| 603 |
} |
| 604 |
|
| 605 |
void system_header() { |
| 606 |
callMethod<RefCountable>(object); |
| 607 |
} |