@@ -1155,26 +1155,30 @@ auto buildDiagnoseMatchSwitch(
11551155 // that avoid it through memoization.
11561156 const auto IgnorableOptional = ignorableOptional (Options);
11571157
1158- auto Builder = CFGMatchSwitchBuilder<
1159- const Environment,
1160- llvm::SmallVector<UncheckedOptionalAccessDiagnostic>>()
1161- .CaseOfCFGStmt <CallExpr>(
1162- valueOperatorCall (IgnorableOptional),
1163- [](const CallExpr *E, const MatchFinder::MatchResult &,
1164- const Environment &Env) {
1165- return diagnoseUnwrapCall (E->getArg (0 ), Env);
1166- });
1167-
1168- if (!Options.IgnoreValueCalls ) {
1169- return std::move (Builder)
1170- .CaseOfCFGStmt <CXXMemberCallExpr>(
1171- valueCall (IgnorableOptional),
1172- [](const CXXMemberCallExpr *E, const MatchFinder::MatchResult &,
1173- const Environment &Env) {
1174- return diagnoseUnwrapCall (E->getImplicitObjectArgument (), Env);
1175- })
1176- .Build ();
1177- }
1158+ auto DiagBuilder =
1159+ CFGMatchSwitchBuilder<
1160+ const Environment,
1161+ llvm::SmallVector<UncheckedOptionalAccessDiagnostic>>()
1162+ // optional::operator*, optional::operator->
1163+ .CaseOfCFGStmt <CallExpr>(
1164+ valueOperatorCall (IgnorableOptional),
1165+ [](const CallExpr *E, const MatchFinder::MatchResult &,
1166+ const Environment &Env) {
1167+ return diagnoseUnwrapCall (E->getArg (0 ), Env);
1168+ });
1169+
1170+ auto Builder = Options.IgnoreValueCalls
1171+ ? std::move (DiagBuilder)
1172+ : std::move (DiagBuilder)
1173+ // optional::value
1174+ .CaseOfCFGStmt <CXXMemberCallExpr>(
1175+ valueCall (IgnorableOptional),
1176+ [](const CXXMemberCallExpr *E,
1177+ const MatchFinder::MatchResult &,
1178+ const Environment &Env) {
1179+ return diagnoseUnwrapCall (
1180+ E->getImplicitObjectArgument (), Env);
1181+ });
11781182
11791183 return std::move (Builder).Build ();
11801184}
0 commit comments