================
@@ -1153,26 +1153,30 @@ auto buildDiagnoseMatchSwitch(
// FIXME: Evaluate the efficiency of matchers. If using matchers results in a
// lot of duplicated work (e.g. string comparisons), consider providing APIs
// that avoid it through memoization.
- auto IgnorableOptional = ignorableOptional(Options);
- return CFGMatchSwitchBuilder<
- const Environment,
- llvm::SmallVector<UncheckedOptionalAccessDiagnostic>>()
- // optional::value
- .CaseOfCFGStmt<CXXMemberCallExpr>(
- valueCall(IgnorableOptional),
- [](const CXXMemberCallExpr *E, const MatchFinder::MatchResult &,
- const Environment &Env) {
- return diagnoseUnwrapCall(E->getImplicitObjectArgument(), Env);
- })
+ const auto IgnorableOptional = ignorableOptional(Options);
+
+ auto Builder = CFGMatchSwitchBuilder<
+ const Environment,
+ llvm::SmallVector<UncheckedOptionalAccessDiagnostic>>()
+ .CaseOfCFGStmt<CallExpr>(
+ valueOperatorCall(IgnorableOptional),
+ [](const CallExpr *E, const MatchFinder::MatchResult
&,
+ const Environment &Env) {
+ return diagnoseUnwrapCall(E->getArg(0), Env);
+ });
+
+ if (!Options.IgnoreValueCalls) {
+ return std::move(Builder)
----------------
vbvictor wrote:
Could we not return here but only add one more `CaseOfCFGStmt` and return only
once at the end of the function?
The rationale is if we are to add completely new `CaseOfCFGStmt` to builder,
then we would need to modify both returns or make more transformations.
Be better leave code in flexible way to change in the future
https://github.com/llvm/llvm-project/pull/167209
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits