r206986 - Replacing a naked pointer with a unique_ptr. No functional changes intended.

David Blaikie dblaikie at gmail.com
Wed Apr 23 10:08:29 PDT 2014


On Wed, Apr 23, 2014 at 7:26 AM, Aaron Ballman <aaron at aaronballman.com> wrote:
> Author: aaronballman
> Date: Wed Apr 23 09:26:59 2014
> New Revision: 206986
>
> URL: http://llvm.org/viewvc/llvm-project?rev=206986&view=rev
> Log:
> Replacing a naked pointer with a unique_ptr. No functional changes intended.

Any particular reason this needs to be dynamically allocated (it
doesn't appear to be polymorphic - but perhaps it will be in the
future?)? Would Optional<CallingContext> suffice?

>
> Modified:
>     cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
>     cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
>
> Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h?rev=206986&r1=206985&r2=206986&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h (original)
> +++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyCommon.h Wed Apr 23 09:26:59 2014
> @@ -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;
>
> Modified: cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp?rev=206986&r1=206985&r2=206986&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp (original)
> +++ cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp Wed Apr 23 09:26:59 2014
> @@ -649,7 +649,7 @@ void SExprBuilder::enterCFG(CFG *Cfg, co
>      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(con
>
>
>  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(cons
>      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;
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list