aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-08-07 00:49:01 +0000
committerTed Kremenek <kremenek@apple.com>2008-08-07 00:49:01 +0000
commit54b5274f2c190331438375ad114dad12ae098b57 (patch)
tree2a1ba5a74a035854301128a6760d35a102f23043 /lib/Sema/SemaChecking.cpp
parentebd335983edcfed763768b22027998162a5a4ff6 (diff)
Fix <rdar://problem/6125909>.
Unify logic in return-of-stack-check (Sema) for casts and implicit casts. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54439 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r--lib/Sema/SemaChecking.cpp32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 5da9cd7ae2..2f2fe7dab6 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -797,30 +797,26 @@ static DeclRefExpr* EvalAddr(Expr *E) {
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