diff options
author | Richard Trieu <rtrieu@google.com> | 2014-03-11 03:11:08 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2014-03-11 03:11:08 +0000 |
commit | 99e1c9515a54d60838b45054cca09f6f8d7b3dfd (patch) | |
tree | 51a7c9f89cc7228effea484fd3ac0fa305e261fb /clang/lib/AST/Expr.cpp | |
parent | d91747980a97f8f6bc4ae365823d707ba972ef65 (diff) | |
download | bcm5719-llvm-99e1c9515a54d60838b45054cca09f6f8d7b3dfd.tar.gz bcm5719-llvm-99e1c9515a54d60838b45054cca09f6f8d7b3dfd.zip |
Move the warning about unused relational comparison from -Wunused-value to
-Wunused-comparison. Also, newly warn on unused result from overloaded
relational comparisons, now also in -Wunused-comparison.
llvm-svn: 203535
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 0b8948e5fa4..2f5f14f38e3 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -2064,15 +2064,22 @@ bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, return true; case CXXOperatorCallExprClass: { - // We warn about operator== and operator!= even when user-defined operator + // Warn about operator ==,!=,<,>,<=, and >= even when user-defined operator // overloads as there is no reasonable way to define these such that they // have non-trivial, desirable side-effects. See the -Wunused-comparison - // warning: these operators are commonly typo'ed, and so warning on them + // warning: operators == and != are commonly typo'ed, and so warning on them // provides additional value as well. If this list is updated, // DiagnoseUnusedComparison should be as well. const CXXOperatorCallExpr *Op = cast<CXXOperatorCallExpr>(this); - if (Op->getOperator() == OO_EqualEqual || - Op->getOperator() == OO_ExclaimEqual) { + switch (Op->getOperator()) { + default: + break; + case OO_EqualEqual: + case OO_ExclaimEqual: + case OO_Less: + case OO_Greater: + case OO_GreaterEqual: + case OO_LessEqual: WarnE = this; Loc = Op->getOperatorLoc(); R1 = Op->getSourceRange(); |