[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdevplatform/language/duchain
From:       David Nolden <david.nolden.kde () art-master ! de>
Date:       2009-02-28 17:35:24
Message-ID: 1235842524.318866.4129.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 933336 by zwabel:

Better handling of alias-types


 M  +13 -5     declaration.cpp  
 M  +6 -2      types/typeutils.cpp  
 M  +1 -1      types/typeutils.h  


--- trunk/KDE/kdevplatform/language/duchain/declaration.cpp #933335:933336
@@ -46,6 +46,7 @@
 #include "codemodel.h"
 #include "specializationstore.h"
 #include "types/typeutils.h"
+#include "types/typealiastype.h"
 
 using namespace KTextEditor;
 
@@ -470,11 +471,18 @@
 
   if( d_func()->m_isTypeAlias ) {
     ///If this is a type-alias, return the internal context of the actual type.
-    AbstractType::Ptr t = TypeUtils::unAliasedType(abstractType());
-    
-    IdentifiedType* idType = dynamic_cast<IdentifiedType*>(t.unsafeData());
-    if( idType && idType->declaration(topContext) && idType->declaration(topContext) \
                != this )
-      return idType->declaration(topContext)->logicalInternalContext( topContext );
+    TypeAliasType::Ptr t = type<TypeAliasType>();
+    if(t) {
+      AbstractType::Ptr target = t->type();
+      
+      IdentifiedType* idType = dynamic_cast<IdentifiedType*>(target.unsafeData());
+      if( idType ) {
+        Declaration* decl = idType->declaration(topContext);
+        if(decl && decl != this) {
+          return decl->logicalInternalContext( topContext );
+        }
+      }
+    }
   }
 
   return internalContext();
--- trunk/KDE/kdevplatform/language/duchain/types/typeutils.cpp #933335:933336
@@ -45,19 +45,23 @@
 
     ReferenceType::Ptr ref = base.cast<ReferenceType>();
     PointerType::Ptr pnt = base.cast<PointerType>();
+    TypeAliasType::Ptr alias = base.cast<TypeAliasType>();
 
-    while( ref || pnt ) {
+    while( ref || pnt || alias ) {
       if( ref ) {
         if( constant )
           (*constant) |= static_cast<bool>(ref->modifiers() & \
AbstractType::ConstModifier);  base = ref->baseType();
-      } else {
+      } else if(pnt) {
         if( constant )
           (*constant) |= static_cast<bool>(pnt->modifiers() & \
AbstractType::ConstModifier);  base = pnt->baseType();
+      }else{
+        base = alias->type();
       }
       ref = base.cast<ReferenceType>();
       pnt = base.cast<PointerType>();
+      alias = base.cast<TypeAliasType>();
     }
 
     return base;
--- trunk/KDE/kdevplatform/language/duchain/types/typeutils.h #933335:933336
@@ -26,7 +26,7 @@
 }
 namespace TypeUtils {
   /**
-   * Returns the completely dereferenced type, pointers are also \
dereferenced(example: ReferenceType(PointerType(int)) -> int) +   * Returns the \
completely dereferenced and un-aliased type, pointers are also dereferenced(example: \
                ReferenceType(PointerType(int)) -> int)
    *
    *  !!DU-Chain must be locked!
   * @param constant will be set to true when one of the references made the result \
constant


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic