From: Zhongxing Xu Date: Wed, 24 Nov 2010 13:48:50 +0000 (+0000) Subject: When getting CXXThisRegion from CXXMethodDecl, use the qualifiers. This is X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=32303020d0f1a21cbcab65ae0c69a4218dc8f0fb;p=clang When getting CXXThisRegion from CXXMethodDecl, use the qualifiers. This is to be consistent with the type of 'this' expr in the method. 此行及以下内容将会被忽略-- M test/Analysis/method-call.cpp M include/clang/Checker/PathSensitive/GRExprEngine.h M lib/Checker/GRCXXExprEngine.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120094 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Checker/PathSensitive/GRExprEngine.h b/include/clang/Checker/PathSensitive/GRExprEngine.h index 4e97b8ee2e..519a3e4c6f 100644 --- a/include/clang/Checker/PathSensitive/GRExprEngine.h +++ b/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/lib/Checker/GRCXXExprEngine.cpp b/lib/Checker/GRCXXExprEngine.cpp index 4a0fdc66ed..2dd03b2782 100644 --- a/lib/Checker/GRCXXExprEngine.cpp +++ b/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/test/Analysis/method-call.cpp b/test/Analysis/method-call.cpp index a766da9aae..6cfbda895d 100644 --- a/test/Analysis/method-call.cpp +++ b/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() {