diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-07-28 23:07:36 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-07-28 23:07:36 +0000 |
commit | a6446681932568411d78d26c5fc6e3d8358be357 (patch) | |
tree | 7d3b0fa7104a9074743eadfae41c2a1503bbc5b3 | |
parent | caed7c6954cfad10fc884bb3631b5f4aa7fe221c (diff) | |
download | bcm5719-llvm-a6446681932568411d78d26c5fc6e3d8358be357.tar.gz bcm5719-llvm-a6446681932568411d78d26c5fc6e3d8358be357.zip |
[analyzer] fix handling of MaterializeTemporaryExpr by binding the result value to
the proper expression.
llvm-svn: 136412
-rw-r--r-- | clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h | 3 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp | 13 | ||||
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ExprEngine.cpp | 2 | ||||
-rw-r--r-- | clang/test/Analysis/reference.cpp | 1 |
4 files changed, 11 insertions, 8 deletions
diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index d24036c0ec2..8c1d2f19c96 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -366,7 +366,8 @@ public: ExplodedNodeSet &Dst); /// Create a C++ temporary object for an rvalue. - void CreateCXXTemporaryObject(const Expr *Ex, ExplodedNode *Pred, + void CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, + ExplodedNode *Pred, ExplodedNodeSet &Dst); /// Synthesize CXXThisRegion. diff --git a/clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp index 137aa2ab64f..eecf1146adc 100644 --- a/clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/CXXExprEngine.cpp @@ -103,23 +103,24 @@ const CXXThisRegion *ExprEngine::getCXXThisRegion(const CXXMethodDecl *decl, getCXXThisRegion(decl->getThisType(getContext()), frameCtx); } -void ExprEngine::CreateCXXTemporaryObject(const Expr *Ex, ExplodedNode *Pred, - ExplodedNodeSet &Dst) { +void ExprEngine::CreateCXXTemporaryObject(const MaterializeTemporaryExpr *ME, + ExplodedNode *Pred, + ExplodedNodeSet &Dst) { ExplodedNodeSet Tmp; - Visit(Ex, Pred, Tmp); + Visit(ME->GetTemporaryExpr(), Pred, Tmp); for (ExplodedNodeSet::iterator I = Tmp.begin(), E = Tmp.end(); I != E; ++I) { const GRState *state = GetState(*I); // Bind the temporary object to the value of the expression. Then bind // the expression to the location of the object. - SVal V = state->getSVal(Ex); + SVal V = state->getSVal(ME->GetTemporaryExpr()); const MemRegion *R = - svalBuilder.getRegionManager().getCXXTempObjectRegion(Ex, + svalBuilder.getRegionManager().getCXXTempObjectRegion(ME, Pred->getLocationContext()); state = state->bindLoc(loc::MemRegionVal(R), V); - MakeNode(Dst, Ex, Pred, state->BindExpr(Ex, loc::MemRegionVal(R))); + MakeNode(Dst, ME, Pred, state->BindExpr(ME, loc::MemRegionVal(R))); } } diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp index b654f1cf347..003c0f305d2 100644 --- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp @@ -705,7 +705,7 @@ void ExprEngine::Visit(const Stmt* S, ExplodedNode* Pred, const MaterializeTemporaryExpr *Materialize = cast<MaterializeTemporaryExpr>(S); if (!Materialize->getType()->isRecordType()) - CreateCXXTemporaryObject(Materialize->GetTemporaryExpr(), Pred, Dst); + CreateCXXTemporaryObject(Materialize, Pred, Dst); else Visit(Materialize->GetTemporaryExpr(), Pred, Dst); break; diff --git a/clang/test/Analysis/reference.cpp b/clang/test/Analysis/reference.cpp index 3422b58d3fe..48a258588e4 100644 --- a/clang/test/Analysis/reference.cpp +++ b/clang/test/Analysis/reference.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -analyze -analyzer-checker=core,core.experimental -analyzer-store=region -analyzer-constraints=range -verify %s +// XFAIL typedef typeof(sizeof(int)) size_t; void malloc (size_t); |