Author: dblaikie Date: Thu Aug 13 17:12:21 2015 New Revision: 244968 URL: http://llvm.org/viewvc/llvm-project?rev=244968&view=rev Log: 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. Modified: cfe/trunk/include/clang/Analysis/Support/BumpVector.h cfe/trunk/lib/Analysis/CFG.cpp Modified: cfe/trunk/include/clang/Analysis/Support/BumpVector.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Support/BumpVector.h?rev=244968&r1=244967&r2=244968&view=diff ============================================================================== --- cfe/trunk/include/clang/Analysis/Support/BumpVector.h (original) +++ cfe/trunk/include/clang/Analysis/Support/BumpVector.h Thu Aug 13 17:12:21 2015 @@ -35,7 +35,12 @@ public: /// Construct a new BumpVectorContext that creates a new BumpPtrAllocator /// and destroys it when the BumpVectorContext object is destroyed. BumpVectorContext() : Alloc(new llvm::BumpPtrAllocator(), 1) {} - + + BumpVectorContext(BumpVectorContext &&Other) : Alloc(Other.Alloc) { + Other.Alloc.setInt(false); + Other.Alloc.setPointer(nullptr); + } + /// Construct a new BumpVectorContext that reuses an existing /// BumpPtrAllocator. This BumpPtrAllocator is not destroyed when the /// BumpVectorContext object is destroyed. Modified: cfe/trunk/lib/Analysis/CFG.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFG.cpp?rev=244968&r1=244967&r2=244968&view=diff ============================================================================== --- cfe/trunk/lib/Analysis/CFG.cpp (original) +++ cfe/trunk/lib/Analysis/CFG.cpp Thu Aug 13 17:12:21 2015 @@ -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::addImplicitDtorsForDest /// 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<LocalScope>(); - BumpVectorContext ctx(alloc); - new (Scope) LocalScope(ctx, ScopePos); - } - return Scope; + if (Scope) + return Scope; + llvm::BumpPtrAllocator &alloc = cfg->getAllocator(); + return new (alloc.Allocate<LocalScope>()) + LocalScope(BumpVectorContext(alloc), ScopePos); } /// addLocalScopeForStmt - Add LocalScope to local scopes tree for statement _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits