mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1242789 - Allow lambdas to capture raw pointers to refcounted objects by reference, r=ehsan
This commit is contained in:
parent
bfd5b53352
commit
aa2b0131c4
@ -1272,7 +1272,7 @@ void DiagnosticsMatcher::RefCountedInsideLambdaChecker::run(
|
||||
const LambdaExpr *Lambda = Result.Nodes.getNodeAs<LambdaExpr>("lambda");
|
||||
|
||||
for (const LambdaCapture Capture : Lambda->captures()) {
|
||||
if (Capture.capturesVariable()) {
|
||||
if (Capture.capturesVariable() && Capture.getCaptureKind() != LCK_ByRef) {
|
||||
QualType Pointee = Capture.getCapturedVar()->getType()->getPointeeType();
|
||||
|
||||
if (!Pointee.isNull() && isClassRefCounted(Pointee)) {
|
||||
|
@ -21,7 +21,7 @@ void foo() {
|
||||
SmartPtr<R> sp;
|
||||
take([&](R* argptr) {
|
||||
R* localptr;
|
||||
ptr->method(); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
ptr->method();
|
||||
argptr->method();
|
||||
localptr->method();
|
||||
});
|
||||
@ -33,7 +33,7 @@ void foo() {
|
||||
});
|
||||
take([&](R* argptr) {
|
||||
R* localptr;
|
||||
take(ptr); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be captured by a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
take(ptr);
|
||||
take(argptr);
|
||||
take(localptr);
|
||||
});
|
||||
@ -91,4 +91,28 @@ void foo() {
|
||||
take(argsp);
|
||||
take(localsp);
|
||||
});
|
||||
take([&ptr](R* argptr) {
|
||||
R* localptr;
|
||||
ptr->method();
|
||||
argptr->method();
|
||||
localptr->method();
|
||||
});
|
||||
take([&sp](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
sp->method();
|
||||
argsp->method();
|
||||
localsp->method();
|
||||
});
|
||||
take([&ptr](R* argptr) {
|
||||
R* localptr;
|
||||
take(ptr);
|
||||
take(argptr);
|
||||
take(localptr);
|
||||
});
|
||||
take([&sp](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
take(sp);
|
||||
take(argsp);
|
||||
take(localsp);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user