diff options
-rw-r--r-- | lib/Analysis/GRExprEngine.cpp | 17 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp index d122dca019..98fa58f5dd 100644 --- a/lib/Analysis/GRExprEngine.cpp +++ b/lib/Analysis/GRExprEngine.cpp @@ -1780,6 +1780,23 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred, return; } + + case UnaryOperator::AlignOf: { + + QualType T = U->getSubExpr()->getType(); + + // FIXME: Add support for VLAs. + + if (!T.getTypePtr()->isConstantSizeType()) + return; + + uint64_t size = getContext().getTypeAlign(T) / 8; + const GRState* St = GetState(Pred); + St = SetSVal(St, U, NonLoc::MakeVal(getBasicVals(), size, U->getType())); + + MakeNode(Dst, U, Pred, St); + return; + } case UnaryOperator::SizeOf: { diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index f96b1a22c7..ab00bd8c34 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -9,3 +9,7 @@ } @end +// Reduced test case from crash in PR 2796; +// http://llvm.org/bugs/show_bug.cgi?id=2796 + +unsigned foo(unsigned x) { return __alignof__((x)) + sizeof(x); } |