[cfe-commits] r54439 - /cfe/trunk/lib/Sema/SemaChecking.cpp
Ted Kremenek
kremenek at apple.com
Wed Aug 6 17:49:01 PDT 2008
Author: kremenek
Date: Wed Aug 6 19:49:01 2008
New Revision: 54439
URL: http://llvm.org/viewvc/llvm-project?rev=54439&view=rev
Log:
Fix <rdar://problem/6125909>.
Unify logic in return-of-stack-check (Sema) for casts and implicit casts.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=54439&r1=54438&r2=54439&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Aug 6 19:49:01 2008
@@ -797,30 +797,26 @@
return EvalAddr(C->getRHS());
}
- // For implicit casts, we need to handle conversions from arrays to
- // pointer values, and implicit pointer-to-pointer conversions.
+ // For casts, we need to handle conversions from arrays to
+ // pointer values, and pointer-to-pointer conversions.
+ case Stmt::CastExprClass:
case Stmt::ImplicitCastExprClass: {
- ImplicitCastExpr *IE = cast<ImplicitCastExpr>(E);
- Expr* SubExpr = IE->getSubExpr();
- if (SubExpr->getType()->isPointerType() ||
- SubExpr->getType()->isObjCQualifiedIdType())
- return EvalAddr(SubExpr);
+ Expr* SubExpr;
+
+ if (ImplicitCastExpr *IE = dyn_cast<ImplicitCastExpr>(E))
+ SubExpr = IE->getSubExpr();
else
- return EvalVal(SubExpr);
- }
-
- // For casts, we handle pointer-to-pointer conversions (which
- // is essentially a no-op from our mini-interpreter's standpoint).
- // For other casts we abort.
- case Stmt::CastExprClass: {
- CastExpr *C = cast<CastExpr>(E);
- Expr *SubExpr = C->getSubExpr();
+ SubExpr = cast<CastExpr>(E)->getSubExpr();
+
+ QualType T = SubExpr->getType();
- if (SubExpr->getType()->isPointerType())
+ if (T->isPointerType() || T->isObjCQualifiedIdType())
return EvalAddr(SubExpr);
+ else if (T->isArrayType())
+ return EvalVal(SubExpr);
else
- return NULL;
+ return 0;
}
// C++ casts. For dynamic casts, static casts, and const casts, we
More information about the cfe-commits
mailing list