[Lldb-commits] [lldb] r139428 - in /lldb/trunk: include/lldb/API/SBFrame.h include/lldb/API/SBType.h include/lldb/API/SBValue.h include/lldb/Symbol/ClangASTContext.h include/lldb/Symbol/ClangASTType.h include/lldb/Symbol/Type.h include/lldb/lldb-enumerations.h include/lldb/lldb-forward.h scripts/Python/interface/SBType.i scripts/Python/interface/SBValue.i source/API/SBFrame.cpp source/API/SBType.cpp source/API/SBValue.cpp source/Symbol/ClangASTContext.cpp source/Symbol/ClangASTType.cpp

Greg Clayton gclayton at apple.com
Fri Sep 9 16:04:00 PDT 2011


Author: gclayton
Date: Fri Sep  9 18:04:00 2011
New Revision: 139428

URL: http://llvm.org/viewvc/llvm-project?rev=139428&view=rev
Log:
Added the ability to introspect types thourgh the public SBType interface.

Fixed up many API calls to not be "const" as const doesn't mean anything to
most of our lldb::SB objects since they contain a shared pointer, auto_ptr, or
pointer to the types which circumvent the constness anyway.


Modified:
    lldb/trunk/include/lldb/API/SBFrame.h
    lldb/trunk/include/lldb/API/SBType.h
    lldb/trunk/include/lldb/API/SBValue.h
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/include/lldb/Symbol/ClangASTType.h
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/scripts/Python/interface/SBType.i
    lldb/trunk/scripts/Python/interface/SBValue.i
    lldb/trunk/source/API/SBFrame.cpp
    lldb/trunk/source/API/SBType.cpp
    lldb/trunk/source/API/SBValue.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp

Modified: lldb/trunk/include/lldb/API/SBFrame.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBFrame.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBFrame.h (original)
+++ lldb/trunk/include/lldb/API/SBFrame.h Fri Sep  9 18:04:00 2011
@@ -200,8 +200,8 @@
     lldb_private::StackFrame *
     get() const;
 
-    const lldb::StackFrameSP &
-    get_sp() const;
+    lldb::StackFrameSP &
+    get_sp();
     
 #endif
 

Modified: lldb/trunk/include/lldb/API/SBType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBType.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBType.h (original)
+++ lldb/trunk/include/lldb/API/SBType.h Fri Sep  9 18:04:00 2011
@@ -16,78 +16,148 @@
 
 class SBTypeList;    
 
-class SBType
+class SBTypeMember
 {
 public:
-
-    SBType (const SBType &rhs);
-
-    ~SBType ();
-
-#ifndef SWIG
-    const lldb::SBType &
-    operator = (const lldb::SBType &rhs);
+    SBTypeMember ();
     
-    bool
-    operator == (const lldb::SBType &rhs) const;
+    SBTypeMember (const lldb::SBTypeMember& rhs);
+    
+    ~SBTypeMember();
     
+#ifndef SWIG
+    lldb::SBTypeMember&
+    operator = (const lldb::SBTypeMember& rhs);
+#endif
+
     bool
-    operator != (const lldb::SBType &rhs) const;
+    IsValid() const;
     
-    lldb_private::TypeImpl &
-    ref ();
+    const char *
+    GetName ();
     
-    const lldb_private::TypeImpl &
-    ref () const;
+    lldb::SBType
+    GetType ();
     
-#endif
+    uint64_t
+    GetOffsetByteSize();
     
+protected:
+    friend class SBType;
+
+#ifndef SWIG
+    void
+    reset (lldb_private::TypeMemberImpl *);
+
+    lldb_private::TypeMemberImpl &
+    ref ();
+
+    const lldb_private::TypeMemberImpl &
+    ref () const;
+#endif
+
+    std::auto_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
+};
+
+class SBType
+{
+public:
+
+    SBType();
+
+    SBType (const lldb::SBType &rhs);
+
+    ~SBType ();
+
     bool
     IsValid() const;
     
     size_t
-    GetByteSize() const;
+    GetByteSize();
 
     bool
-    IsPointerType() const;
+    IsPointerType();
     
     bool
-    IsReferenceType() const;
+    IsReferenceType();
     
-    SBType
-    GetPointerType() const;
+    lldb::SBType
+    GetPointerType();
     
-    SBType
-    GetPointeeType() const;
+    lldb::SBType
+    GetPointeeType();
     
-    SBType
-    GetReferenceType() const;
+    lldb::SBType
+    GetReferenceType();
     
-    SBType
-    GetDereferencedType() const;
+    lldb::SBType
+    GetDereferencedType();
     
-    SBType
-    GetBasicType(lldb::BasicType type) const;
-        
+    lldb::SBType
+    GetBasicType(lldb::BasicType type);
+    
+    uint32_t
+    GetNumberOfFields ();
+    
+    uint32_t
+    GetNumberOfDirectBaseClasses ();
+
+    uint32_t
+    GetNumberOfVirtualBaseClasses ();
+    
+    lldb::SBTypeMember
+    GetFieldAtIndex (uint32_t idx);
+    
+    lldb::SBTypeMember
+    GetDirectBaseClassAtIndex (uint32_t idx);
+
+    lldb::SBTypeMember
+    GetVirtualBaseClassAtIndex (uint32_t idx);
+
     const char*
     GetName();
     
+    lldb::TypeClass
+    GetTypeClass ();
+
     // DEPRECATED: but needed for Xcode right now
     static bool
     IsPointerType (void * clang_type);
         
 protected:
+    
+#ifndef SWIG
+    lldb::SBType &
+    operator = (const lldb::SBType &rhs);
+    
+    bool
+    operator == (lldb::SBType &rhs);
+    
+    bool
+    operator != (lldb::SBType &rhs);
+    
+    lldb_private::TypeImpl &
+    ref ();
+    
+    const lldb_private::TypeImpl &
+    ref () const;
+    
+    void
+    reset(const lldb::TypeImplSP &type_impl_sp);
+#endif
+    
+
     lldb::TypeImplSP m_opaque_sp;
     
     friend class SBModule;
     friend class SBTarget;
     friend class SBValue;
+    friend class SBTypeMember;
     friend class SBTypeList;
         
     SBType (const lldb_private::ClangASTType &);
     SBType (const lldb::TypeSP &);
     SBType (const lldb::TypeImplSP &);
-    SBType();
     
 };
     
@@ -96,28 +166,30 @@
 public:
     SBTypeList();
     
-    SBTypeList(const SBTypeList& rhs);
+    SBTypeList(const lldb::SBTypeList& rhs);
     
-    SBTypeList&
-    operator = (const SBTypeList& rhs);
+    ~SBTypeList();
+
+    lldb::SBTypeList&
+    operator = (const lldb::SBTypeList& rhs);
     
     bool
-    IsValid() const;
+    IsValid();
 
     void
-    Append (const SBType& type);
+    Append (lldb::SBType type);
     
-    SBType
-    GetTypeAtIndex(int index) const;
+    lldb::SBType
+    GetTypeAtIndex (uint32_t index);
     
-    int
-    GetSize() const;
+    uint32_t
+    GetSize();
     
-    ~SBTypeList();
     
 private:
     std::auto_ptr<lldb_private::TypeListImpl> m_opaque_ap;
 };
+    
 
 } // namespace lldb
 

Modified: lldb/trunk/include/lldb/API/SBValue.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/API/SBValue.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/API/SBValue.h (original)
+++ lldb/trunk/include/lldb/API/SBValue.h Fri Sep  9 18:04:00 2011
@@ -22,17 +22,17 @@
 public:
     SBValue ();
 
-    SBValue (const SBValue &rhs);
+    SBValue (const lldb::SBValue &rhs);
 
 #ifndef SWIG
-    const SBValue &
-    operator =(const SBValue &rhs);
+    lldb::SBValue &
+    operator =(const lldb::SBValue &rhs);
 #endif
 
     ~SBValue ();
 
     bool
-    IsValid() const;
+    IsValid();
     
     SBError
     GetError();
@@ -50,28 +50,22 @@
     GetByteSize ();
 
     bool
-    IsInScope (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
-
-    bool
     IsInScope ();
 
     lldb::Format
-    GetFormat () const;
+    GetFormat ();
     
     void
     SetFormat (lldb::Format format);
 
     const char *
-    GetValue (const lldb::SBFrame &frame);   // DEPRECATED - SBValues know their own frames.
-
-    const char *
     GetValue ();
 
     int64_t
-    GetValueAsSigned(SBError& error, int64_t fail_value=0);
+    GetValueAsSigned (lldb::SBError& error, int64_t fail_value=0);
     
     uint64_t
-    GetValueAsUnsigned(SBError& error, uint64_t fail_value=0);
+    GetValueAsUnsigned (lldb::SBError& error, uint64_t fail_value=0);
     
     int64_t
     GetValueAsSigned(int64_t fail_value=0);
@@ -83,56 +77,43 @@
     GetValueType ();
 
     bool
-    GetValueDidChange (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
-
-    bool
     GetValueDidChange ();
 
     const char *
-    GetSummary (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
-    
-    const char *
     GetSummary ();
     
     const char *
-    GetObjectDescription (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
-
-    const char *
     GetObjectDescription ();
 
     const char *
-    GetLocation (const lldb::SBFrame &frame);  // DEPRECATED - SBValues know their own frames.
-
-    const char *
     GetLocation ();
 
     bool
-    SetValueFromCString (const lldb::SBFrame &frame, const char *value_str);  // DEPRECATED - SBValues know their own frames.
-
-    bool
     SetValueFromCString (const char *value_str);
 
     lldb::SBValue
     GetChildAtIndex (uint32_t idx);
     
     lldb::SBValue
-    CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type);
+    CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type);
     
     lldb::SBValue
-    Cast(const SBType& type);
+    Cast (lldb::SBType type);
     
     lldb::SBValue
     CreateValueFromExpression (const char *name, const char* expression);
     
     lldb::SBValue
-    CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type);
+    CreateValueFromAddress (const char* name, 
+                            lldb::addr_t address, 
+                            lldb::SBType type);
     
     // this has no address! GetAddress() and GetLoadAddress() as well as AddressOf()
     // on the return of this call all return invalid
     lldb::SBValue
     CreateValueFromData (const char* name,
-                         const SBData& data,
-                         const SBType& type);
+                         lldb::SBData data,
+                         lldb::SBType type);
 
     //------------------------------------------------------------------
     /// Get a child value by index from a value.
@@ -279,7 +260,7 @@
     bool
     TypeIsPointerType ();
     
-    SBType
+    lldb::SBType
     GetType();
 
     bool
@@ -289,7 +270,8 @@
     GetExpressionPath (lldb::SBStream &description);
     
     bool
-    GetExpressionPath (lldb::SBStream &description, bool qualify_cxx_base_classes);
+    GetExpressionPath (lldb::SBStream &description, 
+                       bool qualify_cxx_base_classes);
 
     SBValue (const lldb::ValueObjectSP &value_sp);
 
@@ -298,8 +280,8 @@
     // currently rely on being able to extract the SharedPointer out of an SBValue. if the implementation
     // is deferred to the .cpp file instead of being inlined here, the platform will fail to link
     // correctly. however, this is temporary till a better general solution is found. FIXME
-    const lldb::ValueObjectSP&
-    get_sp() const
+    lldb::ValueObjectSP&
+    get_sp()
     {
         return m_opaque_sp;
     }

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Fri Sep  9 18:04:00 2011
@@ -413,6 +413,37 @@
                     lldb::clang_type_t clang_type,
                     bool omit_empty_base_classes);
 
+    static uint32_t 
+    GetNumDirectBaseClasses (clang::ASTContext *ast, 
+                             lldb::clang_type_t clang_type);
+
+    static uint32_t 
+    GetNumVirtualBaseClasses (clang::ASTContext *ast, 
+                              lldb::clang_type_t clang_type);
+
+    static uint32_t 
+    GetNumFields (clang::ASTContext *ast, 
+                  lldb::clang_type_t clang_type);
+    
+    static lldb::clang_type_t
+    GetDirectBaseClassAtIndex (clang::ASTContext *ast, 
+                               lldb::clang_type_t clang_type,
+                               uint32_t idx, 
+                               uint32_t *byte_offset_ptr);
+
+    static lldb::clang_type_t
+    GetVirtualBaseClassAtIndex (clang::ASTContext *ast, 
+                                lldb::clang_type_t clang_type,
+                                uint32_t idx, 
+                                uint32_t *byte_offset_ptr);
+
+    static lldb::clang_type_t
+    GetFieldAtIndex (clang::ASTContext *ast, 
+                     lldb::clang_type_t clang_type,
+                     uint32_t idx, 
+                     std::string& name,
+                     uint32_t *byte_offset_ptr);
+
     static uint32_t
     GetNumPointeeChildren (lldb::clang_type_t clang_type);
 

Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Fri Sep  9 18:04:00 2011
@@ -107,6 +107,10 @@
     GetMinimumLanguage (clang::ASTContext *ctx,
                         lldb::clang_type_t clang_type);
 
+    static lldb::TypeClass
+    GetTypeClass (clang::ASTContext *ast_context, 
+                  lldb::clang_type_t clang_type);
+
     void
     DumpValue (ExecutionContext *exe_ctx,
                Stream *s,

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Fri Sep  9 18:04:00 2011
@@ -390,6 +390,57 @@
 private:
     std::vector<lldb::TypeImplSP> m_content;
 };
