diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-01-22 17:31:11 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-01-22 17:31:11 +0000 |
commit | 07c487e5f73c3e6ea47a03b674a4a0f753adf90f (patch) | |
tree | 7f38dca6d7be1d1ffd0bf90ab0ef70210ac7b722 /lib | |
parent | 21282df53bd86f737f84c4ae6d2dea7ef32f0895 (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Parse/AstGuard.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Parse/AstGuard.h b/lib/Parse/AstGuard.h index d755ea76c9..602fea51dc 100644 --- a/lib/Parse/AstGuard.h +++ b/lib/Parse/AstGuard.h @@ -26,6 +26,7 @@ namespace clang 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 @@ namespace clang 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 @@ namespace clang 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 } } |