blob: 343afec18d21f35bd4027340427cca09e9d04c56 [file] [log] [blame]
Zhongxing Xu7b71c192010-03-23 07:32:14 +00001//=-- 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
18using namespace clang;
19
20namespace {
21class AggExprVisitor : public StmtVisitor<AggExprVisitor> {
22 SVal DestPtr;
23 ExplodedNode *Pred;
24 ExplodedNodeSet &DstSet;
25 GRExprEngine &Eng;
26
27public:
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
37void AggExprVisitor::VisitCastExpr(CastExpr *E) {
38 switch (E->getCastKind()) {
39 default:
40 assert(0 && "Unhandled cast kind");
Zhongxing Xu3a3e5842010-04-01 03:47:27 +000041 case CastExpr::CK_NoOp:
Zhongxing Xu7b71c192010-03-23 07:32:14 +000042 case CastExpr::CK_ConstructorConversion:
43 Visit(E->getSubExpr());
44 break;
45 }
46}
47
48void AggExprVisitor::VisitCXXConstructExpr(CXXConstructExpr *E) {
49 Eng.VisitCXXConstructExpr(E, DestPtr, Pred, DstSet);
50}
51
52void GRExprEngine::VisitAggExpr(const Expr *E, SVal Dest, ExplodedNode *Pred,
53 ExplodedNodeSet &Dst) {
54 AggExprVisitor(Dest, Pred, Dst, *this).Visit(const_cast<Expr *>(E));
55}