[cfe-commits] r67983 - in /cfe/trunk/include/clang/Parse: Action.h Ownership.h

Chris Lattner sabre at nondot.org
Sat Mar 28 22:08:48 PDT 2009


Author: lattner
Date: Sun Mar 29 00:08:48 2009
New Revision: 67983

URL: http://llvm.org/viewvc/llvm-project?rev=67983&view=rev
Log:
Make the ActionResult optimization work for non-void*'s and switch DeclPtrTy to use it.

Modified:
    cfe/trunk/include/clang/Parse/Action.h
    cfe/trunk/include/clang/Parse/Ownership.h

Modified: cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Action.h?rev=67983&r1=67982&r2=67983&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/trunk/include/clang/Parse/Action.h Sun Mar 29 00:08:48 2009
@@ -47,7 +47,7 @@
   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

Modified: cfe/trunk/include/clang/Parse/Ownership.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Ownership.h?rev=67983&r1=67982&r2=67983&view=diff

==============================================================================
--- cfe/trunk/include/clang/Parse/Ownership.h (original)
+++ cfe/trunk/include/clang/Parse/Ownership.h Sun Mar 29 00:08:48 2009
@@ -230,7 +230,13 @@
         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 @@
 
       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;
       }





More information about the cfe-commits mailing list