From: Artem Dergachev Date: Thu, 15 Feb 2018 19:01:55 +0000 (+0000) Subject: [analyzer] NFC: Eliminate ParentMap lookup in mayInlineCallKind(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=54cd87a7b2e38a93c1bdfc7d6c9a4a0267c55729;p=clang [analyzer] NFC: Eliminate ParentMap lookup in mayInlineCallKind(). Don't look at the parent statement to figure out if the cxx-allocator-inlining flag should kick in and prevent us from inlining the constructor within a new-expression. We now have construction contexts for that purpose. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@325278 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h index a9423d4f02..ea81313a87 100644 --- a/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h +++ b/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h @@ -577,6 +577,12 @@ public: ExplodedNode *Pred, ProgramStateRef St, SVal TargetLV, SVal Val, const ProgramPointTag *tag = nullptr); + /// Return the CFG element corresponding to the worklist element + /// that is currently being processed by ExprEngine. + CFGElement getCurrentCFGElement() { + return (*currBldrCtx->getBlock())[currStmtIdx]; + } + /// \brief Create a new state in which the call return value is binded to the /// call origin expression. ProgramStateRef bindReturnValue(const CallEvent &Call, diff --git a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp index bdf5555b2e..107debdd4c 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp @@ -109,10 +109,7 @@ ExprEngine::getRegionForConstructedObject(const CXXConstructExpr *CE, // See if we're constructing an existing region by looking at the // current construction context. - const NodeBuilderContext &CurrBldrCtx = getBuilderContext(); - const CFGBlock *B = CurrBldrCtx.getBlock(); - const CFGElement &E = (*B)[currStmtIdx]; - if (auto CC = E.getAs()) { + if (auto CC = getCurrentCFGElement().getAs()) { if (const Stmt *TriggerStmt = CC->getTriggerStmt()) { if (const CXXNewExpr *CNE = dyn_cast(TriggerStmt)) { if (AMgr.getAnalyzerOptions().mayInlineCXXAllocator()) { diff --git a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp index 9f61861ae4..d89d8f5bba 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -15,7 +15,6 @@ #include "PrettyStackTraceLocationContext.h" #include "clang/AST/CXXInheritance.h" #include "clang/AST/DeclCXX.h" -#include "clang/AST/ParentMap.h" #include "clang/Analysis/Analyses/LiveVariables.h" #include "clang/StaticAnalyzer/Core/CheckerManager.h" #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h" @@ -639,10 +638,8 @@ ExprEngine::mayInlineCallKind(const CallEvent &Call, const ExplodedNode *Pred, const CXXConstructExpr *CtorExpr = Ctor.getOriginExpr(); - // FIXME: ParentMap is slow and ugly. The callee should provide the - // necessary context. Ideally as part of the call event, or maybe as part of - // location context. - const Stmt *ParentExpr = CurLC->getParentMap().getParent(CtorExpr); + auto CC = getCurrentCFGElement().getAs(); + const Stmt *ParentExpr = CC ? CC->getTriggerStmt() : nullptr; if (ParentExpr && isa(ParentExpr) && !Opts.mayInlineCXXAllocator())