[cfe-commits] r43448 - /cfe/trunk/Sema/SemaExpr.cpp
Ted Kremenek
kremenek at apple.com
Mon Oct 29 09:45:23 PDT 2007
Author: kremenek
Date: Mon Oct 29 11:45:23 2007
New Revision: 43448
URL: http://llvm.org/viewvc/llvm-project?rev=43448&view=rev
Log:
For floating point equality check, we now ignore parentheses. e.g.:
(x) == x is the treated the same as x == x.
Modified:
cfe/trunk/Sema/SemaExpr.cpp
Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=43448&r1=43447&r2=43448&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Mon Oct 29 11:45:23 2007
@@ -1191,6 +1191,20 @@
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 @@
// 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;
More information about the cfe-commits
mailing list