From 8be65a792ff56526e8937340ab620f75524b1de7 Mon Sep 17 00:00:00 2001 From: Zhongxing Xu Date: Wed, 24 Nov 2010 13:48:50 +0000 Subject: [PATCH] =?UTF-8?q?When=20getting=20CXXThisRegion=20from=20CXXMeth?= =?UTF-8?q?odDecl,=20use=20the=20qualifiers.=20This=20is=20to=20be=20consi?= =?UTF-8?q?stent=20with=20the=20type=20of=20'this'=20expr=20in=20the=20met?= =?UTF-8?q?hod.=20=E6=AD=A4=E8=A1=8C=E5=8F=8A=E4=BB=A5=E4=B8=8B=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=B0=86=E4=BC=9A=E8=A2=AB=E5=BF=BD=E7=95=A5--?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit M test/Analysis/method-call.cpp M include/clang/Checker/PathSensitive/GRExprEngine.h M lib/Checker/GRCXXExprEngine.cpp llvm-svn: 120094 --- clang/include/clang/Checker/PathSensitive/GRExprEngine.h | 3 +++ clang/lib/Checker/GRCXXExprEngine.cpp | 8 +++++++- clang/test/Analysis/method-call.cpp | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/clang/include/clang/Checker/PathSensitive/GRExprEngine.h b/clang/include/clang/Checker/PathSensitive/GRExprEngine.h index 4e97b8ee2e57..519a3e4c6fce 100644 --- a/clang/include/clang/Checker/PathSensitive/GRExprEngine.h +++ b/clang/include/clang/Checker/PathSensitive/GRExprEngine.h @@ -462,6 +462,9 @@ public: const CXXThisRegion *getCXXThisRegion(const CXXRecordDecl *RD, const StackFrameContext *SFC); + const CXXThisRegion *getCXXThisRegion(const CXXMethodDecl *decl, + const StackFrameContext *frameCtx); + /// Evaluate arguments with a work list algorithm. void EvalArguments(ConstExprIterator AI, ConstExprIterator AE, const FunctionProtoType *FnType, diff --git a/clang/lib/Checker/GRCXXExprEngine.cpp b/clang/lib/Checker/GRCXXExprEngine.cpp index 4a0fdc66ed8e..2dd03b2782c3 100644 --- a/clang/lib/Checker/GRCXXExprEngine.cpp +++ b/clang/lib/Checker/GRCXXExprEngine.cpp @@ -77,6 +77,12 @@ const CXXThisRegion *GRExprEngine::getCXXThisRegion(const CXXRecordDecl *D, return ValMgr.getRegionManager().getCXXThisRegion(PT, SFC); } +const CXXThisRegion *GRExprEngine::getCXXThisRegion(const CXXMethodDecl *decl, + const StackFrameContext *frameCtx) { + return ValMgr.getRegionManager(). + getCXXThisRegion(decl->getThisType(getContext()), frameCtx); +} + void GRExprEngine::CreateCXXTemporaryObject(const Expr *Ex, ExplodedNode *Pred, ExplodedNodeSet &Dst) { ExplodedNodeSet Tmp; @@ -242,7 +248,7 @@ void GRExprEngine::EvalMethodCall(const CallExpr *MCE, const CXXMethodDecl *MD, MCE, false, Builder->getBlock(), Builder->getIndex()); - const CXXThisRegion *ThisR = getCXXThisRegion(MD->getParent(), SFC); + const CXXThisRegion *ThisR = getCXXThisRegion(MD, SFC); CallEnter Loc(MCE, SFC, Pred->getLocationContext()); for (ExplodedNodeSet::iterator I = PreVisitChecks.begin(), E = PreVisitChecks.end(); I != E; ++I) { diff --git a/clang/test/Analysis/method-call.cpp b/clang/test/Analysis/method-call.cpp index a766da9aae2f..6cfbda895dec 100644 --- a/clang/test/Analysis/method-call.cpp +++ b/clang/test/Analysis/method-call.cpp @@ -3,7 +3,7 @@ struct A { int x; A(int a) { x = a; } - int getx() { return x; } + int getx() const { return x; } }; void f1() {