[cfe-commits] r117908 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRExprEngine.h lib/Checker/AggExprVisitor.cpp lib/Checker/GRCXXExprEngine.cpp lib/Checker/GRExprEngine.cpp test/Analysis/method-call.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Mon Nov 1 02:09:44 PDT 2010
Author: zhongxingxu
Date: Mon Nov 1 04:09:44 2010
New Revision: 117908
URL: http://llvm.org/viewvc/llvm-project?rev=117908&view=rev
Log:
Now initializer of C++ record type is visited as block-level expr.
Let the destination of AggExprVisitor be an explicit MemRegion.
Reenable the test case.
Modified:
cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
cfe/trunk/lib/Checker/AggExprVisitor.cpp
cfe/trunk/lib/Checker/GRCXXExprEngine.cpp
cfe/trunk/lib/Checker/GRExprEngine.cpp
cfe/trunk/test/Analysis/method-call.cpp
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h?rev=117908&r1=117907&r2=117908&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRExprEngine.h Mon Nov 1 04:09:44 2010
@@ -412,9 +412,8 @@
void VisitCXXThisExpr(const CXXThisExpr *TE, ExplodedNode *Pred,
ExplodedNodeSet & Dst);
- void VisitCXXConstructExpr(const CXXConstructExpr *E, SVal Dest,
- ExplodedNode *Pred,
- ExplodedNodeSet &Dst);
+ void VisitCXXConstructExpr(const CXXConstructExpr *E, const MemRegion *Dest,
+ ExplodedNode *Pred, ExplodedNodeSet &Dst);
void VisitCXXMemberCallExpr(const CXXMemberCallExpr *MCE, ExplodedNode *Pred,
ExplodedNodeSet &Dst);
@@ -425,7 +424,7 @@
void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE, ExplodedNode *Pred,
ExplodedNodeSet &Dst);
- void VisitAggExpr(const Expr *E, SVal Dest, ExplodedNode *Pred,
+ void VisitAggExpr(const Expr *E, const MemRegion *Dest, ExplodedNode *Pred,
ExplodedNodeSet &Dst);
/// Create a C++ temporary object for an rvalue.
Modified: cfe/trunk/lib/Checker/AggExprVisitor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/AggExprVisitor.cpp?rev=117908&r1=117907&r2=117908&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/AggExprVisitor.cpp (original)
+++ cfe/trunk/lib/Checker/AggExprVisitor.cpp Mon Nov 1 04:09:44 2010
@@ -26,15 +26,15 @@
/// cast and construct exprs (and others), and at the final point, dispatches
/// back to the GRExprEngine to let the real evaluation logic happen.
class AggExprVisitor : public StmtVisitor<AggExprVisitor> {
- SVal DestPtr;
+ const MemRegion *Dest;
ExplodedNode *Pred;
ExplodedNodeSet &DstSet;
GRExprEngine &Eng;
public:
- AggExprVisitor(SVal dest, ExplodedNode *N, ExplodedNodeSet &dst,
+ AggExprVisitor(const MemRegion *dest, ExplodedNode *N, ExplodedNodeSet &dst,
GRExprEngine &eng)
- : DestPtr(dest), Pred(N), DstSet(dst), Eng(eng) {}
+ : Dest(dest), Pred(N), DstSet(dst), Eng(eng) {}
void VisitCastExpr(CastExpr *E);
void VisitCXXConstructExpr(CXXConstructExpr *E);
@@ -53,10 +53,10 @@
}
void AggExprVisitor::VisitCXXConstructExpr(CXXConstructExpr *E) {
- Eng.VisitCXXConstructExpr(E, DestPtr, Pred, DstSet);
+ Eng.VisitCXXConstructExpr(E, Dest, Pred, DstSet);
}
-void GRExprEngine::VisitAggExpr(const Expr *E, SVal Dest, ExplodedNode *Pred,
- ExplodedNodeSet &Dst) {
+void GRExprEngine::VisitAggExpr(const Expr *E, const MemRegion *Dest,
+ ExplodedNode *Pred, ExplodedNodeSet &Dst) {
AggExprVisitor(Dest, Pred, Dst, *this).Visit(const_cast<Expr *>(E));
}
Modified: cfe/trunk/lib/Checker/GRCXXExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRCXXExprEngine.cpp?rev=117908&r1=117907&r2=117908&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRCXXExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRCXXExprEngine.cpp Mon Nov 1 04:09:44 2010
@@ -91,9 +91,14 @@
}
}
-void GRExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E, SVal Dest,
+void GRExprEngine::VisitCXXConstructExpr(const CXXConstructExpr *E,
+ const MemRegion *Dest,
ExplodedNode *Pred,
ExplodedNodeSet &Dst) {
+ if (!Dest)
+ Dest = ValMgr.getRegionManager().getCXXObjectRegion(E,
+ Pred->getLocationContext());
+
if (E->isElidable()) {
VisitAggExpr(E->getArg(0), Dest, Pred, Dst);
return;
@@ -124,7 +129,7 @@
const GRState *state = GetState(*NI);
// Setup 'this' region, so that the ctor is evaluated on the object pointed
// by 'Dest'.
- state = state->bindLoc(loc::MemRegionVal(ThisR), Dest);
+ state = state->bindLoc(loc::MemRegionVal(ThisR), loc::MemRegionVal(Dest));
ExplodedNode *N = Builder->generateNode(Loc, state, Pred);
if (N)
Dst.Add(N);
Modified: cfe/trunk/lib/Checker/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/GRExprEngine.cpp?rev=117908&r1=117907&r2=117908&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Checker/GRExprEngine.cpp Mon Nov 1 04:09:44 2010
@@ -679,7 +679,6 @@
// C++ stuff we don't support yet.
case Stmt::CXXBindTemporaryExprClass:
case Stmt::CXXCatchStmtClass:
- case Stmt::CXXConstructExprClass:
case Stmt::CXXDefaultArgExprClass:
case Stmt::CXXDependentScopeMemberExprClass:
case Stmt::CXXExprWithTemporariesClass:
@@ -810,6 +809,14 @@
break;
}
+ case Stmt::CXXConstructExprClass: {
+ const CXXConstructExpr *C = cast<CXXConstructExpr>(S);
+ // For block-level CXXConstructExpr, we don't have a destination region.
+ // Let VisitCXXConstructExpr() create one.
+ VisitCXXConstructExpr(C, 0, Pred, Dst);
+ break;
+ }
+
case Stmt::CXXMemberCallExprClass: {
const CXXMemberCallExpr *MCE = cast<CXXMemberCallExpr>(S);
VisitCXXMemberCallExpr(MCE, Pred, Dst);
@@ -2592,20 +2599,7 @@
ExplodedNodeSet Tmp;
if (InitEx) {
- QualType InitTy = InitEx->getType();
- if (getContext().getLangOptions().CPlusPlus && InitTy->isRecordType()) {
- // Delegate expressions of C++ record type evaluation to AggExprVisitor.
- VisitAggExpr(InitEx, GetState(Pred)->getLValue(VD,
- Pred->getLocationContext()), Pred, Tmp);
-
- // FIXME: remove later when all paths through VisitAggExpr work properly
- if (Tmp.empty())
- Tmp.Add(Pred);
- // Call checkers for initialized aggregates
- CheckerVisit(DS, Dst, Tmp, PreVisitStmtCallback);
-
- return;
- } else if (VD->getType()->isReferenceType())
+ if (VD->getType()->isReferenceType())
VisitLValue(InitEx, Pred, Tmp);
else
Visit(InitEx, Pred, Tmp);
Modified: cfe/trunk/test/Analysis/method-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/method-call.cpp?rev=117908&r1=117907&r2=117908&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/method-call.cpp (original)
+++ cfe/trunk/test/Analysis/method-call.cpp Mon Nov 1 04:09:44 2010
@@ -1,5 +1,5 @@
// RUN: %clang_cc1 -analyze -analyzer-check-objc-mem -analyzer-inline-call -analyzer-store region -verify %s
-// XFAIL: *
+
struct A {
int x;
A(int a) { x = a; }
More information about the cfe-commits
mailing list