diff options
author | George Burgess IV <george.burgess.iv@gmail.com> | 2017-01-03 23:35:19 +0000 |
---|---|---|
committer | George Burgess IV <george.burgess.iv@gmail.com> | 2017-01-03 23:35:19 +0000 |
commit | d49e17b4116694db28672b4ae66fd1958000d6a1 (patch) | |
tree | 350b1b5c802eea3dbcf66050c2df5554a37237fc /lib/AST/ExprConstant.cpp | |
parent | fd845a579da485d1461682d2aab0331751fb898c (diff) |
Re-add objectsize function/incomplete type checks.
I accidentally omitted these when refactoring this code. This caused
problems when building parts of the test-suite on MacOS.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@290916 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ExprConstant.cpp')
-rw-r--r-- | lib/AST/ExprConstant.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index b3f8925b64..6dcb705c44 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -7192,6 +7192,12 @@ static bool determineEndOffset(EvalInfo &Info, SourceLocation ExprLoc, CharUnits &EndOffset) { bool DetermineForCompleteObject = refersToCompleteObject(LVal); + auto CheckedHandleSizeof = [&](QualType Ty, CharUnits &Result) { + if (Ty.isNull() || Ty->isIncompleteType() || Ty->isFunctionType()) + return false; + return HandleSizeof(Info, ExprLoc, Ty, Result); + }; + // We want to evaluate the size of the entire object. This is a valid fallback // for when Type=1 and the designator is invalid, because we're asked for an // upper-bound. @@ -7209,7 +7215,7 @@ static bool determineEndOffset(EvalInfo &Info, SourceLocation ExprLoc, return false; QualType BaseTy = getObjectType(LVal.getLValueBase()); - return !BaseTy.isNull() && HandleSizeof(Info, ExprLoc, BaseTy, EndOffset); + return CheckedHandleSizeof(BaseTy, EndOffset); } // We want to evaluate the size of a subobject. @@ -7238,7 +7244,7 @@ static bool determineEndOffset(EvalInfo &Info, SourceLocation ExprLoc, } CharUnits BytesPerElem; - if (!HandleSizeof(Info, ExprLoc, Designator.MostDerivedType, BytesPerElem)) + if (!CheckedHandleSizeof(Designator.MostDerivedType, BytesPerElem)) return false; // According to the GCC documentation, we want the size of the subobject |