[nullability] Smart pointers: Implement `weak_ptr::lock()`. This is the one `weak_ptr` operation that we do want to implement, as we want the analysis to "know" that the return value of `lock()` is nullable and therefore needs to be checked. PiperOrigin-RevId: 590464166 Change-Id: I48c5f43ca235273e82f425ec0e966d0fd8136e11
diff --git a/nullability/pointer_nullability_matchers.cc b/nullability/pointer_nullability_matchers.cc index 2006237..dc75724 100644 --- a/nullability/pointer_nullability_matchers.cc +++ b/nullability/pointer_nullability_matchers.cc
@@ -26,6 +26,7 @@ using ast_matchers::cxxMemberCallExpr; using ast_matchers::cxxMethodDecl; using ast_matchers::cxxOperatorCallExpr; +using ast_matchers::cxxRecordDecl; using ast_matchers::cxxThisExpr; using ast_matchers::decl; using ast_matchers::expr; @@ -159,6 +160,12 @@ hasType(isNullPtrType())))); } +Matcher<Stmt> isWeakPtrLockCall() { + return cxxMemberCallExpr( + thisPointerType(cxxRecordDecl(isInStdNamespace(), hasName("weak_ptr"))), + callee(cxxMethodDecl(hasName("lock")))); +} + Matcher<Stmt> isSupportedPointerAccessorCall() { return cxxMemberCallExpr(callee(cxxMethodDecl(hasBody(compoundStmt( statementCountIs(1),