]> granicus.if.org Git - clang/commitdiff
Replacing a naked pointer with a unique_ptr. No functional changes intended.
authorAaron Ballman <aaron@aaronballman.com>
Wed, 23 Apr 2014 14:26:59 +0000 (14:26 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 23 Apr 2014 14:26:59 +0000 (14:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@206986 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Analyses/ThreadSafetyCommon.h
lib/Analysis/ThreadSafetyCommon.cpp

index 73678dcb5e298afaf6f12d8cd66b4003a0c92af5..6a3ae3605beb070bdcbace4ecfe1e6251b078959 100644 (file)
@@ -27,6 +27,7 @@
 #include "clang/Analysis/AnalysisContext.h"
 #include "clang/Basic/OperatorKinds.h"
 
+#include <memory>
 #include <vector>
 
 
@@ -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<til::BasicBlock *> BlockMap; // Map from clang to til BBs.
   std::vector<BlockInfo> BBInfo;           // Extra information per BB.
                                            // Indexed by clang BlockID.
-  SExprBuilder::CallingContext *CallCtx;   // Root calling context
+  std::unique_ptr<SExprBuilder::CallingContext> CallCtx; // Root calling context
 
   LVarDefinitionMap CurrentLVarMap;
   std::vector<til::Variable*> CurrentArguments;
index 252fd97496b11085f6795420687363c7aeeece2b..0a6efebd3110de1707ad31ad0301b236fe64da2c 100644 (file)
@@ -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;