diff options
author | Nathan Huckleberry <nhuck@google.com> | 2019-06-19 18:37:01 +0000 |
---|---|---|
committer | Nathan Huckleberry <nhuck@google.com> | 2019-06-19 18:37:01 +0000 |
commit | 321f902a0122a8b9c28b7b6aae5c8f78e431306d (patch) | |
tree | 3f79b227912f9fbb8356291df82871a51f1336d2 /clang/lib/AST/Expr.cpp | |
parent | f05369768cf005a1743328b5689751585113d8d8 (diff) | |
download | bcm5719-llvm-321f902a0122a8b9c28b7b6aae5c8f78e431306d.tar.gz bcm5719-llvm-321f902a0122a8b9c28b7b6aae5c8f78e431306d.zip |
[AST] Fixed extraneous warnings for binary conditional operator
Summary:
Binary conditional operator gave warnings where ternary operators
did not. They have been fixed to warn similarly to ternary operators.
Link: https://bugs.llvm.org/show_bug.cgi?id=42239
Reviewers: rsmith, aaron.ballman, nickdesaulniers
Reviewed By: rsmith, nickdesaulniers
Subscribers: srhines, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D63369
llvm-svn: 363857
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index f5714d93787..cc92689cb92 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2453,12 +2453,13 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, // If only one of the LHS or RHS is a warning, the operator might // be being used for control flow. Only warn if both the LHS and // RHS are warnings. - const ConditionalOperator *Exp = cast<ConditionalOperator>(this); - if (!Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx)) - return false; - if (!Exp->getLHS()) - return true; - return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx); + const auto *Exp = cast<ConditionalOperator>(this); + return Exp->getLHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx) && + Exp->getRHS()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx); + } + case BinaryConditionalOperatorClass: { + const auto *Exp = cast<BinaryConditionalOperator>(this); + return Exp->getFalseExpr()->isUnusedResultAWarning(WarnE, Loc, R1, R2, Ctx); } case MemberExprClass: |