summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2007-10-29 16:45:23 +0000
committerTed Kremenek <kremenek@apple.com>2007-10-29 16:45:23 +0000
commitfa907b81684a9c9d7e6ddb3e858353eb4dfb471c (patch)
treec2b8a68987ae04c46911fb6d8c18f1805299d2c2
parentd4ecc6da675277a2ad92efdbb2b166fddd349719 (diff)
downloadbcm5719-llvm-fa907b81684a9c9d7e6ddb3e858353eb4dfb471c.tar.gz
bcm5719-llvm-fa907b81684a9c9d7e6ddb3e858353eb4dfb471c.zip
For floating point equality check, we now ignore parentheses. e.g.:
(x) == x is the treated the same as x == x. llvm-svn: 43448
-rw-r--r--clang/Sema/SemaExpr.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/clang/Sema/SemaExpr.cpp b/clang/Sema/SemaExpr.cpp
index 59cff7cc7d4..1156bd7d4d1 100644
--- a/clang/Sema/SemaExpr.cpp
+++ b/clang/Sema/SemaExpr.cpp
@@ -1191,6 +1191,20 @@ inline QualType Sema::CheckShiftOperands( // C99 6.5.7
return QualType();
}
+// Utility method to plow through parentheses to get the first nested
+// non-ParenExpr expr.
+static inline Expr* IgnoreParen(Expr* E) {
+
+ while (true) {
+ if (ParenExpr* P = dyn_cast<ParenExpr>(E))
+ E = P->getSubExpr();
+ else
+ break;
+ }
+
+ return E;
+}
+
inline QualType Sema::CheckCompareOperands( // C99 6.5.8
Expr *&lex, Expr *&rex, SourceLocation loc, bool isRelational)
{
@@ -1212,8 +1226,8 @@ inline QualType Sema::CheckCompareOperands( // C99 6.5.8
// Special case: check for x == x (which is OK).
bool EmitWarning = true;
- if (DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(lex))
- if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(rex))
+ if (DeclRefExpr* DRL = dyn_cast<DeclRefExpr>(IgnoreParen(lex)))
+ if (DeclRefExpr* DRR = dyn_cast<DeclRefExpr>(IgnoreParen(rex)))
if (DRL->getDecl() == DRR->getDecl())
EmitWarning = false;
OpenPOWER on IntegriCloud