Zhongxing Xu | 7b71c19 | 2010-03-23 07:32:14 +0000 | [diff] [blame^] | 1 | //=-- AggExprVisitor.cpp - evaluating expressions of C++ class type -*- C++ -*-= |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines AggExprVisitor class, which contains lots of boiler |
| 11 | // plate code for evaluating expressions of C++ class type. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Checker/PathSensitive/GRExprEngine.h" |
| 16 | #include "clang/AST/StmtVisitor.h" |
| 17 | |
| 18 | using namespace clang; |
| 19 | |
| 20 | namespace { |
| 21 | class AggExprVisitor : public StmtVisitor<AggExprVisitor> { |
| 22 | SVal DestPtr; |
| 23 | ExplodedNode *Pred; |
| 24 | ExplodedNodeSet &DstSet; |
| 25 | GRExprEngine &Eng; |
| 26 | |
| 27 | public: |
| 28 | AggExprVisitor(SVal dest, ExplodedNode *N, ExplodedNodeSet &dst, |
| 29 | GRExprEngine &eng) |
| 30 | : DestPtr(dest), Pred(N), DstSet(dst), Eng(eng) {} |
| 31 | |
| 32 | void VisitCastExpr(CastExpr *E); |
| 33 | void VisitCXXConstructExpr(CXXConstructExpr *E); |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | void AggExprVisitor::VisitCastExpr(CastExpr *E) { |
| 38 | switch (E->getCastKind()) { |
| 39 | default: |
| 40 | assert(0 && "Unhandled cast kind"); |
| 41 | case CastExpr::CK_ConstructorConversion: |
| 42 | Visit(E->getSubExpr()); |
| 43 | break; |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | void AggExprVisitor::VisitCXXConstructExpr(CXXConstructExpr *E) { |
| 48 | Eng.VisitCXXConstructExpr(E, DestPtr, Pred, DstSet); |
| 49 | } |
| 50 | |
| 51 | void GRExprEngine::VisitAggExpr(const Expr *E, SVal Dest, ExplodedNode *Pred, |
| 52 | ExplodedNodeSet &Dst) { |
| 53 | AggExprVisitor(Dest, Pred, Dst, *this).Visit(const_cast<Expr *>(E)); |
| 54 | } |