mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-11 17:08:42 +00:00
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
This commit is contained in:
parent
5c73c941c9
commit
c1334cc17d
@ -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.
|
||||
|
@ -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<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
|
||||
|
Loading…
Reference in New Issue
Block a user