Add a switch that allows disabling the smart pointers.
Uncomment the define in Ownership.h to disable the smart pointers.
Disabled, the smart pointers no longer contain a pointer
to the action, and no longer have special destruction or
copying semantics. They are, compiler willing, raw
pointers or ActionResult equivalents.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62767 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Parse/AstGuard.h b/lib/Parse/AstGuard.h
index d755ea7..602fea5 100644
--- a/lib/Parse/AstGuard.h
+++ b/lib/Parse/AstGuard.h
@@ -26,6 +26,7 @@
template <ASTDestroyer Destroyer, unsigned N>
class ASTVector : public llvm::SmallVector<void*, N> {
private:
+#if !defined(DISABLE_SMART_POINTERS)
Action &Actions;
bool Owns;
@@ -40,18 +41,27 @@
ASTVector(const ASTVector&); // DO NOT IMPLEMENT
// Reference member prevents copy assignment.
+#endif
public:
+#if !defined(DISABLE_SMART_POINTERS)
ASTVector(Action &actions) : Actions(actions), Owns(true) {}
~ASTVector() { destroy(); }
+#else
+ ASTVector(Action &) {}
+#endif
void **take() {
+#if !defined(DISABLE_SMART_POINTERS)
Owns = false;
+#endif
return &(*this)[0];
}
+#if !defined(DISABLE_SMART_POINTERS)
Action &getActions() const { return Actions; }
+#endif
};
/// A SmallVector of statements, with stack size 32 (as that is the only one
@@ -62,7 +72,11 @@
template <ASTDestroyer Destroyer, unsigned N> inline
ASTMultiPtr<Destroyer> move_arg(ASTVector<Destroyer, N> &vec) {
+#if !defined(DISABLE_SMART_POINTERS)
return ASTMultiPtr<Destroyer>(vec.getActions(), vec.take(), vec.size());
+#else
+ return ASTMultiPtr<Destroyer>(vec.take(), vec.size());
+#endif
}
}