aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/GRExprEngine.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2008-12-15 18:51:00 +0000
committerTed Kremenek <kremenek@apple.com>2008-12-15 18:51:00 +0000
commit55f7bcbda37964d3c0e8928d0e50a6e1692b7dce (patch)
treebf662170c5bb04a65aea1fdf5bf091710ade74d4 /lib/Analysis/GRExprEngine.cpp
parent9fbb609b90c1b41e147cf3e6afac40ff4b4137da (diff)
Fix regression in handling sizeof(void) in the static analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61039 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/GRExprEngine.cpp')
-rw-r--r--lib/Analysis/GRExprEngine.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index d6b15b1e2c..769e4b31a6 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -1973,22 +1973,24 @@ void GRExprEngine::VisitSizeOfAlignOfExpr(SizeOfAlignOfExpr* Ex,
uint64_t amt;
if (Ex->isSizeOf()) {
-
- // FIXME: Add support for VLAs.
- if (!T.getTypePtr()->isConstantSizeType())
+ if (T == getContext().VoidTy) {
+ // sizeof(void) == 1 byte.
+ amt = 1;
+ }
+ else if (!T.getTypePtr()->isConstantSizeType()) {
+ // FIXME: Add support for VLAs.
return;
-
- // Some code tries to take the sizeof an ObjCInterfaceType, relying that
- // the compiler has laid out its representation. Just report Unknown
- // for these.
- if (T->isObjCInterfaceType())
+ }
+ else if (T->isObjCInterfaceType()) {
+ // Some code tries to take the sizeof an ObjCInterfaceType, relying that
+ // the compiler has laid out its representation. Just report Unknown
+ // for these.
return;
-
- amt = 1; // Handle sizeof(void)
-
- if (T != getContext().VoidTy)
+ }
+ else {
+ // All other cases.
amt = getContext().getTypeSize(T) / 8;
-
+ }
}
else // Get alignment of the type.
amt = getContext().getTypeAlign(T) / 8;