diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-03-11 19:24:49 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-03-11 19:24:49 +0000 |
commit | f4e3cfbe8abd124be6341ef5d714819b4fbd9082 (patch) | |
tree | 58c9d5a512305020803bedf5dbc229573ff99175 /lib/StaticAnalyzer/Core/ExprEngine.cpp | |
parent | 1e15394853bfae25112d9cc6b445504905e1f34a (diff) |
Add support for the OpenCL vec_step operator, by generalising and
extending the existing support for sizeof and alignof. Original
patch by Guy Benyei.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@127475 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/ExprEngine.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/ExprEngine.cpp | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/lib/StaticAnalyzer/Core/ExprEngine.cpp b/lib/StaticAnalyzer/Core/ExprEngine.cpp index 95d339ff82..9178a6184f 100644 --- a/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -690,8 +690,9 @@ void ExprEngine::Visit(const Stmt* S, ExplodedNode* Pred, VisitOffsetOfExpr(cast<OffsetOfExpr>(S), Pred, Dst); break; - case Stmt::SizeOfAlignOfExprClass: - VisitSizeOfAlignOfExpr(cast<SizeOfAlignOfExpr>(S), Pred, Dst); + case Stmt::UnaryExprOrTypeTraitExprClass: + VisitUnaryExprOrTypeTraitExpr(cast<UnaryExprOrTypeTraitExpr>(S), + Pred, Dst); break; case Stmt::StmtExprClass: { @@ -2410,19 +2411,15 @@ void ExprEngine::VisitInitListExpr(const InitListExpr* E, ExplodedNode* Pred, assert(0 && "unprocessed InitListExpr type"); } -/// VisitSizeOfAlignOfExpr - Transfer function for sizeof(type). -void ExprEngine::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr* Ex, +/// VisitUnaryExprOrTypeTraitExpr - Transfer function for sizeof(type). +void ExprEngine::VisitUnaryExprOrTypeTraitExpr( + const UnaryExprOrTypeTraitExpr* Ex, ExplodedNode* Pred, ExplodedNodeSet& Dst) { QualType T = Ex->getTypeOfArgument(); - CharUnits amt; - if (Ex->isSizeOf()) { - if (T == getContext().VoidTy) { - // sizeof(void) == 1 byte. - amt = CharUnits::One(); - } - else if (!T->isConstantSizeType()) { + if (Ex->getKind() == UETT_SizeOf) { + if (!T->isIncompleteType() && !T->isConstantSizeType()) { assert(T->isVariableArrayType() && "Unknown non-constant-sized type."); // FIXME: Add support for VLA type arguments, not just VLA expressions. @@ -2463,13 +2460,11 @@ void ExprEngine::VisitSizeOfAlignOfExpr(const SizeOfAlignOfExpr* Ex, Dst.Add(Pred); return; } - else { - // All other cases. - amt = getContext().getTypeSizeInChars(T); - } } - else // Get alignment of the type. - amt = getContext().getTypeAlignInChars(T); + + Expr::EvalResult Result; + Ex->Evaluate(Result, getContext()); + CharUnits amt = CharUnits::fromQuantity(Result.Val.getInt().getZExtValue()); MakeNode(Dst, Ex, Pred, GetState(Pred)->BindExpr(Ex, |