diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-12-15 18:51:00 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-12-15 18:51:00 +0000 |
commit | 4299d5d2d89e6138566eb3f47b002a7331d4fbb1 (patch) | |
tree | d485adeaef22a4c821b36ae51572cea49c676444 /clang/lib/Analysis/GRExprEngine.cpp | |
parent | cd489a822c9f0a37ffced4b4acbe2d28f89332de (diff) | |
download | bcm5719-llvm-4299d5d2d89e6138566eb3f47b002a7331d4fbb1.tar.gz bcm5719-llvm-4299d5d2d89e6138566eb3f47b002a7331d4fbb1.zip |
Fix regression in handling sizeof(void) in the static analyzer.
llvm-svn: 61039
Diffstat (limited to 'clang/lib/Analysis/GRExprEngine.cpp')
-rw-r--r-- | clang/lib/Analysis/GRExprEngine.cpp | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index d6b15b1e2c4..769e4b31a63 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/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; |