From 57ce399326c0f99e1be7521dab442c8f46466fc2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 29 Mar 2009 05:08:48 +0000 Subject: [PATCH] Make the ActionResult optimization work for non-void*'s and switch DeclPtrTy to use it. llvm-svn: 67983 --- clang/include/clang/Parse/Action.h | 2 +- clang/include/clang/Parse/Ownership.h | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/clang/include/clang/Parse/Action.h b/clang/include/clang/Parse/Action.h index b1174672f20e..84023d667868 100644 --- a/clang/include/clang/Parse/Action.h +++ b/clang/include/clang/Parse/Action.h @@ -47,7 +47,7 @@ namespace clang { template<> struct IsResultPtrLowBitFree<1> { static const bool value = true;}; template<> struct IsResultPtrLowBitFree<3> { static const bool value = true;}; template<> struct IsResultPtrLowBitFree<4> { static const bool value = true;}; -//template<> struct IsResultPtrLowBitFree<5> { static const bool value = true;}; + template<> struct IsResultPtrLowBitFree<5> { static const bool value = true;}; /// Action - As the parser reads the input file and recognizes the productions /// of the grammar, it invokes methods on this class to turn the parsed input diff --git a/clang/include/clang/Parse/Ownership.h b/clang/include/clang/Parse/Ownership.h index 1f5c4f886506..6445254aad5b 100644 --- a/clang/include/clang/Parse/Ownership.h +++ b/clang/include/clang/Parse/Ownership.h @@ -230,7 +230,13 @@ namespace clang PtrWithInvalid = reinterpret_cast(VP); assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer"); } - + + ActionResult(PtrTy V) { + void *VP = PtrTraits::getAsVoidPointer(V); + PtrWithInvalid = reinterpret_cast(VP); + assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer"); + } + ActionResult(const DiagnosticBuilder &) : PtrWithInvalid(0x01) { } PtrTy get() const { @@ -246,8 +252,9 @@ namespace clang bool isInvalid() const { return PtrWithInvalid & 0x01; } - const ActionResult &operator=(void *RHS) { - PtrWithInvalid = reinterpret_cast(RHS); + const ActionResult &operator=(PtrTy RHS) { + void *VP = PtrTraits::getAsVoidPointer(RHS); + PtrWithInvalid = reinterpret_cast(VP); assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer"); return *this; }