[Lldb-commits] [lldb] r134823 - /lldb/trunk/source/Symbol/ClangASTContext.cpp

Greg Clayton gclayton at apple.com
Sat Jul 9 10:12:27 PDT 2011


Author: gclayton
Date: Sat Jul  9 12:12:27 2011
New Revision: 134823

URL: http://llvm.org/viewvc/llvm-project?rev=134823&view=rev
Log:
Fixed an issue with getting the size of an array from an opaque clang_type_t
variable where we were using a static cast when we shouldn't have been.
Fixed another array related issue where we weren't looking through a typedef.


Modified:
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=134823&r1=134822&r2=134823&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Sat Jul  9 12:12:27 2011
@@ -4624,9 +4624,21 @@
 {
     if (clang_type)
     {
-        const ConstantArrayType *array = cast<ConstantArrayType>(QualType::getFromOpaquePtr(clang_type).getTypePtr());
-        if (array)
-            return array->getSize().getLimitedValue();
+        QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+        const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+        switch (type_class)
+        {
+        case clang::Type::ConstantArray:
+            {
+                const ConstantArrayType *array = cast<ConstantArrayType>(QualType::getFromOpaquePtr(clang_type).getTypePtr());
+                if (array)
+                    return array->getSize().getLimitedValue();
+            }
+            break;
+
+        case clang::Type::Typedef:
+            return ClangASTContext::GetArraySize(cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+        }
     }
     return 0;
 }
@@ -4644,30 +4656,39 @@
     {
     default:
         break;
+
     case clang::Type::ConstantArray:
         if (member_type)
             *member_type = cast<ConstantArrayType>(qual_type)->getElementType().getAsOpaquePtr();
         if (size)
             *size = cast<ConstantArrayType>(qual_type)->getSize().getLimitedValue(ULLONG_MAX);
         return true;
+
     case clang::Type::IncompleteArray:
         if (member_type)
             *member_type = cast<IncompleteArrayType>(qual_type)->getElementType().getAsOpaquePtr();
         if (size)
             *size = 0;
         return true;
+
     case clang::Type::VariableArray:
         if (member_type)
             *member_type = cast<VariableArrayType>(qual_type)->getElementType().getAsOpaquePtr();
         if (size)
             *size = 0;
         return true;
+
     case clang::Type::DependentSizedArray:
         if (member_type)
             *member_type = cast<DependentSizedArrayType>(qual_type)->getElementType().getAsOpaquePtr();
         if (size)
             *size = 0;
         return true;
+    
+    case clang::Type::Typedef:
+        return ClangASTContext::IsArrayType (cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
+                                             member_type, 
+                                             size);
     }
     return false;
 }





More information about the lldb-commits mailing list