29 auto HasStatusOrCallDescendant =
30 hasDescendant(callExpr(callee(cxxMethodDecl(ofClass(hasAnyName(
31 "absl::StatusOr",
"absl::internal_statusor::OperatorBase"))))));
32 Finder->addMatcher(functionDecl(unless(isExpansionInSystemHeader()),
33 hasBody(HasStatusOrCallDescendant))
37 cxxConstructorDecl(hasAnyConstructorInitializer(
38 withInitializer(HasStatusOrCallDescendant)))
44 const MatchFinder::MatchResult &Result) {
45 if (Result.SourceManager->getDiagnostics().hasUncompilableErrorOccurred())
48 const auto *
FuncDecl = Result.Nodes.getNodeAs<FunctionDecl>(
FuncID);
52 UncheckedStatusOrAccessDiagnoser Diagnoser;
53 if (llvm::Expected<llvm::SmallVector<SourceLocation>> Locs =
54 dataflow::diagnoseFunction<UncheckedStatusOrAccessModel,
55 SourceLocation>(*
FuncDecl, *Result.Context,
57 for (
const SourceLocation &Loc : *Locs)
58 diag(Loc,
"unchecked access to 'absl::StatusOr' value");
60 llvm::consumeError(Locs.takeError());