Convert a few Stmt actions to smart pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61309 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/AstGuard.h b/lib/Parse/AstGuard.h
index 5d17aa6..a65caed 100644
--- a/lib/Parse/AstGuard.h
+++ b/lib/Parse/AstGuard.h
@@ -23,7 +23,7 @@
/// automatically freeing them on destruction unless it's been disowned.
/// Instantiated for statements and expressions (Action::DeleteStmt and
/// Action::DeleteExpr).
- template <void (ActionBase::*Destroyer)(void*), unsigned N>
+ template <ASTDestroyer Destroyer, unsigned N>
class ASTVector : public llvm::SmallVector<void*, N> {
private:
Action &Actions;
@@ -50,6 +50,8 @@
Owns = false;
return &(*this)[0];
}
+
+ Action &getActions() const { return Actions; }
};
/// A SmallVector of statements, with stack size 32 (as that is the only one
@@ -57,6 +59,11 @@
typedef ASTVector<&Action::DeleteStmt, 32> StmtVector;
/// A SmallVector of expressions, with stack size 12 (the maximum used.)
typedef ASTVector<&Action::DeleteExpr, 12> ExprVector;
+
+ template <ASTDestroyer Destroyer, unsigned N> inline
+ ASTMultiPtr<Destroyer> move_convert(ASTVector<Destroyer, N> &vec) {
+ return ASTMultiPtr<Destroyer>(vec.getActions(), vec.take(), vec.size());
+ }
}
#endif