mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out d952a7d6bfb4 (bug 1170388) on a CLOSED TREE for static analysis bustage. r=bustage
This commit is contained in:
parent
5be7886d40
commit
e90e955195
@ -704,14 +704,8 @@ DiagnosticsMatcher::DiagnosticsMatcher()
|
||||
).bind("node"),
|
||||
&noAddRefReleaseOnReturnChecker);
|
||||
|
||||
// Match declrefs with type "pointer to object of ref-counted type" inside a
|
||||
// lambda, where the declaration they reference is not inside the lambda.
|
||||
// This excludes arguments and local variables, leaving only captured
|
||||
// variables.
|
||||
astMatcher.addMatcher(lambdaExpr(
|
||||
hasDescendant(declRefExpr(hasType(pointerType(pointee(isRefCounted()))),
|
||||
to(decl().bind("decl"))).bind("declref")),
|
||||
unless(hasDescendant(decl(equalsBoundNode("decl"))))
|
||||
hasDescendant(declRefExpr(hasType(pointerType(pointee(isRefCounted())))).bind("node"))
|
||||
),
|
||||
&refCountedInsideLambdaChecker);
|
||||
|
||||
@ -923,14 +917,14 @@ void DiagnosticsMatcher::RefCountedInsideLambdaChecker::run(
|
||||
const MatchFinder::MatchResult &Result) {
|
||||
DiagnosticsEngine &Diag = Result.Context->getDiagnostics();
|
||||
unsigned errorID = Diag.getDiagnosticIDs()->getCustomDiagID(
|
||||
DiagnosticIDs::Error, "Refcounted variable %0 of type %1 cannot be captured by a lambda");
|
||||
DiagnosticIDs::Error, "Refcounted variable %0 of type %1 cannot be used inside a lambda");
|
||||
unsigned noteID = Diag.getDiagnosticIDs()->getCustomDiagID(
|
||||
DiagnosticIDs::Note, "Please consider using a smart pointer");
|
||||
const DeclRefExpr *declref = Result.Nodes.getNodeAs<DeclRefExpr>("declref");
|
||||
const DeclRefExpr *node = Result.Nodes.getNodeAs<DeclRefExpr>("node");
|
||||
|
||||
Diag.Report(declref->getLocStart(), errorID) << declref->getFoundDecl() <<
|
||||
declref->getType()->getPointeeType();
|
||||
Diag.Report(declref->getLocStart(), noteID);
|
||||
Diag.Report(node->getLocStart(), errorID) << node->getFoundDecl() <<
|
||||
node->getType()->getPointeeType();
|
||||
Diag.Report(node->getLocStart(), noteID);
|
||||
}
|
||||
|
||||
void DiagnosticsMatcher::ExplicitOperatorBoolChecker::run(
|
||||
|
@ -19,76 +19,40 @@ void take(...);
|
||||
void foo() {
|
||||
R* ptr;
|
||||
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}}
|
||||
argptr->method();
|
||||
localptr->method();
|
||||
take([&]() {
|
||||
ptr->method(); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be used inside a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
});
|
||||
take([&](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
take([&]() {
|
||||
sp->method();
|
||||
argsp->method();
|
||||
localsp->method();
|
||||
});
|
||||
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(argptr);
|
||||
take(localptr);
|
||||
take([&]() {
|
||||
take(ptr); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be used inside a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
});
|
||||
take([&](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
take([&]() {
|
||||
take(sp);
|
||||
take(argsp);
|
||||
take(localsp);
|
||||
});
|
||||
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}}
|
||||
argptr->method();
|
||||
localptr->method();
|
||||
take([=]() {
|
||||
ptr->method(); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be used inside a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
});
|
||||
take([=](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
take([=]() {
|
||||
sp->method();
|
||||
argsp->method();
|
||||
localsp->method();
|
||||
});
|
||||
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(argptr);
|
||||
take(localptr);
|
||||
take([=]() {
|
||||
take(ptr); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be used inside a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
});
|
||||
take([=](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
take([=]() {
|
||||
take(sp);
|
||||
take(argsp);
|
||||
take(localsp);
|
||||
});
|
||||
take([ptr](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}}
|
||||
argptr->method();
|
||||
localptr->method();
|
||||
take([ptr]() {
|
||||
ptr->method(); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be used inside a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
});
|
||||
take([sp](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
take([sp]() {
|
||||
sp->method();
|
||||
argsp->method();
|
||||
localsp->method();
|
||||
});
|
||||
take([ptr](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(argptr);
|
||||
take(localptr);
|
||||
take([ptr]() {
|
||||
take(ptr); // expected-error{{Refcounted variable 'ptr' of type 'R' cannot be used inside a lambda}} expected-note{{Please consider using a smart pointer}}
|
||||
});
|
||||
take([sp](SmartPtr<R> argsp) {
|
||||
SmartPtr<R> localsp;
|
||||
take([sp]() {
|
||||
take(sp);
|
||||
take(argsp);
|
||||
take(localsp);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user