]> granicus.if.org Git - clang/commitdiff
Make the ActionResult optimization work for non-void*'s and switch DeclPtrTy to use it.
authorChris Lattner <sabre@nondot.org>
Sun, 29 Mar 2009 05:08:48 +0000 (05:08 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 29 Mar 2009 05:08:48 +0000 (05:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67983 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Action.h
include/clang/Parse/Ownership.h

index b1174672f20ead1a84dd768a3c798e2f98a1537f..84023d667868ed934c188374d2c50252b78cf154 100644 (file)
@@ -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
index 1f5c4f886506f7ff8870536aca7304478b5d26c2..6445254aad5b9b9e6de4bf3dff3f4119c3b53362 100644 (file)
@@ -230,7 +230,13 @@ namespace clang
         PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
         assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
       }
-
+      
+      ActionResult(PtrTy V) {
+        void *VP = PtrTraits::getAsVoidPointer(V);
+        PtrWithInvalid = reinterpret_cast<uintptr_t>(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<uintptr_t>(RHS);
+      const ActionResult &operator=(PtrTy RHS) {
+        void *VP = PtrTraits::getAsVoidPointer(RHS);
+        PtrWithInvalid = reinterpret_cast<uintptr_t>(VP);
         assert((PtrWithInvalid & 0x01) == 0 && "Badly aligned pointer");
         return *this;
       }