+    
+class TypeMemberImpl
+{
+public:
+    TypeMemberImpl () :
+        m_type_impl_sp (),
+        m_bit_offset (0),
+        m_name ()
+    {
+    }
+
+    TypeMemberImpl (const lldb::TypeImplSP &type_impl_sp, 
+                    uint64_t bit_offset,
+                    const ConstString &name) :
+        m_type_impl_sp (type_impl_sp),
+        m_bit_offset (bit_offset),
+        m_name (name)
+    {
+    }
+    
+    TypeMemberImpl (const lldb::TypeImplSP &type_impl_sp, 
+                    uint64_t bit_offset):
+        m_type_impl_sp (type_impl_sp),
+        m_bit_offset (bit_offset),
+        m_name ()
+    {
+    }
+
+    const lldb::TypeImplSP &
+    GetTypeImpl ()
+    {
+        return m_type_impl_sp;
+    }
+
+    const ConstString &
+    GetName () const
+    {
+        return m_name;
+    }
+
+    uint64_t
+    GetBitOffset () const
+    {
+        return m_bit_offset;
+    }
+
+protected:
+    lldb::TypeImplSP m_type_impl_sp;
+    uint64_t m_bit_offset;
+    ConstString m_name;
+};
 
     
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Sep  9 18:04:00 2011
@@ -550,7 +550,34 @@
         eBasicTypeObjCClass,
         eBasicTypeObjCSel
     } BasicType;
-        
+
+    typedef enum TypeClass
+    {
+        eTypeClassInvalid           = (0u),
+        eTypeClassArray             = (1u << 0),
+        eTypeClassBlockPointer      = (1u << 1),
+        eTypeClassBuiltin           = (1u << 2),
+        eTypeClassClass             = (1u << 3),
+        eTypeClassComplexFloat      = (1u << 4),
+        eTypeClassComplexInteger    = (1u << 5),
+        eTypeClassEnumeration       = (1u << 6),
+        eTypeClassFunction          = (1u << 7),
+        eTypeClassMemberPointer     = (1u << 8),
+        eTypeClassObjCObject        = (1u << 9),
+        eTypeClassObjCInterface     = (1u << 10),
+        eTypeClassObjCObjectPointer = (1u << 11),
+        eTypeClassPointer           = (1u << 12),
+        eTypeClassReference         = (1u << 13),
+        eTypeClassStruct            = (1u << 14),
+        eTypeClassTypedef           = (1u << 15),
+        eTypeClassUnion             = (1u << 16),
+        eTypeClassVector            = (1u << 17),
+        // Define the last type class as the MSBit of a 32 bit value
+        eTypeClassOther             = (1u << 31),
+        // Define a mask that can be used for any type when finding types
+        eTypeClassAny               = (0xffffffffu)
+    }TypeClass;
+
 } // namespace lldb
 
 

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Fri Sep  9 18:04:00 2011
@@ -170,6 +170,7 @@
 class   TypeAndOrName;
 class   TypeList;
 class   TypeListImpl;
+class   TypeMemberImpl;    
 class   UUID;
 class   Unwind;
 class   UnwindAssembly;

Modified: lldb/trunk/scripts/Python/interface/SBType.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBType.i?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBType.i (original)
+++ lldb/trunk/scripts/Python/interface/SBType.i Fri Sep  9 18:04:00 2011
@@ -9,6 +9,35 @@
 
 namespace lldb {
 
+    %feature("docstring",
+"Represents a member of a type in lldb.
+") SBTypeMember;
+
+class SBTypeMember
+{
+public:
+    SBTypeMember ();
+
+    SBTypeMember (const lldb::SBTypeMember& rhs);
+
+    ~SBTypeMember();
+
+    bool
+    IsValid() const;
+
+    const char *
+    GetName ();
+
+    lldb::SBType
+    GetType ();
+
+    uint64_t
+    GetOffsetByteSize();
+
+protected:
+    std::auto_ptr<lldb_private::TypeMemberImpl> m_opaque_ap;
+};
+
 %feature("docstring",
 "Represents a data type in lldb.  The FindFirstType() method of SBTarget/SBModule
 returns a SBType.
@@ -85,39 +114,60 @@
 class SBType
 {
 public:
-    SBType (const SBType &rhs);
+    SBType (const lldb::SBType &rhs);
 
     ~SBType ();
 
     bool
-    IsValid() const;
+    IsValid();
 
     size_t
-    GetByteSize() const;
+    GetByteSize();
 
     bool
-    IsPointerType() const;
+    IsPointerType();
 
     bool
-    IsReferenceType() const;
-
-    SBType
-    GetPointerType() const;
+    IsReferenceType();
 
-    SBType
-    GetPointeeType() const;
+    lldb::SBType
+    GetPointerType();
 
-    SBType
-    GetReferenceType() const;
+    lldb::SBType
+    GetPointeeType();
 
-    SBType
-    GetDereferencedType() const;
-
-    SBType
-    GetBasicType(lldb::BasicType type) const;
+    lldb::SBType
+    GetReferenceType();
+
+    lldb::SBType
+    GetDereferencedType();
+
+    lldb::SBType
+    GetBasicType (lldb::BasicType type);
+
+    uint32_t
+    GetNumberOfFields ();
+    
+    uint32_t
+    GetNumberOfDirectBaseClasses ();
+    
+    uint32_t
+    GetNumberOfVirtualBaseClasses ();
+    
+    lldb::SBTypeMember
+    GetFieldAtIndex (uint32_t idx);
+    
+    lldb::SBTypeMember
+    GetDirectBaseClassAtIndex (uint32_t idx);
+    
+    lldb::SBTypeMember
+    GetVirtualBaseClassAtIndex (uint32_t idx);
 
     const char*
     GetName();
+    
+    lldb::TypeClass
+    GetTypeClass ();
 };
 
 %feature("docstring",
@@ -157,15 +207,15 @@
     SBTypeList();
 
     bool
-    IsValid() const;
+    IsValid();
 
     void
-    Append(const SBType& type);
+    Append (lldb::SBType type);
 
-    SBType
-    GetTypeAtIndex(int index);
+    lldb::SBType
+    GetTypeAtIndex (uint32_t index);
 
-    int
+    uint32_t
     GetSize();
 
     ~SBTypeList();

Modified: lldb/trunk/scripts/Python/interface/SBValue.i
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/interface/SBValue.i?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/interface/SBValue.i (original)
+++ lldb/trunk/scripts/Python/interface/SBValue.i Fri Sep  9 18:04:00 2011
@@ -65,7 +65,7 @@
     ~SBValue ();
 
     bool
-    IsValid() const;
+    IsValid();
     
     SBError
     GetError();
@@ -86,7 +86,7 @@
     IsInScope ();
 
     lldb::Format
-    GetFormat () const;
+    GetFormat ();
     
     void
     SetFormat (lldb::Format format);
@@ -185,21 +185,21 @@
                      bool can_create_synthetic);
     
     lldb::SBValue
-    CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type);
+    CreateChildAtOffset (const char *name, uint32_t offset, lldb::SBType type);
     
     lldb::SBValue
-    SBValue::Cast(const SBType& type);
+    SBValue::Cast (lldb::SBType type);
 
     lldb::SBValue
     CreateValueFromExpression (const char *name, const char* expression);
 
     lldb::SBValue
-    CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type);
+    CreateValueFromAddress(const char* name, lldb::addr_t address, lldb::SBType type);
     
 	lldb::SBValue
 	CreateValueFromData (const char* name,
-	                     const SBData& data,
-	                     const SBType& type);
+	                     lldb::SBData data,
+	                     lldb::SBType type);
 
     lldb::SBType
     GetType();

Modified: lldb/trunk/source/API/SBFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBFrame.cpp?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/source/API/SBFrame.cpp (original)
+++ lldb/trunk/source/API/SBFrame.cpp Fri Sep  9 18:04:00 2011
@@ -538,8 +538,8 @@
     return m_opaque_sp.get();
 }
 
-const lldb::StackFrameSP &
-SBFrame::get_sp() const
+lldb::StackFrameSP &
+SBFrame::get_sp()
 {
     return m_opaque_sp;
 }

Modified: lldb/trunk/source/API/SBType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBType.cpp?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/source/API/SBType.cpp (original)
+++ lldb/trunk/source/API/SBType.cpp Fri Sep  9 18:04:00 2011
@@ -31,7 +31,7 @@
 {
 }
 
-SBType::SBType (const lldb_private::ClangASTType &type) :
+SBType::SBType (const ClangASTType &type) :
     m_opaque_sp(new TypeImpl(ClangASTType(type.GetASTContext(),
                                           type.GetOpaqueQualType())))
 {
@@ -63,7 +63,7 @@
 //{}
 //
 bool
-SBType::operator == (const lldb::SBType &rhs) const
+SBType::operator == (SBType &rhs)
 {
     if (IsValid() == false)
         return !rhs.IsValid();
@@ -73,7 +73,7 @@
 }
 
 bool
-SBType::operator != (const lldb::SBType &rhs) const
+SBType::operator != (SBType &rhs)
 {    
     if (IsValid() == false)
         return rhs.IsValid();
@@ -82,11 +82,16 @@
             (rhs.m_opaque_sp->GetOpaqueQualType() != m_opaque_sp->GetOpaqueQualType());
 }
 
+void
+SBType::reset(const lldb::TypeImplSP &type_impl_sp)
+{
+    m_opaque_sp = type_impl_sp;
+}
 
-const lldb::SBType &
-SBType::operator = (const lldb::SBType &rhs)
+SBType &
+SBType::operator = (const SBType &rhs)
 {
-    if (*this != rhs)
+    if (this != &rhs)
     {
         m_opaque_sp = rhs.m_opaque_sp;
     }
@@ -96,15 +101,15 @@
 SBType::~SBType ()
 {}
 
-lldb_private::TypeImpl &
+TypeImpl &
 SBType::ref ()
 {
     if (m_opaque_sp.get() == NULL)
-        m_opaque_sp.reset (new lldb_private::TypeImpl());
+        m_opaque_sp.reset (new TypeImpl());
         return *m_opaque_sp;
 }
 
-const lldb_private::TypeImpl &
+const TypeImpl &
 SBType::ref () const
 {
     // "const SBAddress &addr" should already have checked "addr.IsValid()" 
@@ -124,7 +129,7 @@
 }
 
 size_t
-SBType::GetByteSize() const
+SBType::GetByteSize()
 {
     if (!IsValid())
         return 0;
@@ -134,7 +139,7 @@
 }
 
 bool
-SBType::IsPointerType() const
+SBType::IsPointerType()
 {
     if (!IsValid())
         return false;
@@ -148,7 +153,7 @@
 }
 
 bool
-SBType::IsReferenceType() const
+SBType::IsReferenceType()
 {
     if (!IsValid())
         return false;
@@ -162,7 +167,7 @@
 }
 
 SBType
-SBType::GetPointerType() const
+SBType::GetPointerType()
 {
     if (!IsValid())
         return SBType();
@@ -172,7 +177,7 @@
 }
 
 SBType
-SBType::GetPointeeType() const
+SBType::GetPointeeType()
 {
     if (!IsValid())
         return SBType();
@@ -186,7 +191,7 @@
 }
 
 SBType
-SBType::GetReferenceType() const
+SBType::GetReferenceType()
 {
     if (!IsValid())
         return SBType();
@@ -196,7 +201,7 @@
 }
 
 SBType
-SBType::GetDereferencedType() const
+SBType::GetDereferencedType()
 {
     if (!IsValid())
         return SBType();
@@ -207,7 +212,7 @@
 }
 
 SBType
-SBType::GetBasicType(lldb::BasicType type) const
+SBType::GetBasicType(lldb::BasicType type)
 {
     
     if (!IsValid())
@@ -302,6 +307,89 @@
     return SBType(ClangASTType(m_opaque_sp->GetASTContext(), base_type_qual.getAsOpaquePtr()));
 }
 
+uint32_t
+SBType::GetNumberOfDirectBaseClasses ()
+{
+    if (IsValid())
+        return ClangASTContext::GetNumDirectBaseClasses(m_opaque_sp->GetASTContext(), m_opaque_sp->GetOpaqueQualType());
+    return 0;
+}
+
+uint32_t
+SBType::GetNumberOfVirtualBaseClasses ()
+{
+    if (IsValid())
+        return ClangASTContext::GetNumVirtualBaseClasses(m_opaque_sp->GetASTContext(), m_opaque_sp->GetOpaqueQualType());
+    return 0;
+}
+
+uint32_t
+SBType::GetNumberOfFields ()
+{
+    if (IsValid())
+        return ClangASTContext::GetNumFields(m_opaque_sp->GetASTContext(), m_opaque_sp->GetOpaqueQualType());
+    return 0;
+}
+
+SBTypeMember
+SBType::GetDirectBaseClassAtIndex (uint32_t idx)
+{
+    SBTypeMember sb_type_member;
+    if (IsValid())
+    {
+        clang::ASTContext* ast = m_opaque_sp->GetASTContext();
+        uint32_t byte_offset = 0;
+        clang_type_t clang_type = ClangASTContext::GetDirectBaseClassAtIndex (ast, m_opaque_sp->GetOpaqueQualType(), idx, &byte_offset);
+        if (clang_type)
+        {
+            TypeImplSP type_impl_sp (new TypeImpl(ClangASTType (ast, clang_type)));
+            sb_type_member.reset (new TypeMemberImpl (type_impl_sp, byte_offset));
+        }
+    }
+    return sb_type_member;
+
+}
+
+SBTypeMember
+SBType::GetVirtualBaseClassAtIndex (uint32_t idx)
+{
+    SBTypeMember sb_type_member;
+    if (IsValid())
+    {
+        uint32_t byte_offset = 0;
+        clang::ASTContext* ast = m_opaque_sp->GetASTContext();
+        clang_type_t clang_type = ClangASTContext::GetVirtualBaseClassAtIndex (ast, m_opaque_sp->GetOpaqueQualType(), idx, &byte_offset);
+        if (clang_type)
+        {
+            TypeImplSP type_impl_sp (new TypeImpl(ClangASTType (ast, clang_type)));
+            sb_type_member.reset (new TypeMemberImpl (type_impl_sp, byte_offset));
+        }        
+    }
+    return sb_type_member;
+}
+
+SBTypeMember
+SBType::GetFieldAtIndex (uint32_t idx)
+{
+    SBTypeMember sb_type_member;
+    if (IsValid())
+    {
+        uint32_t byte_offset = 0;
+        clang::ASTContext* ast = m_opaque_sp->GetASTContext();
+        std::string name_sstr;
+        clang_type_t clang_type = ClangASTContext::GetFieldAtIndex (ast, m_opaque_sp->GetOpaqueQualType(), idx, name_sstr, &byte_offset);
+        if (clang_type)
+        {
+            ConstString name;
+            if (!name_sstr.empty())
+                name.SetCString(name_sstr.c_str());
+            TypeImplSP type_impl_sp (new TypeImpl(ClangASTType (ast, clang_type)));
+            sb_type_member.reset (new TypeMemberImpl (type_impl_sp, byte_offset, name));
+        }        
+    }
+    return sb_type_member;
+}
+
 const char*
 SBType::GetName()
 {
@@ -311,6 +399,15 @@
     return ClangASTType::GetConstTypeName(m_opaque_sp->GetOpaqueQualType()).GetCString();
 }
 
+lldb::TypeClass
+SBType::GetTypeClass ()
+{
+    if (IsValid())
+        return ClangASTType::GetTypeClass (m_opaque_sp->GetASTContext(),
+                                           m_opaque_sp->GetOpaqueQualType());
+    return lldb::eTypeClassInvalid;
+}
+
 SBTypeList::SBTypeList() :
     m_opaque_ap(new TypeListImpl())
 {
@@ -319,12 +416,12 @@
 SBTypeList::SBTypeList(const SBTypeList& rhs) :
     m_opaque_ap(new TypeListImpl())
 {
-    for (uint32_t i = 0, rhs_size = rhs.GetSize(); i < rhs_size; i++)
-        Append(rhs.GetTypeAtIndex(i));
+    for (uint32_t i = 0, rhs_size = const_cast<SBTypeList&>(rhs).GetSize(); i < rhs_size; i++)
+        Append(const_cast<SBTypeList&>(rhs).GetTypeAtIndex(i));
 }
 
 bool
-SBTypeList::IsValid () const
+SBTypeList::IsValid ()
 {
     return (m_opaque_ap.get() != NULL);
 }
@@ -332,30 +429,32 @@
 SBTypeList&
 SBTypeList::operator = (const SBTypeList& rhs)
 {
-    if (this != &rhs && m_opaque_ap.get() != rhs.m_opaque_ap.get())
+    if (this != &rhs)
     {
-        m_opaque_ap.reset(new TypeListImpl());
-        for (uint32_t i = 0, rhs_size = rhs.GetSize(); i < rhs_size; i++)
-            Append(rhs.GetTypeAtIndex(i));
+        m_opaque_ap.reset (new TypeListImpl());
+        for (uint32_t i = 0, rhs_size = const_cast<SBTypeList&>(rhs).GetSize(); i < rhs_size; i++)
+            Append(const_cast<SBTypeList&>(rhs).GetTypeAtIndex(i));
     }
     return *this;
 }
 
 void
-SBTypeList::Append (const SBType& type)
+SBTypeList::Append (SBType type)
 {
     if (type.IsValid())
         m_opaque_ap->Append (type.m_opaque_sp);
 }
 
 SBType
-SBTypeList::GetTypeAtIndex(int index) const
+SBTypeList::GetTypeAtIndex(uint32_t index)
 {
-    return SBType(m_opaque_ap->GetTypeAtIndex(index));
+    if (m_opaque_ap.get())
+        return SBType(m_opaque_ap->GetTypeAtIndex(index));
+    return SBType();
 }
 
-int
-SBTypeList::GetSize() const
+uint32_t
+SBTypeList::GetSize()
 {
     return m_opaque_ap->GetSize();
 }
@@ -367,7 +466,7 @@
 bool
 SBType::IsPointerType (void *opaque_type)
 {
-    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
     
     bool ret_value = ClangASTContext::IsPointerType (opaque_type);
     
@@ -376,3 +475,89 @@
     
     return ret_value;
 }
+
+
+SBTypeMember::SBTypeMember() :
+    m_opaque_ap()
+{
+}
+
+SBTypeMember::~SBTypeMember()
+{
+}
+
+SBTypeMember::SBTypeMember (const SBTypeMember& rhs) :
+    m_opaque_ap()
+{
+    if (this != &rhs)
+    {
+        if (rhs.IsValid())
+            m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
+    }
+}
+
+lldb::SBTypeMember&
+SBTypeMember::operator = (const lldb::SBTypeMember& rhs)
+{
+    if (this != &rhs)
+    {
+        if (rhs.IsValid())
+            m_opaque_ap.reset(new TypeMemberImpl(rhs.ref()));
+    }
+    return *this;
+}
+
+bool
+SBTypeMember::IsValid() const
+{
+    return m_opaque_ap.get();
+}
+
+const char *
+SBTypeMember::GetName ()
+{
+    if (m_opaque_ap.get())
+        return m_opaque_ap->GetName().GetCString();
+    return NULL;
+}
+
+SBType
+SBTypeMember::GetType ()
+{
+    SBType sb_type;
+    if (m_opaque_ap.get())
+    {
+        sb_type.reset (m_opaque_ap->GetTypeImpl());
+    }
+    return sb_type;
+
+}
+
+uint64_t
+SBTypeMember::GetOffsetByteSize()
+{
+    if (m_opaque_ap.get())
+        return (m_opaque_ap->GetBitOffset() + 7) / 8u;
+    return 0;
+}
+
+void
+SBTypeMember::reset(TypeMemberImpl *type_member_impl)
+{
+    m_opaque_ap.reset(type_member_impl);
+}
+
+TypeMemberImpl &
+SBTypeMember::ref ()
+{
+    if (m_opaque_ap.get() == NULL)
+        m_opaque_ap.reset (new TypeMemberImpl());
+    return *m_opaque_ap.get();
+}
+
+const TypeMemberImpl &
+SBTypeMember::ref () const
+{
+    return *m_opaque_ap.get();
+}
+

Modified: lldb/trunk/source/API/SBValue.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBValue.cpp?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/source/API/SBValue.cpp (original)
+++ lldb/trunk/source/API/SBValue.cpp Fri Sep  9 18:04:00 2011
@@ -52,7 +52,7 @@
 {
 }
 
-const SBValue &
+SBValue &
 SBValue::operator = (const SBValue &rhs)
 {
     if (this != &rhs)
@@ -65,7 +65,7 @@
 }
 
 bool
-SBValue::IsValid () const
+SBValue::IsValid ()
 {
     // If this function ever changes to anything that does more than just
     // check if the opaque shared pointer is non NULL, then we need to update
@@ -146,12 +146,6 @@
 }
 
 bool
-SBValue::IsInScope (const SBFrame &sb_frame)
-{
-    return IsInScope();
-}
-
-bool
 SBValue::IsInScope ()
 {
     bool result = false;
@@ -173,12 +167,6 @@
 }
 
 const char *
-SBValue::GetValue (const SBFrame &sb_frame)
-{
-    return GetValue();
-}
-
-const char *
 SBValue::GetValue ()
 {
     const char *cstr = NULL;
@@ -228,12 +216,6 @@
 }
 
 const char *
-SBValue::GetObjectDescription (const SBFrame &sb_frame)
-{
-    return GetObjectDescription ();
-}
-
-const char *
 SBValue::GetObjectDescription ()
 {
     const char *cstr = NULL;
@@ -256,12 +238,6 @@
     return cstr;
 }
 
-bool
-SBValue::GetValueDidChange (const SBFrame &sb_frame)
-{
-    return GetValueDidChange ();
-}
-
 SBType
 SBValue::GetType()
 {
@@ -305,12 +281,6 @@
 }
 
 const char *
-SBValue::GetSummary (const SBFrame &sb_frame)
-{
-    return GetSummary ();
-}
-
-const char *
 SBValue::GetSummary ()
 {
     const char *cstr = NULL;
@@ -334,12 +304,6 @@
 }
 
 const char *
-SBValue::GetLocation (const SBFrame &sb_frame)
-{
-    return GetLocation ();
-}
-
-const char *
 SBValue::GetLocation ()
 {
     const char *cstr = NULL;
@@ -363,12 +327,6 @@
 }
 
 bool
-SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str)
-{
-    return SetValueFromCString (value_str);
-}
-
-bool
 SBValue::SetValueFromCString (const char *value_str)
 {
     bool success = false;
@@ -384,7 +342,7 @@
 }
 
 lldb::SBValue
-SBValue::CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type)
+SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type)
 {
     lldb::SBValue result;
     if (m_opaque_sp)
@@ -407,7 +365,7 @@
 }
 
 lldb::SBValue
