From c1334cc17d024117f25351b00be400e630b16825 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 13 Aug 2015 22:12:21 +0000 Subject: Wdeprecated: Make BumpVectorContext movable Turns out the one place that relied on the implicit copy ctor was safe because it created an object in a state where the dtor was a no-op, but that's more luck that good management. Sure up the API by defining move construction and using it, which implicitly disallows the unreliable copy operations. llvm-svn: 244968 --- clang/lib/Analysis/CFG.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'clang/lib/Analysis/CFG.cpp') diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp index 3a358f91b09..efc93534ed1 100644 --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -176,8 +176,8 @@ private: public: /// Constructs empty scope linked to previous scope in specified place. - LocalScope(BumpVectorContext &ctx, const_iterator P) - : ctx(ctx), Vars(ctx, 4), Prev(P) {} + LocalScope(BumpVectorContext ctx, const_iterator P) + : ctx(std::move(ctx)), Vars(this->ctx, 4), Prev(P) {} /// Begin of scope in direction of CFG building (backwards). const_iterator begin() const { return const_iterator(*this, Vars.size()); } @@ -1247,13 +1247,11 @@ void CFGBuilder::addImplicitDtorsForDestructor(const CXXDestructorDecl *DD) { /// createOrReuseLocalScope - If Scope is NULL create new LocalScope. Either /// way return valid LocalScope object. LocalScope* CFGBuilder::createOrReuseLocalScope(LocalScope* Scope) { - if (!Scope) { - llvm::BumpPtrAllocator &alloc = cfg->getAllocator(); - Scope = alloc.Allocate(); - BumpVectorContext ctx(alloc); - new (Scope) LocalScope(ctx, ScopePos); - } - return Scope; + if (Scope) + return Scope; + llvm::BumpPtrAllocator &alloc = cfg->getAllocator(); + return new (alloc.Allocate()) + LocalScope(BumpVectorContext(alloc), ScopePos); } /// addLocalScopeForStmt - Add LocalScope to local scopes tree for statement -- cgit v1.2.3