1 // RUN: %clang_analyze_cc1 -analyzer-checker=webkit.UncountedLambdaCapturesChecker %s 2>&1 | FileCheck %s --strict-whitespace
2 #include "mock-types.h"
5 RefCountable
* ref_countable
= nullptr;
6 auto foo1
= [ref_countable
](){};
7 // CHECK: warning: Captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
8 // CHECK-NEXT:{{^ 6 | }} auto foo1 = [ref_countable](){};
9 // CHECK-NEXT:{{^ | }} ^
10 auto foo2
= [&ref_countable
](){};
11 // CHECK: warning: Captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
12 auto foo3
= [&](){ ref_countable
= nullptr; };
13 // CHECK: warning: Implicitly captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
14 // CHECK-NEXT:{{^ 12 | }} auto foo3 = [&](){ ref_countable = nullptr; };
15 // CHECK-NEXT:{{^ | }} ^
16 auto foo4
= [=](){ (void) ref_countable
; };
17 // CHECK: warning: Implicitly captured raw-pointer 'ref_countable' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
21 RefCountable automatic
;
22 RefCountable
& ref_countable_ref
= automatic
;
24 auto foo1
= [ref_countable_ref
](){};
25 // CHECK: warning: Captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
26 auto foo2
= [&ref_countable_ref
](){};
27 // CHECK: warning: Captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
28 auto foo3
= [&](){ (void) ref_countable_ref
; };
29 // CHECK: warning: Implicitly captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
30 auto foo4
= [=](){ (void) ref_countable_ref
; };
31 // CHECK: warning: Implicitly captured reference 'ref_countable_ref' to uncounted type is unsafe [webkit.UncountedLambdaCapturesChecker]
35 // This code is not expected to trigger any warnings.
37 RefCountable automatic
;
38 RefCountable
&ref_countable_ref
= automatic
;
43 RefCountable
*ref_countable
= nullptr;