diff options
author | Mike Stump <mrs@apple.com> | 2009-10-26 21:38:39 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-10-26 21:38:39 +0000 |
commit | 06bc9bcc705e5fee714d4b00c3c3c9f01715c195 (patch) | |
tree | d37641e8ad8c520bbf3928b8f7ed8745961e70ae /lib/AST/ExprConstant.cpp | |
parent | 07e72fd5cbfa46a5e9459a057ec0077cd4167d7f (diff) |
__builtin_object_size refinements. When we run out of object, be sure
to clamp at 0 bytes left. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85157 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index f1a446ef6e..9992b6944e 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -884,7 +884,11 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { if (const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(LVBase)) { if (const VarDecl *VD = dyn_cast<VarDecl>(DRE->getDecl())) { uint64_t Size = Info.Ctx.getTypeSize(VD->getType()) / 8; - Size -= Base.Val.getLValueOffset(); + uint64_t Offset = Base.Val.getLValueOffset(); + if (Offset <= Size) + Size -= Base.Val.getLValueOffset(); + else + Size = 0; return Success(Size, E); } } |