diff options
author | Mike Stump <mrs@apple.com> | 2009-10-28 21:22:24 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2009-10-28 21:22:24 +0000 |
commit | 460d138c19be357414e4ab56ec880e5451f95cb4 (patch) | |
tree | 1a23946430fa17a202059df7085100d2b1130c31 /lib/AST/ExprConstant.cpp | |
parent | d7a4a436efc11844c0d837a84f284aac7a09f31a (diff) |
Refine __builtin_object_size. Don't try and get a size for things
that don't have sizes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85435 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index dc53289165..a4ca2c4db6 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -943,13 +943,18 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { if (const Expr *LVBase = Base.Val.getLValueBase()) 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; - uint64_t Offset = Base.Val.getLValueOffset(); - if (Offset <= Size) - Size -= Base.Val.getLValueOffset(); - else - Size = 0; - return Success(Size, E); + if (!VD->getType()->isIncompleteType() + && VD->getType()->isObjectType() + && !VD->getType()->isVariablyModifiedType() + && !VD->getType()->isDependentType()) { + uint64_t Size = Info.Ctx.getTypeSize(VD->getType()) / 8; + uint64_t Offset = Base.Val.getLValueOffset(); + if (Offset <= Size) + Size -= Base.Val.getLValueOffset(); + else + Size = 0; + return Success(Size, E); + } } } |