From: Aaron Ballman Date: Wed, 23 Apr 2014 14:26:59 +0000 (+0000) Subject: Replacing a naked pointer with a unique_ptr. No functional changes intended. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aafc70acf92c076d185be010889cea961ea0dc41;p=clang Replacing a naked pointer with a unique_ptr. No functional changes intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206986 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/Analyses/ThreadSafetyCommon.h b/include/clang/Analysis/Analyses/ThreadSafetyCommon.h index 73678dcb5e..6a3ae3605b 100644 --- a/include/clang/Analysis/Analyses/ThreadSafetyCommon.h +++ b/include/clang/Analysis/Analyses/ThreadSafetyCommon.h @@ -27,6 +27,7 @@ #include "clang/Analysis/AnalysisContext.h" #include "clang/Basic/OperatorKinds.h" +#include #include @@ -234,15 +235,11 @@ public: }; SExprBuilder(til::MemRegionRef A) - : Arena(A), SelfVar(nullptr), Scfg(nullptr), CallCtx(nullptr), - CurrentBB(nullptr), CurrentBlockInfo(nullptr) { + : Arena(A), SelfVar(nullptr), Scfg(nullptr), CurrentBB(nullptr), + CurrentBlockInfo(nullptr) { // FIXME: we don't always have a self-variable. SelfVar = new (Arena) til::Variable(til::Variable::VK_SFun); } - ~SExprBuilder() { - if (CallCtx) - delete CallCtx; - } // Translate a clang statement or expression to a TIL expression. // Also performs substitution of variables; Ctx provides the context. @@ -369,7 +366,7 @@ private: std::vector BlockMap; // Map from clang to til BBs. std::vector BBInfo; // Extra information per BB. // Indexed by clang BlockID. - SExprBuilder::CallingContext *CallCtx; // Root calling context + std::unique_ptr CallCtx; // Root calling context LVarDefinitionMap CurrentLVarMap; std::vector CurrentArguments; diff --git a/lib/Analysis/ThreadSafetyCommon.cpp b/lib/Analysis/ThreadSafetyCommon.cpp index 252fd97496..0a6efebd31 100644 --- a/lib/Analysis/ThreadSafetyCommon.cpp +++ b/lib/Analysis/ThreadSafetyCommon.cpp @@ -649,7 +649,7 @@ void SExprBuilder::enterCFG(CFG *Cfg, const FunctionDecl *FD, auto *BB = new (Arena) til::BasicBlock(Arena, 0, B->size()); BlockMap[B->getBlockID()] = BB; } - CallCtx = new SExprBuilder::CallingContext(FD); + CallCtx.reset(new SExprBuilder::CallingContext(FD)); CurrentBB = lookupBlock(&Cfg->getEntry()); for (auto *Pm : FD->parameters()) { @@ -712,7 +712,7 @@ void SExprBuilder::enterCFGBlockBody(const CFGBlock *B) { void SExprBuilder::handleStatement(const Stmt *S) { - til::SExpr *E = translate(S, CallCtx); + til::SExpr *E = translate(S, CallCtx.get()); addStatement(E, S); } @@ -744,7 +744,7 @@ void SExprBuilder::exitCFGBlockBody(const CFGBlock *B) { CurrentBB->setTerminator(Tm); } else if (N == 2) { - til::SExpr *C = translate(B->getTerminatorCondition(true), CallCtx); + til::SExpr *C = translate(B->getTerminatorCondition(true), CallCtx.get()); til::BasicBlock *BB1 = *It ? lookupBlock(*It) : nullptr; ++It; til::BasicBlock *BB2 = *It ? lookupBlock(*It) : nullptr;