-SBValue::Cast(const SBType& type)
+SBValue::Cast (SBType type)
 {
     return CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type);
 }
@@ -419,10 +377,10 @@
     if (m_opaque_sp)
     {
         ValueObjectSP result_valobj_sp;
-        m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression(expression,
-                                                                      m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(),
-                                                                      true, true, eNoDynamicValues,
-                                                                      result_valobj_sp);
+        m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression (expression,
+                                                                         m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(),
+                                                                         true, true, eNoDynamicValues,
+                                                                         result_valobj_sp);
         result_valobj_sp->SetName(ConstString(name));
         result = SBValue(result_valobj_sp);
     }
@@ -438,7 +396,7 @@
 }
 
 lldb::SBValue
-SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type)
+SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType type)
 {
     lldb::SBValue result;
     if (m_opaque_sp)
@@ -448,13 +406,13 @@
         
         lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
         
-        ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(),
-                                                                          real_type.m_opaque_sp->GetASTContext(),
-                                                                          real_type.m_opaque_sp->GetOpaqueQualType(),
-                                                                          ConstString(name),
-                                                                          buffer,
-                                                                          lldb::endian::InlHostByteOrder(), 
-                                                                          GetTarget().GetProcess().GetAddressByteSize()));
+        ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(),
+                                                                           real_type.m_opaque_sp->GetASTContext(),
+                                                                           real_type.m_opaque_sp->GetOpaqueQualType(),
+                                                                           ConstString(name),
+                                                                           buffer,
+                                                                           lldb::endian::InlHostByteOrder(), 
+                                                                           GetTarget().GetProcess().GetAddressByteSize()));
         
         ValueObjectSP result_valobj_sp;
         
