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 | e190dee7a5488f6314f74accd266c4abf36c2c4b (patch) | |
| tree | cf65c2f82ba42c767a6ea8308c1e7128afec169b /clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | |
| parent | 012284162613e4227042ea27d8426c119dad64a0 (diff) | |
| download | bcm5719-llvm-e190dee7a5488f6314f74accd266c4abf36c2c4b.tar.gz bcm5719-llvm-e190dee7a5488f6314f74accd266c4abf36c2c4b.zip | |
Add support for the OpenCL vec_step operator, by generalising and
extending the existing support for sizeof and alignof.  Original
patch by Guy Benyei.
llvm-svn: 127475
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ExprEngine.cpp')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 29 | 
1 files changed, 12 insertions, 17 deletions
| diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index 95d339ff827..9178a6184fb 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/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, | 

