Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 8 additions & 21 deletions clang/lib/Analysis/ExprMutationAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,34 +55,21 @@ static bool canExprResolveTo(const Expr *Source, const Expr *Target) {
// This is matched by `IgnoreDerivedToBase(canResolveToExpr(InnerMatcher))`
// below.
const auto ConditionalOperatorM = [Target](const Expr *E) {
if (const auto *OP = dyn_cast<ConditionalOperator>(E)) {
if (const auto *TE = OP->getTrueExpr()->IgnoreParens())
if (canExprResolveTo(TE, Target))
return true;
if (const auto *FE = OP->getFalseExpr()->IgnoreParens())
if (canExprResolveTo(FE, Target))
return true;
}
return false;
};

const auto ElvisOperator = [Target](const Expr *E) {
if (const auto *OP = dyn_cast<BinaryConditionalOperator>(E)) {
if (const auto *TE = OP->getTrueExpr()->IgnoreParens())
if (canExprResolveTo(TE, Target))
return true;
if (const auto *FE = OP->getFalseExpr()->IgnoreParens())
if (canExprResolveTo(FE, Target))
return true;
if (const auto *CO = dyn_cast<AbstractConditionalOperator>(E)) {
const auto *TE = CO->getTrueExpr()->IgnoreParens();
if (TE && canExprResolveTo(TE, Target))
return true;
const auto *FE = CO->getFalseExpr()->IgnoreParens();
if (FE && canExprResolveTo(FE, Target))
return true;
}
return false;
};

const Expr *SourceExprP = Source->IgnoreParens();
return IgnoreDerivedToBase(SourceExprP,
[&](const Expr *E) {
return E == Target || ConditionalOperatorM(E) ||
ElvisOperator(E);
return E == Target || ConditionalOperatorM(E);
}) ||
EvalCommaExpr(SourceExprP, [&](const Expr *E) {
return IgnoreDerivedToBase(
Expand Down
Loading