@@ -480,9 +438,7 @@
 }
 
 lldb::SBValue
-SBValue::CreateValueFromData (const char* name,
-                              const SBData& data,
-                              const SBType& type)
+SBValue::CreateValueFromData (const char* name, SBData data, SBType type)
 {
     SBValue result;
     
@@ -869,7 +825,7 @@
     {
         if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
         {
-            result = SBThread(lldb::ThreadSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread()));
+            result = SBThread(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread()->GetSP());
         }
     }
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -891,7 +847,7 @@
     {
         if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
         {
-            result = SBFrame(lldb::StackFrameSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame()));
+            result.SetFrame (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame()->GetSP());
         }
     }
     LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
@@ -980,7 +936,7 @@
 }
 
 lldb::Format
-SBValue::GetFormat () const
+SBValue::GetFormat ()
 {
     if (m_opaque_sp)
         return m_opaque_sp->GetFormat();

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Fri Sep  9 18:04:00 2011
@@ -2397,6 +2397,386 @@
     return num_children;
 }
 
+uint32_t
+ClangASTContext::GetNumDirectBaseClasses (clang::ASTContext *ast, clang_type_t clang_type)
+{
+    if (clang_type == NULL)
+        return 0;
+    
+    uint32_t count = 0;
+    QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+        case clang::Type::Record:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+                if (cxx_record_decl)
+                    count = cxx_record_decl->getNumBases();
+            }
+            break;
+            
+        case clang::Type::ObjCObject:
+        case clang::Type::ObjCInterface:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
+                if (objc_class_type)
+                {
+                    ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+                    
+                    if (class_interface_decl && class_interface_decl->getSuperClass())
+                        count = 1;
+                }
+            }
+            break;
+            
+            
+        case clang::Type::Typedef:
+            count = ClangASTContext::GetNumDirectBaseClasses (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+            break;
+            
+        case clang::Type::Elaborated:
+            count = ClangASTContext::GetNumDirectBaseClasses (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+            break;
+            
+        default:
+            break;
+    }
+    return count;
+}
+
+uint32_t 
+ClangASTContext::GetNumVirtualBaseClasses (clang::ASTContext *ast, 
+                                           clang_type_t clang_type)
+{
+    if (clang_type == NULL)
+        return 0;
+    
+    uint32_t count = 0;
+    QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+        case clang::Type::Record:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+                if (cxx_record_decl)
+                    count = cxx_record_decl->getNumVBases();
+            }
+            break;
+            
+        case clang::Type::Typedef:
+            count = ClangASTContext::GetNumVirtualBaseClasses (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+            break;
+            
+        case clang::Type::Elaborated:
+            count = ClangASTContext::GetNumVirtualBaseClasses (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+            break;
+            
+        default:
+            break;
+    }
+    return count;
+}
+
+uint32_t 
+ClangASTContext::GetNumFields (clang::ASTContext *ast, clang_type_t clang_type)
+{
+    if (clang_type == NULL)
+        return 0;
+    
+    uint32_t count = 0;
+    QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+        case clang::Type::Record:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const RecordType *record_type = dyn_cast<RecordType>(qual_type.getTypePtr());
+                if (record_type)
+                {
+                    RecordDecl *record_decl = record_type->getDecl();
+                    if (record_decl)
+                    {
+                        uint32_t field_idx = 0;
+                        RecordDecl::field_iterator field, field_end;
+                        for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field)
+                            ++field_idx;
+                        count = field_idx;
+                    }
+                }
+            }
+            break;
+            
+        case clang::Type::Typedef:
+            count = ClangASTContext::GetNumFields (ast, cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr());
+            break;
+            
+        case clang::Type::Elaborated:
+            count = ClangASTContext::GetNumFields (ast, cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr());
+            break;
+            
+        default:
+            break;
+    }
+    return count;
+}
+
+clang_type_t
+ClangASTContext::GetDirectBaseClassAtIndex (clang::ASTContext *ast, 
+                                            clang_type_t clang_type,
+                                            uint32_t idx, 
+                                            uint32_t *byte_offset_ptr)
+{
+    if (clang_type == NULL)
+        return 0;
+    
+    QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+        case clang::Type::Record:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+                if (cxx_record_decl)
+                {
+                    uint32_t curr_idx = 0;
+                    CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+                    for (base_class = cxx_record_decl->bases_begin(), base_class_end = cxx_record_decl->bases_end();
+                         base_class != base_class_end;
+                         ++base_class, ++curr_idx)
+                    {
+                        if (curr_idx == idx)
+                        {
+                            if (byte_offset_ptr)
+                            {
+                                const ASTRecordLayout &record_layout = ast->getASTRecordLayout(cxx_record_decl);
+                                const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
+//                                if (base_class->isVirtual())
+//                                    *byte_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
+//                                else
+                                    *byte_offset_ptr = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
+                            }
+                            return base_class->getType().getAsOpaquePtr();
+                        }
+                    }
+                }
+            }
+            break;
+            
+        case clang::Type::ObjCObject:
+        case clang::Type::ObjCInterface:
+            if (idx == 0 && GetCompleteQualType (ast, qual_type))
+            {
+                const ObjCObjectType *objc_class_type = qual_type->getAsObjCQualifiedInterfaceType();
+                if (objc_class_type)
+                {
+                    ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+                    
+                    if (class_interface_decl)
+                    {
+                        ObjCInterfaceDecl *superclass_interface_decl = class_interface_decl->getSuperClass();
+                        if (superclass_interface_decl)
+                        {
+                            if (byte_offset_ptr)
+                                *byte_offset_ptr = 0;
+                            return ast->getObjCInterfaceType(superclass_interface_decl).getAsOpaquePtr();
+                        }
+                    }
+                }
+            }
+            break;
+            
+            
+        case clang::Type::Typedef:
+            return ClangASTContext::GetDirectBaseClassAtIndex (ast, 
+                                                               cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
+                                                               idx,
+                                                               byte_offset_ptr);
+            
+        case clang::Type::Elaborated:
+            return  ClangASTContext::GetDirectBaseClassAtIndex (ast, 
+                                                                cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
+                                                                idx,
+                                                                byte_offset_ptr);
+            
+        default:
+            break;
+    }
+    return NULL;
+}
+
+clang_type_t
+ClangASTContext::GetVirtualBaseClassAtIndex (clang::ASTContext *ast, 
+                                             clang_type_t clang_type,
+                                             uint32_t idx, 
+                                             uint32_t *byte_offset_ptr)
+{
+    if (clang_type == NULL)
+        return 0;
+    
+    QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+        case clang::Type::Record:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const CXXRecordDecl *cxx_record_decl = qual_type->getAsCXXRecordDecl();
+                if (cxx_record_decl)
+                {
+                    uint32_t curr_idx = 0;
+                    CXXRecordDecl::base_class_const_iterator base_class, base_class_end;
+                    for (base_class = cxx_record_decl->vbases_begin(), base_class_end = cxx_record_decl->vbases_end();
+                         base_class != base_class_end;
+                         ++base_class, ++curr_idx)
+                    {
+                        if (curr_idx == idx)
+                        {
+                            if (byte_offset_ptr)
+                            {
+                                const ASTRecordLayout &record_layout = ast->getASTRecordLayout(cxx_record_decl);
+                                const CXXRecordDecl *base_class_decl = cast<CXXRecordDecl>(base_class->getType()->getAs<RecordType>()->getDecl());
+                                *byte_offset_ptr = record_layout.getVBaseClassOffset(base_class_decl).getQuantity() * 8;
+
+                            }
+                            return base_class->getType().getAsOpaquePtr();
+                        }
+                    }
+                }
+            }
+            break;
+            
+        case clang::Type::Typedef:
+            return ClangASTContext::GetVirtualBaseClassAtIndex (ast, 
+                                                                cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
+                                                                idx,
+                                                                byte_offset_ptr);
+            
+        case clang::Type::Elaborated:
+            return  ClangASTContext::GetVirtualBaseClassAtIndex (ast, 
+                                                                 cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
+                                                                 idx,
+                                                                 byte_offset_ptr);
+            
+        default:
+            break;
+    }
+    return NULL;
+}
+
+clang_type_t
+ClangASTContext::GetFieldAtIndex (clang::ASTContext *ast, 
+                                  clang_type_t clang_type,
+                                  uint32_t idx, 
+                                  std::string& name,
+                                  uint32_t *byte_offset_ptr)
+{
+    if (clang_type == NULL)
+        return 0;
+    
+    QualType qual_type(QualType::getFromOpaquePtr(clang_type));
+    const clang::Type::TypeClass type_class = qual_type->getTypeClass();
+    switch (type_class)
+    {
+        case clang::Type::Record:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const RecordType *record_type = cast<RecordType>(qual_type.getTypePtr());
+                const RecordDecl *record_decl = record_type->getDecl();
+                uint32_t field_idx = 0;
+                RecordDecl::field_iterator field, field_end;
+                for (field = record_decl->field_begin(), field_end = record_decl->field_end(); field != field_end; ++field, ++field_idx)
+                {
+                    if (idx == field_idx)
+                    {
+                        // Print the member type if requested
+                        // Print the member name and equal sign
+                        name.assign(field->getNameAsString());
+                        
+                        // Figure out the type byte size (field_type_info.first) and
+                        // alignment (field_type_info.second) from the AST context.
+                        if (byte_offset_ptr)
+                        {
+                            const ASTRecordLayout &record_layout = ast->getASTRecordLayout(record_decl);
+                            *byte_offset_ptr = (record_layout.getFieldOffset (field_idx) + 7) / 8;
+                        }
+                        
+                        return field->getType().getAsOpaquePtr();
+                    }
+                }
+            }
+            break;
+            
+        case clang::Type::ObjCObject:
+        case clang::Type::ObjCInterface:
+            if (GetCompleteQualType (ast, qual_type))
+            {
+                const ObjCObjectType *objc_class_type = dyn_cast<ObjCObjectType>(qual_type.getTypePtr());
+                assert (objc_class_type);
+                if (objc_class_type)
+                {
+                    ObjCInterfaceDecl *class_interface_decl = objc_class_type->getInterface();
+                    
+                    if (class_interface_decl)
+                    {
+                        if (idx < (class_interface_decl->ivar_size()))
+                        {
+                            ObjCInterfaceDecl::ivar_iterator ivar_pos, ivar_end = class_interface_decl->ivar_end();
+                            uint32_t ivar_idx = 0;
+
+                            for (ivar_pos = class_interface_decl->ivar_begin(); ivar_pos != ivar_end; ++ivar_pos, ++ivar_idx)
+                            {
+                                if (ivar_idx == idx)
+                                {
+                                    const ObjCIvarDecl* ivar_decl = *ivar_pos;
+                                    
+                                    QualType ivar_qual_type(ivar_decl->getType());
+                                    
+                                    name.assign(ivar_decl->getNameAsString());
+
+                                    if (byte_offset_ptr)
+                                    {
+                                        const ASTRecordLayout &interface_layout = ast->getASTObjCInterfaceLayout(class_interface_decl);
+                                        *byte_offset_ptr = (interface_layout.getFieldOffset (ivar_idx) + 7)/8;
+                                    }
+                                    
+                                    return ivar_qual_type.getAsOpaquePtr();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            break;
+            
+            
+        case clang::Type::Typedef:
+            return ClangASTContext::GetFieldAtIndex (ast, 
+                                                     cast<TypedefType>(qual_type)->getDecl()->getUnderlyingType().getAsOpaquePtr(),
+                                                     idx,
+                                                     name,
+                                                     byte_offset_ptr);
+            
+        case clang::Type::Elaborated:
+            return  ClangASTContext::GetFieldAtIndex (ast, 
+                                                      cast<ElaboratedType>(qual_type)->getNamedType().getAsOpaquePtr(),
+                                                      idx,
+                                                      name,
+                                                      byte_offset_ptr);
+            
+        default:
+            break;
+    }
+    return NULL;
+}
+
+
 // If a pointer to a pointee type (the clang_type arg) says that it has no 
 // children, then we either need to trust it, or override it and return a 
 // different result. For example, an "int *" has one child that is an integer, 
@@ -2616,7 +2996,6 @@
                                 bit_offset = record_layout.getBaseClassOffset(base_class_decl).getQuantity() * 8;
 
                             // Base classes should be a multiple of 8 bits in size
-                            assert (bit_offset % 8 == 0);
                             child_byte_offset = bit_offset/8;
                             
                             child_name = ClangASTType::GetTypeNameForQualType(base_class->getType());

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=139428&r1=139427&r2=139428&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Sep  9 18:04:00 2011
@@ -215,6 +215,79 @@
                                              m_type);
 }
 
+lldb::TypeClass
+ClangASTType::GetTypeClass (clang::ASTContext *ast_context, lldb::clang_type_t clang_type)
+{
+    if (clang_type == NULL)
+        return lldb::eTypeClassInvalid;
+
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
+    
+    switch (qual_type->getTypeClass())
+    {
+        case clang::Type::UnaryTransform:           break;
+        case clang::Type::FunctionNoProto:          return lldb::eTypeClassFunction;
+        case clang::Type::FunctionProto:            return lldb::eTypeClassFunction;
+        case clang::Type::IncompleteArray:          return lldb::eTypeClassArray;
+        case clang::Type::VariableArray:            return lldb::eTypeClassArray;
+        case clang::Type::ConstantArray:            return lldb::eTypeClassArray;
+        case clang::Type::DependentSizedArray:      return lldb::eTypeClassArray;
+        case clang::Type::DependentSizedExtVector:  return lldb::eTypeClassVector;
+        case clang::Type::ExtVector:                return lldb::eTypeClassVector;
+        case clang::Type::Vector:                   return lldb::eTypeClassVector;
+        case clang::Type::Builtin:                  return lldb::eTypeClassBuiltin;
+        case clang::Type::ObjCObjectPointer:        return lldb::eTypeClassObjCObjectPointer;
+        case clang::Type::BlockPointer:             return lldb::eTypeClassBlockPointer;
+        case clang::Type::Pointer:                  return lldb::eTypeClassPointer;
+        case clang::Type::LValueReference:          return lldb::eTypeClassReference;
+        case clang::Type::RValueReference:          return lldb::eTypeClassReference;
+        case clang::Type::MemberPointer:            return lldb::eTypeClassMemberPointer;
+        case clang::Type::Complex:
+            if (qual_type->isComplexType())
+                return lldb::eTypeClassComplexFloat;
+            else
+                return lldb::eTypeClassComplexInteger;
+        case clang::Type::ObjCObject:               return lldb::eTypeClassObjCObject;
+        case clang::Type::ObjCInterface:            return lldb::eTypeClassObjCInterface;
+        case clang::Type::Record:
+            if (ClangASTContext::GetCompleteType (ast_context, clang_type))
+            {
+                const clang::RecordType *record_type = llvm::cast<clang::RecordType>(qual_type.getTypePtr());
+                const clang::RecordDecl *record_decl = record_type->getDecl();
+                if (record_decl->isUnion())
+                    return lldb::eTypeClassUnion;
+                else if (record_decl->isStruct())
+                    return lldb::eTypeClassStruct;
+                else
+                    return lldb::eTypeClassClass;
+            }
+            break;
+        case clang::Type::Enum:                     return lldb::eTypeClassEnumeration;
+        case clang::Type::Typedef:                  return lldb::eTypeClassTypedef;
+        case clang::Type::UnresolvedUsing:          break;
+        case clang::Type::Paren:                    break;
+        case clang::Type::Elaborated:               break;
+        case clang::Type::Attributed:               break;
+        case clang::Type::TemplateTypeParm:         break;
+        case clang::Type::SubstTemplateTypeParm:    break;
+        case clang::Type::SubstTemplateTypeParmPack:break;
+        case clang::Type::Auto:                     break;
+        case clang::Type::InjectedClassName:        break;
+        case clang::Type::DependentName:            break;
+        case clang::Type::DependentTemplateSpecialization: break;
+        case clang::Type::PackExpansion:            break;
+            
+        case clang::Type::TypeOfExpr:               break;
+        case clang::Type::TypeOf:                   break;
+        case clang::Type::Decltype:                 break;
+        case clang::Type::TemplateSpecialization:   break;
+    }
+    // We don't know hot to display this type...
+    return lldb::eTypeClassOther;
+
+}
+
+
 lldb::LanguageType
 ClangASTType::GetMinimumLanguage (clang::ASTContext *ctx,
                                   lldb::clang_type_t clang_type)





More information about the lldb-commits mailing list