[Lldb-commits] [lldb] r227383 - Add logic to ClangASTType and SBType to discover information about vector types

Enrico Granata egranata at apple.com
Wed Jan 28 14:18:02 PST 2015


Author: enrico
Date: Wed Jan 28 16:18:02 2015
New Revision: 227383

URL: http://llvm.org/viewvc/llvm-project?rev=227383&view=rev
Log:
Add logic to ClangASTType and SBType to discover information about vector types

Modified:
    lldb/trunk/include/lldb/API/SBType.h
    lldb/trunk/include/lldb/Symbol/ClangASTType.h
    lldb/trunk/scripts/Python/interface/SBType.i
    lldb/trunk/source/API/SBType.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp

Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=227383&r1=227382&r2=227383&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Wed Jan 28 16:18:02 2015
@@ -153,6 +153,9 @@ public:
     IsArrayType ();
     
     bool
+    IsVectorType ();
+    
+    bool
     IsTypedefType ();
     
     lldb::SBType
@@ -175,6 +178,9 @@ public:
     
     lldb::SBType
     GetArrayElementType ();
+    
+    lldb::SBType
+    GetVectorElementType ();
 
     lldb::SBType
     GetCanonicalType();

Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=227383&r1=227382&r2=227383&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Wed Jan 28 16:18:02 2015
@@ -97,6 +97,10 @@ public:
                  bool *is_incomplete) const;
 
     bool
+    IsVectorType (ClangASTType *element_type,
+                  uint64_t *size) const;
+    
+    bool
     IsArrayOfScalarType () const;
 
     bool

Modified: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=227383&r1=227382&r2=227383&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (original)
+++ lldb/trunk/scripts/Python/interface/SBType.i Wed Jan 28 16:18:02 2015
@@ -210,6 +210,9 @@ public:
     IsArrayType ();
     
     bool
+    IsVectorType ();
+    
+    bool
     IsTypedefType ();
     
     lldb::SBType
@@ -235,6 +238,9 @@ public:
     
     lldb::SBType
     GetArrayElementType ();
+    
+    lldb::SBType
+    GetVectorElementType ();
 
     lldb::BasicType
     GetBasicType();

Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=227383&r1=227382&r2=227383&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Wed Jan 28 16:18:02 2015
@@ -164,6 +164,14 @@ SBType::IsArrayType()
 }
 
 bool
+SBType::IsVectorType()
+{
+    if (!IsValid())
+        return false;
+    return m_opaque_sp->GetClangASTType(true).IsVectorType(nullptr, nullptr);
+}
+
+bool
 SBType::IsReferenceType()
 {
     if (!IsValid())
@@ -220,7 +228,20 @@ SBType::GetArrayElementType()
     return SBType(TypeImplSP(new TypeImpl(m_opaque_sp->GetClangASTType(true).GetArrayElementType())));
 }
 
-bool 
+SBType
+SBType::GetVectorElementType ()
+{
+    SBType type_sb;
+    if (IsValid())
+    {
+        ClangASTType vector_element_type;
+        if (m_opaque_sp->GetClangASTType(true).IsVectorType(&vector_element_type, nullptr))
+            type_sb.SetSP(TypeImplSP(new TypeImpl(vector_element_type)));
+    }
+    return type_sb;
+}
+
+bool
 SBType::IsFunctionType ()
 {
     if (!IsValid())

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=227383&r1=227382&r2=227383&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed Jan 28 16:18:02 2015
@@ -290,6 +290,37 @@ ClangASTType::IsArrayType (ClangASTType
 }
 
 bool
+ClangASTType::IsVectorType (ClangASTType *element_type,
+                            uint64_t *size) const
+{
+    if (IsValid())
+    {
+        clang::QualType qual_type (GetCanonicalQualType());
+        
+        const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+        switch (type_class)
+        {
+            case clang::Type::Vector:
+            {
+                const clang::VectorType *vector_type = qual_type->getAs<clang::VectorType>();
+                if (vector_type)
+                {
+                    if (size)
+                        *size = vector_type->getNumElements();
+                    if (element_type)
+                        *element_type = ClangASTType(m_ast, vector_type->getElementType().getAsOpaquePtr());
+                }
+                return true;
+            }
+                break;
+            default:
+                break;
+        }
+    }
+    return false;
+}
+
+bool
 ClangASTType::IsRuntimeGeneratedType () const
 {
     if (!IsValid())





More information about the lldb-commits mailing list