Add support in GRExprEngine for UnaryOperator::AlignOf. This fixes one crash report in PR 2796.

llvm-svn: 57777
This commit is contained in:
Ted Kremenek 2008-10-18 22:20:20 +00:00
parent cfb049c832
commit f8d65a30d6
2 changed files with 21 additions and 0 deletions

View File

@ -1780,6 +1780,23 @@ void GRExprEngine::VisitUnaryOperator(UnaryOperator* U, NodeTy* Pred,
return; 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: { case UnaryOperator::SizeOf: {

View File

@ -9,3 +9,7 @@
} }
@end @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); }