[Lldb-commits] [lldb] r115343 - in /lldb/trunk: include/lldb/Symbol/ClangASTType.h include/lldb/Symbol/Type.h include/lldb/Symbol/TypeList.h source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/ClangASTType.cpp source/Symbol/Type.cpp source/Symbol/TypeList.cpp

Greg Clayton gclayton at apple.com
Fri Oct 1 13:48:32 PDT 2010


Author: gclayton
Date: Fri Oct  1 15:48:32 2010
New Revision: 115343

URL: http://llvm.org/viewvc/llvm-project?rev=115343&view=rev
Log:
Fixed an issue where if a method funciton was asked to be parsed before
its containing class was parsed, we would crash.


Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTType.h
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/include/lldb/Symbol/TypeList.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
    lldb/trunk/source/Symbol/ClangASTType.cpp
    lldb/trunk/source/Symbol/Type.cpp
    lldb/trunk/source/Symbol/TypeList.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Fri Oct  1 15:48:32 2010
@@ -28,7 +28,7 @@
 class ClangASTType
 {
 protected:
-    ClangASTType (void *type, clang::ASTContext *ast_context) :
+    ClangASTType (lldb::clang_type_t type, clang::ASTContext *ast_context) :
         m_type (type),
         m_ast  (ast_context) 
     {
@@ -57,7 +57,7 @@
     }
     
 public:
-    void *
+    lldb::clang_type_t
     GetOpaqueQualType() const
     { 
         return m_type; 
@@ -73,19 +73,19 @@
     GetClangTypeName ();
 
     static ConstString
-    GetClangTypeName (void *clang_type);
+    GetClangTypeName (lldb::clang_type_t clang_type);
 
     uint64_t
     GetClangTypeBitWidth ();
 
     static uint64_t
-    GetClangTypeBitWidth (clang::ASTContext *ast_context, void *opaque_clang_qual_type);
+    GetClangTypeBitWidth (clang::ASTContext *ast_context, lldb::clang_type_t opaque_clang_qual_type);
 
     size_t
     GetTypeBitAlign ();
     
     static size_t
-    GetTypeBitAlign (clang::ASTContext *ast_context, void *clang_type);
+    GetTypeBitAlign (clang::ASTContext *ast_context, lldb::clang_type_t clang_type);
 
     void
     DumpValue (ExecutionContext *exe_ctx,
@@ -103,7 +103,7 @@
 
     static void
     DumpValue (clang::ASTContext *ast_context,
-               void *opaque_clang_qual_type,
+               lldb::clang_type_t opaque_clang_qual_type,
                ExecutionContext *exe_ctx,
                Stream *s,
                lldb::Format format,
@@ -129,7 +129,7 @@
     
     static bool
     DumpTypeValue (clang::ASTContext *ast_context,
-                   void *opaque_clang_qual_type,
+                   lldb::clang_type_t opaque_clang_qual_type,
                    Stream *s,
                    lldb::Format format,
                    const DataExtractor &data,
@@ -148,7 +148,7 @@
     
     static void
     DumpSummary (clang::ASTContext *ast_context,
-                 void *opaque_clang_qual_type,
+                 lldb::clang_type_t opaque_clang_qual_type,
                  ExecutionContext *exe_ctx,
                  Stream *s,
                  const DataExtractor &data,
@@ -160,20 +160,20 @@
     
     static void
     DumpTypeDescription (clang::ASTContext *ast_context,
-                         void *opaque_clang_qual_type,
+                         lldb::clang_type_t opaque_clang_qual_type,
                          Stream *s);
                          
     lldb::Encoding
     GetEncoding (uint32_t &count);                 
 
     static lldb::Encoding
-    GetEncoding (void *opaque_clang_qual_type, uint32_t &count);
+    GetEncoding (lldb::clang_type_t opaque_clang_qual_type, uint32_t &count);
 
     lldb::Format
     GetFormat ();
                  
     static lldb::Format
-    GetFormat (void *opaque_clang_qual_type);
+    GetFormat (lldb::clang_type_t opaque_clang_qual_type);
 
     bool
     GetValueAsScalar (const DataExtractor &data,
@@ -183,7 +183,7 @@
 
     static bool
     GetValueAsScalar (clang::ASTContext *ast_context,
-                      void *opaque_clang_qual_type,
+                      lldb::clang_type_t opaque_clang_qual_type,
                       const DataExtractor &data,
                       uint32_t data_offset,
                       size_t data_byte_size,
@@ -194,7 +194,7 @@
     IsDefined();
 
     static bool
-    IsDefined (void *opaque_clang_qual_type);
+    IsDefined (lldb::clang_type_t opaque_clang_qual_type);
 
     bool
     SetValueFromScalar (const Scalar &value,
@@ -202,7 +202,7 @@
 
     static bool
     SetValueFromScalar (clang::ASTContext *ast_context,
-                        void *opaque_clang_qual_type,
+                        lldb::clang_type_t opaque_clang_qual_type,
                         const Scalar &value,
                         Stream &strm);
 
@@ -214,7 +214,7 @@
 
     static bool
     ReadFromMemory (clang::ASTContext *ast_context,
-                    void *opaque_clang_qual_type,
+                    lldb::clang_type_t opaque_clang_qual_type,
                     ExecutionContext *exe_ctx,
                     lldb::addr_t addr,
                     lldb::AddressType address_type,
@@ -228,17 +228,20 @@
 
     static bool
     WriteToMemory (clang::ASTContext *ast_context,
-                   void *opaque_clang_qual_type,
+                   lldb::clang_type_t opaque_clang_qual_type,
                    ExecutionContext *exe_ctx,
                    lldb::addr_t addr,
                    lldb::AddressType address_type,
                    StreamString &new_value);
 
-    void *
+    lldb::clang_type_t
     GetPointeeType ();
 
-    static void *
-    GetPointeeType (void *opaque_clang_qual_type);
+    static lldb::clang_type_t
+    GetPointeeType (lldb::clang_type_t opaque_clang_qual_type);
+
+    static lldb::clang_type_t
+    RemoveFastQualifiers (lldb::clang_type_t);
 
 private:
     void               *m_type;

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Fri Oct  1 15:48:32 2010
@@ -172,8 +172,15 @@
     const lldb_private::Declaration &
     GetDeclaration () const;
 
+    // Get the clang type, and resolve definitions for any 
+    // class/struct/union/enum types completely.
     lldb::clang_type_t 
-    GetClangType (bool forward_decl_is_ok = false);
+    GetClangType ();
+
+    // Get the clang type and leave class/struct/union/enum types as forward
+    // declarations if they haven't already been fully defined.
+    lldb::clang_type_t 
+    GetClangForwardType ();
 
     clang::ASTContext *
     GetClangAST ();

Modified: lldb/trunk/include/lldb/Symbol/TypeList.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/TypeList.h?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/TypeList.h (original)
+++ lldb/trunk/include/lldb/Symbol/TypeList.h Fri Oct  1 15:48:32 2010
@@ -56,18 +56,18 @@
     GetClangASTContext ();
 
     void *
-    CreateClangPointerType (Type *type, bool forward_decl_is_ok);
+    CreateClangPointerType (Type *type);
 
     void *
-    CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok);
+    CreateClangTypedefType (Type *typedef_type, Type *base_type);
 
     // For C++98 references (&)
     void *
-    CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok);
+    CreateClangLValueReferenceType (Type *type);
 
     // For C++0x references (&&)
     void *
-    CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok);
+    CreateClangRValueReferenceType (Type *type);
 
 private:
     typedef std::vector<lldb::TypeSP> collection;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Fri Oct  1 15:48:32 2010
@@ -530,7 +530,7 @@
     for (pos = m_die_array.begin(); pos != end; ++pos)
     {
         if (pos->Tag() == tag)
-            dies.Insert(&(*pos));
+            dies.Append (&(*pos));
     }
 
     // Return the number of DIEs added to the collection

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.cpp Fri Oct  1 15:48:32 2010
@@ -29,6 +29,12 @@
     return true;
 }
 
+void
+DWARFDIECollection::Append (const DWARFDebugInfoEntry *die)
+{
+    m_dies.push_back (die);
+}
+
 const DWARFDebugInfoEntry *
 DWARFDIECollection::GetDIEPtrAtIndex(uint32_t idx) const
 {

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDIECollection.h Fri Oct  1 15:48:32 2010
@@ -25,6 +25,9 @@
     }
 
     void
+    Append (const DWARFDebugInfoEntry *die);
+
+    void
     Dump(lldb_private::Stream *s, const char* title) const;
 
     const DWARFDebugInfoEntry*

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Fri Oct  1 15:48:32 2010
@@ -52,6 +52,15 @@
 
 #include <map>
 
+//#define ENABLE_DEBUG_PRINTF // COMMENT OUT THIS LINE PRIOR TO CHECKIN
+
+#ifdef ENABLE_DEBUG_PRINTF
+#include <stdio.h>
+#define DEBUG_PRINTF(fmt, ...) printf(fmt, ## __VA_ARGS__)
+#else
+#define DEBUG_PRINTF(fmt, ...)
+#endif
+
 #define DIE_IS_BEING_PARSED ((lldb_private::Type*)1)
 
 using namespace lldb;
@@ -579,8 +588,30 @@
     int call_column = 0;
     DWARFExpression frame_base;
 
-    // Parse the function prototype as a type that can then be added to concrete function instance
-    ParseTypes (sc, dwarf_cu, die, false, false);
+    assert (die->Tag() == DW_TAG_subprogram);
+    
+    if (die->Tag() != DW_TAG_subprogram)
+        return NULL;
+
+    const DWARFDebugInfoEntry *parent_die = die->GetParent();
+    switch (parent_die->Tag())
+    {
+    case DW_TAG_structure_type:
+    case DW_TAG_class_type:
+        // We have methods of a class or struct
+        {
+            Type *class_type = ResolveType (dwarf_cu, parent_die);
+            if (class_type)
+                class_type->GetClangType();
+        }
+        break;
+
+    default:
+        // Parse the function prototype as a type that can then be added to concrete function instance
+        ParseTypes (sc, dwarf_cu, die, false, false);
+        break;
+    }
+    
     //FixupTypes();
 
     if (die->GetDIENamesAndRanges(this, dwarf_cu, name, mangled, func_ranges, decl_file, decl_line, decl_column, call_file, call_line, call_column, &frame_base))
@@ -1013,6 +1044,7 @@
     const LanguageType class_language,
     std::vector<clang::CXXBaseSpecifier *>& base_classes,
     std::vector<int>& member_accessibilities,
+    DWARFDIECollection& member_function_dies,
     AccessType& default_accessibility,
     bool &is_a_class
 )
@@ -1103,8 +1135,8 @@
             break;
 
         case DW_TAG_subprogram:
-            // Let the type parsing code handle this one for us...
-            ResolveType (dwarf_cu, die);
+            // Let the type parsing code handle this one for us. 
+            member_function_dies.Append (die);
             break;
 
         case DW_TAG_inheritance:
@@ -1220,7 +1252,7 @@
 SymbolFileDWARF::ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_type)
 {
     // We have a struct/union/class/enum that needs to be fully resolved.
-    const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (clang_type);
+    const DWARFDebugInfoEntry* die = m_forward_decl_clang_type_to_die.lookup (ClangASTType::RemoveFastQualifiers(clang_type));
     assert (die);
     if (die == NULL)
         return NULL;
@@ -1230,6 +1262,7 @@
 
     const dw_tag_t tag = die->Tag();
 
+    DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") - resolve forward declaration...\n", die->GetOffset(), DW_TAG_value_to_name(tag), type->GetName().AsCString());
     assert (clang_type);
     DWARFDebugInfoEntry::Attributes attributes;
 
@@ -1240,82 +1273,96 @@
     case DW_TAG_structure_type:
     case DW_TAG_union_type:
     case DW_TAG_class_type:
-            type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
-            if (die->HasChildren())
+        type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
+        if (die->HasChildren())
+        {
+            LanguageType class_language = eLanguageTypeUnknown;
+            if (ClangASTContext::IsObjCClassType (clang_type))
+                class_language = eLanguageTypeObjC;
+
+            int tag_decl_kind = -1;
+            AccessType default_accessibility = eAccessNone;
+            if (tag == DW_TAG_structure_type)
+            {
+                tag_decl_kind = clang::TTK_Struct;
+                default_accessibility = eAccessPublic;
+            }
+            else if (tag == DW_TAG_union_type)
             {
-                LanguageType class_language = eLanguageTypeUnknown;
-                if (ClangASTContext::IsObjCClassType (clang_type))
-                    class_language = eLanguageTypeObjC;
+                tag_decl_kind = clang::TTK_Union;
+                default_accessibility = eAccessPublic;
+            }
+            else if (tag == DW_TAG_class_type)
+            {
+                tag_decl_kind = clang::TTK_Class;
+                default_accessibility = eAccessPrivate;
+            }
 
-                int tag_decl_kind = -1;
-                AccessType default_accessibility = eAccessNone;
-                if (tag == DW_TAG_structure_type)
-                {
-                    tag_decl_kind = clang::TTK_Struct;
-                    default_accessibility = eAccessPublic;
-                }
-                else if (tag == DW_TAG_union_type)
-                {
-                    tag_decl_kind = clang::TTK_Union;
-                    default_accessibility = eAccessPublic;
-                }
-                else if (tag == DW_TAG_class_type)
+            SymbolContext sc(GetCompUnitForDWARFCompUnit(cu));
+            std::vector<clang::CXXBaseSpecifier *> base_classes;
+            std::vector<int> member_accessibilities;
+            bool is_a_class = false;
+            // Parse members and base classes first
+            DWARFDIECollection member_function_dies;
+
+            ParseChildMembers (sc, 
+                               cu, 
+                               die, 
+                               clang_type,
+                               class_language,
+                               base_classes, 
+                               member_accessibilities,
+                               member_function_dies,
+                               default_accessibility, 
+                               is_a_class);
+
+            // Now parse any methods if there were any...
+            size_t num_functions = member_function_dies.Size();                
+            if (num_functions > 0)
+            {
+                for (size_t i=0; i<num_functions; ++i)
                 {
-                    tag_decl_kind = clang::TTK_Class;
-                    default_accessibility = eAccessPrivate;
-                }
-
-                SymbolContext sc(GetCompUnitForDWARFCompUnit(cu));
-                std::vector<clang::CXXBaseSpecifier *> base_classes;
-                std::vector<int> member_accessibilities;
-                bool is_a_class = false;
-                ParseChildMembers (sc, 
-                                   cu, 
-                                   die, 
-                                   clang_type,
-                                   class_language,
-                                   base_classes, 
-                                   member_accessibilities, 
-                                   default_accessibility, 
-                                   is_a_class);
-
-                // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we
-                // need to tell the clang type it is actually a class.
-                if (class_language != eLanguageTypeObjC)
-                {
-                    if (is_a_class && tag_decl_kind != clang::TTK_Class)
-                        type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class);
-                }
-
-                // Since DW_TAG_structure_type gets used for both classes
-                // and structures, we may need to set any DW_TAG_member
-                // fields to have a "private" access if none was specified.
-                // When we parsed the child members we tracked that actual
-                // accessibility value for each DW_TAG_member in the
-                // "member_accessibilities" array. If the value for the
-                // member is zero, then it was set to the "default_accessibility"
-                // which for structs was "public". Below we correct this
-                // by setting any fields to "private" that weren't correctly
-                // set.
-                if (is_a_class && !member_accessibilities.empty())
-                {
-                    // This is a class and all members that didn't have
-                    // their access specified are private.
-                    type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size());
-                }
-
-                if (!base_classes.empty())
-                {
-                    type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size());
-
-                    // Clang will copy each CXXBaseSpecifier in "base_classes"
-                    // so we have to free them all.
-                    ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size());
+                    ResolveType(cu, member_function_dies.GetDIEPtrAtIndex(i));
                 }
-                
             }
-            type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
-            return clang_type;
+            
+            // If we have a DW_TAG_structure_type instead of a DW_TAG_class_type we
+            // need to tell the clang type it is actually a class.
+            if (class_language != eLanguageTypeObjC)
+            {
+                if (is_a_class && tag_decl_kind != clang::TTK_Class)
+                    type_list->GetClangASTContext().SetTagTypeKind (clang_type, clang::TTK_Class);
+            }
+
+            // Since DW_TAG_structure_type gets used for both classes
+            // and structures, we may need to set any DW_TAG_member
+            // fields to have a "private" access if none was specified.
+            // When we parsed the child members we tracked that actual
+            // accessibility value for each DW_TAG_member in the
+            // "member_accessibilities" array. If the value for the
+            // member is zero, then it was set to the "default_accessibility"
+            // which for structs was "public". Below we correct this
+            // by setting any fields to "private" that weren't correctly
+            // set.
+            if (is_a_class && !member_accessibilities.empty())
+            {
+                // This is a class and all members that didn't have
+                // their access specified are private.
+                type_list->GetClangASTContext().SetDefaultAccessForRecordFields (clang_type, eAccessPrivate, &member_accessibilities.front(), member_accessibilities.size());
+            }
+
+            if (!base_classes.empty())
+            {
+                type_list->GetClangASTContext().SetBaseClassesForClassType (clang_type, &base_classes.front(), base_classes.size());
+
+                // Clang will copy each CXXBaseSpecifier in "base_classes"
+                // so we have to free them all.
+                ClangASTContext::DeleteBaseClassSpecifiers (&base_classes.front(), base_classes.size());
+            }
+            
+        }
+        type_list->GetClangASTContext().CompleteTagDeclarationDefinition (clang_type);
+        return clang_type;
 
     case DW_TAG_enumeration_type:
         type_list->GetClangASTContext().StartTagDeclarationDefinition (clang_type);
@@ -2097,9 +2144,9 @@
                         Type *type = ResolveTypeUID(param_type_die_offset);
                         if (type)
                         {
-                            function_param_types.push_back (type->GetClangType(true));
+                            function_param_types.push_back (type->GetClangForwardType());
 
-                            clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangType(), storage);
+                            clang::ParmVarDecl *param_var_decl = type_list->GetClangASTContext().CreateParameterDeclaration (name, type->GetClangForwardType(), storage);
                             assert(param_var_decl);
                             function_param_decls.push_back(param_var_decl);
                         }
@@ -2498,6 +2545,8 @@
                         }
                     }
 
+                    DEBUG_PRINTF ("0x%8.8x: %s (\"%s\") type => 0x%8.8x\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr, encoding_uid);
+
                     switch (tag)
                     {
                     default:
@@ -2648,6 +2697,8 @@
                         }
                     }
 
+                    DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr);
+
                     int tag_decl_kind = -1;
                     AccessType default_accessibility = eAccessNone;
                     if (tag == DW_TAG_structure_type)
@@ -2698,7 +2749,7 @@
                         // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)"
                         // When the definition needs to be defined.
                         m_forward_decl_die_to_clang_type[die] = clang_type;
-                        m_forward_decl_clang_type_to_die[clang_type] = die;
+                        m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die;
                     }
                     
                 }
@@ -2753,6 +2804,8 @@
                             }
                         }
 
+                        DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr);
+
                         clang_type_t enumerator_clang_type = NULL;
                         clang_type = m_forward_decl_die_to_clang_type.lookup (die);
                         if (clang_type == NULL)
@@ -2777,7 +2830,7 @@
                         // "SymbolFileDWARF::ResolveClangOpaqueTypeDefinition(Type *)"
                         // When the definition needs to be defined.
                         m_forward_decl_die_to_clang_type[die] = clang_type;
-                        m_forward_decl_clang_type_to_die[clang_type] = die;
+                        m_forward_decl_clang_type_to_die[ClangASTType::RemoveFastQualifiers (clang_type)] = die;
 
                     }
                 }
@@ -2873,6 +2926,8 @@
                             }
                         }
 
+                        DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr);
+
                         clang_type_t return_clang_type = NULL;
                         Type *func_type = NULL;
                         
@@ -2880,7 +2935,7 @@
                             func_type = ResolveTypeUID(type_die_offset);
 
                         if (func_type)
-                            return_clang_type = func_type->GetClangType(true);
+                            return_clang_type = func_type->GetClangForwardType();
                         else
                             return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void();
 
@@ -2953,7 +3008,7 @@
                                     Type *class_type = ResolveType (dwarf_cu, parent_die);
                                     if (class_type)
                                     {
-                                        clang_type_t class_opaque_type = class_type->GetClangType (true);
+                                        clang_type_t class_opaque_type = class_type->GetClangForwardType();
                                         if (ClangASTContext::IsCXXClassType (class_opaque_type))
                                         {
                                             // Neither GCC 4.2 nor clang++ currently set a valid accessibility
@@ -3049,6 +3104,8 @@
                             }
                         }
 
+                        DEBUG_PRINTF ("0x%8.8x: %s (\"%s\")\n", die->GetOffset(), DW_TAG_value_to_name(tag), type_name_cstr);
+
                         Type *element_type = ResolveTypeUID(type_die_offset);
 
                         if (element_type)

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Fri Oct  1 15:48:32 2010
@@ -241,6 +241,7 @@
                                 const lldb::LanguageType class_language,
                                 std::vector<clang::CXXBaseSpecifier *>& base_classes,
                                 std::vector<int>& member_accessibilities,
+                                DWARFDIECollection& member_function_dies,
                                 lldb::AccessType &default_accessibility,
                                 bool &is_a_class);
 

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Fri Oct  1 15:48:32 2010
@@ -36,6 +36,7 @@
 #include "lldb/Target/ExecutionContext.h"
 #include "lldb/Target/Process.h"
 
+using namespace lldb;
 using namespace lldb_private;
 
 ClangASTType::~ClangASTType()
@@ -49,12 +50,12 @@
 }
 
 ConstString
-ClangASTType::GetClangTypeName (void *opaque_clang_qual_type)
+ClangASTType::GetClangTypeName (clang_type_t clang_type)
 {
     ConstString clang_type_name;
-    if (opaque_clang_qual_type)
+    if (clang_type)
     {
-        clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+        clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
 
         const clang::TypedefType *typedef_type = qual_type->getAs<clang::TypedefType>();
         if (typedef_type)
@@ -80,18 +81,18 @@
 }
 
 
-void *
+clang_type_t
 ClangASTType::GetPointeeType ()
 {
     return GetPointeeType (m_type);
 }
 
-void *
-ClangASTType::GetPointeeType (void *opaque_clang_qual_type)
+clang_type_t
+ClangASTType::GetPointeeType (clang_type_t clang_type)
 {
-    if (opaque_clang_qual_type)
+    if (clang_type)
     {
-        clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+        clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
         
         return qual_type.getTypePtr()->getPointeeType().getAsOpaquePtr();
     }
@@ -106,10 +107,10 @@
 
 
 lldb::Encoding
-ClangASTType::GetEncoding (void *opaque_clang_qual_type, uint32_t &count)
+ClangASTType::GetEncoding (clang_type_t clang_type, uint32_t &count)
 {
     count = 1;
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
 
     switch (qual_type->getTypeClass())
     {
@@ -201,9 +202,9 @@
 }
 
 lldb::Format
-ClangASTType::GetFormat (void *opaque_clang_qual_type)
+ClangASTType::GetFormat (clang_type_t clang_type)
 {
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
 
     switch (qual_type->getTypeClass())
     {
@@ -321,7 +322,7 @@
 ClangASTType::DumpValue
 (
     clang::ASTContext *ast_context,
-    void *opaque_clang_qual_type,
+    clang_type_t clang_type,
     ExecutionContext *exe_ctx,
     Stream *s,
     lldb::Format format,
@@ -336,7 +337,7 @@
     uint32_t depth
 )
 {
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
     switch (qual_type->getTypeClass())
     {
     case clang::Type::Record:
@@ -588,7 +589,7 @@
         data.Dump(s, data_byte_offset, format, data_byte_size, 1, UINT32_MAX, LLDB_INVALID_ADDRESS, bitfield_bit_size, bitfield_bit_offset);
 
         if (show_summary)
-            DumpSummary (ast_context, opaque_clang_qual_type, exe_ctx, s, data, data_byte_offset, data_byte_size);
+            DumpSummary (ast_context, clang_type, exe_ctx, s, data, data_byte_offset, data_byte_size);
         break;
     }
 }
@@ -623,7 +624,7 @@
 ClangASTType::DumpTypeValue
 (
     clang::ASTContext *ast_context,
-    void *opaque_clang_qual_type,
+    clang_type_t clang_type,
     Stream *s,
     lldb::Format format,
     const lldb_private::DataExtractor &data,
@@ -633,8 +634,8 @@
     uint32_t bitfield_bit_offset
 )
 {
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
-    if (ClangASTContext::IsAggregateType (opaque_clang_qual_type))
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
+    if (ClangASTContext::IsAggregateType (clang_type))
     {
         return 0;
     }
@@ -729,7 +730,7 @@
 ClangASTType::DumpSummary
 (
     clang::ASTContext *ast_context,
-    void *opaque_clang_qual_type,
+    clang_type_t clang_type,
     ExecutionContext *exe_ctx,
     Stream *s,
     const lldb_private::DataExtractor &data,
@@ -738,8 +739,8 @@
 )
 {
     uint32_t length = 0;
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
-    if (ClangASTContext::IsCStringType (opaque_clang_qual_type, length))
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
+    if (ClangASTContext::IsCStringType (clang_type, length))
     {
 
         if (exe_ctx && exe_ctx->process)
@@ -783,10 +784,10 @@
 }
 
 uint64_t
-ClangASTType::GetClangTypeBitWidth (clang::ASTContext *ast_context, void *opaque_clang_qual_type)
+ClangASTType::GetClangTypeBitWidth (clang::ASTContext *ast_context, clang_type_t clang_type)
 {
-    if (ast_context && opaque_clang_qual_type)
-        return ast_context->getTypeSize(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    if (ast_context && clang_type)
+        return ast_context->getTypeSize(clang::QualType::getFromOpaquePtr(clang_type));
     return 0;
 }
 
@@ -797,10 +798,10 @@
 }
 
 size_t
-ClangASTType::GetTypeBitAlign (clang::ASTContext *ast_context, void *opaque_clang_qual_type)
+ClangASTType::GetTypeBitAlign (clang::ASTContext *ast_context, clang_type_t clang_type)
 {
-    if (ast_context && opaque_clang_qual_type)
-        return ast_context->getTypeAlign(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    if (ast_context && clang_type)
+        return ast_context->getTypeAlign(clang::QualType::getFromOpaquePtr(clang_type));
     return 0;
 }
 
@@ -813,9 +814,9 @@
 
 
 bool
-ClangASTType::IsDefined (void *opaque_clang_qual_type)
+ClangASTType::IsDefined (clang_type_t clang_type)
 {
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
     clang::TagType *tag_type = dyn_cast<clang::TagType>(qual_type.getTypePtr());
     if (tag_type)
     {
@@ -836,11 +837,11 @@
 // Dump the full description of a type. For classes this means all of the
 // ivars and member functions, for structs/unions all of the members. 
 void
-ClangASTType::DumpTypeDescription (clang::ASTContext *ast_context, void *opaque_clang_qual_type, Stream *s)
+ClangASTType::DumpTypeDescription (clang::ASTContext *ast_context, clang_type_t clang_type, Stream *s)
 {
-    if (opaque_clang_qual_type)
+    if (clang_type)
     {
-        clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+        clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
 
         llvm::SmallVector<char, 1024> buf;
         llvm::raw_svector_ostream llvm_ostrm (buf);
@@ -922,23 +923,23 @@
 ClangASTType::GetValueAsScalar
 (
     clang::ASTContext *ast_context,
-    void *opaque_clang_qual_type,
+    clang_type_t clang_type,
     const lldb_private::DataExtractor &data,
     uint32_t data_byte_offset,
     size_t data_byte_size,
     Scalar &value
 )
 {
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
 
-    if (ClangASTContext::IsAggregateType (opaque_clang_qual_type))
+    if (ClangASTContext::IsAggregateType (clang_type))
     {
         return false;   // Aggregate types don't have scalar values
     }
     else
     {
         uint32_t count = 0;
-        lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count);
+        lldb::Encoding encoding = GetEncoding (clang_type, count);
 
         if (encoding == lldb::eEncodingInvalid || count != 1)
             return false;
@@ -1065,19 +1066,19 @@
 ClangASTType::SetValueFromScalar
 (
     clang::ASTContext *ast_context,
-    void *opaque_clang_qual_type,
+    clang_type_t clang_type,
     const Scalar &value,
     Stream &strm
 )
 {
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
 
     // Aggregate types don't have scalar values
-    if (!ClangASTContext::IsAggregateType (opaque_clang_qual_type))
+    if (!ClangASTContext::IsAggregateType (clang_type))
     {
         strm.GetFlags().Set(Stream::eBinary);
         uint32_t count = 0;
-        lldb::Encoding encoding = GetEncoding (opaque_clang_qual_type, count);
+        lldb::Encoding encoding = GetEncoding (clang_type, count);
 
         if (encoding == lldb::eEncodingInvalid || count != 1)
             return false;
@@ -1163,7 +1164,7 @@
 ClangASTType::ReadFromMemory
 (
     clang::ASTContext *ast_context,
-    void *opaque_clang_qual_type,
+    clang_type_t clang_type,
     lldb_private::ExecutionContext *exe_ctx,
     lldb::addr_t addr,
     lldb::AddressType address_type,
@@ -1176,7 +1177,7 @@
         // context (which Module it came from)
         return false;
     }
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
 
     const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8;
     if (data.GetByteSize() < byte_size)
@@ -1227,7 +1228,7 @@
 ClangASTType::WriteToMemory
 (
     clang::ASTContext *ast_context,
-    void *opaque_clang_qual_type,
+    clang_type_t clang_type,
     lldb_private::ExecutionContext *exe_ctx,
     lldb::addr_t addr,
     lldb::AddressType address_type,
@@ -1240,7 +1241,7 @@
         // context (which Module it came from)
         return false;
     }
-    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(opaque_clang_qual_type));
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
     const uint32_t byte_size = (ast_context->getTypeSize (qual_type) + 7) / 8;
 
     if (byte_size > 0)
@@ -1264,3 +1265,10 @@
 }
 
 
+lldb::clang_type_t
+ClangASTType::RemoveFastQualifiers (lldb::clang_type_t clang_type)
+{
+    clang::QualType qual_type(clang::QualType::getFromOpaquePtr(clang_type));
+    qual_type.removeFastQualifiers();
+    return qual_type.getAsOpaquePtr();
+}

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Fri Oct  1 15:48:32 2010
@@ -439,34 +439,34 @@
                 break;
 
             case eEncodingIsConstUID:
-                m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangType(true));
+                m_clang_qual_type = ClangASTContext::AddConstModifier (encoding_type->GetClangForwardType());
                 break;
 
             case eEncodingIsRestrictUID:
-                m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangType(true));
+                m_clang_qual_type = ClangASTContext::AddRestrictModifier (encoding_type->GetClangForwardType());
                 break;
 
             case eEncodingIsVolatileUID:
-                m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangType(true));
+                m_clang_qual_type = ClangASTContext::AddVolatileModifier (encoding_type->GetClangForwardType());
                 break;
 
             case eEncodingIsTypedefUID:
-                m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type, true);
+                m_clang_qual_type = type_list->CreateClangTypedefType (this, encoding_type);
                 // Clear the name so it can get fully qualified in case the
                 // typedef is in a namespace.
                 m_name.Clear();
                 break;
 
             case eEncodingIsPointerUID:
-                m_clang_qual_type = type_list->CreateClangPointerType (encoding_type, true);
+                m_clang_qual_type = type_list->CreateClangPointerType (encoding_type);
                 break;
 
             case eEncodingIsLValueReferenceUID:
-                m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type, true);
+                m_clang_qual_type = type_list->CreateClangLValueReferenceType (encoding_type);
                 break;
 
             case eEncodingIsRValueReferenceUID:
-                m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type, true);
+                m_clang_qual_type = type_list->CreateClangRValueReferenceType (encoding_type);
                 break;
 
             default:
@@ -584,14 +584,22 @@
 }
 
 
-
 clang_type_t 
-lldb_private::Type::GetClangType (bool forward_decl_is_ok)
+lldb_private::Type::GetClangType ()
 {
+    const bool forward_decl_is_ok = false;
     ResolveClangType(forward_decl_is_ok);
     return m_clang_qual_type;
 }
 
+clang_type_t 
+lldb_private::Type::GetClangForwardType ()
+{
+    const bool forward_decl_is_ok = true;
+    ResolveClangType (forward_decl_is_ok);
+    return m_clang_qual_type;
+}
+
 clang::ASTContext *
 lldb_private::Type::GetClangAST ()
 {

Modified: lldb/trunk/source/Symbol/TypeList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/TypeList.cpp?rev=115343&r1=115342&r2=115343&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/TypeList.cpp (original)
+++ lldb/trunk/source/Symbol/TypeList.cpp Fri Oct  1 15:48:32 2010
@@ -208,31 +208,33 @@
 }
 
 void *
-TypeList::CreateClangPointerType (Type *type, bool forward_decl_is_ok)
+TypeList::CreateClangPointerType (Type *type)
 {
     assert(type);
-    return m_ast.CreatePointerType(type->GetClangType(forward_decl_is_ok));
+    return m_ast.CreatePointerType(type->GetClangForwardType());
 }
 
 void *
-TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type, bool forward_decl_is_ok)
+TypeList::CreateClangTypedefType (Type *typedef_type, Type *base_type)
 {
     assert(typedef_type && base_type);
-    return m_ast.CreateTypedefType(typedef_type->GetName().AsCString(), base_type->GetClangType(forward_decl_is_ok), typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID()));
+    return m_ast.CreateTypedefType (typedef_type->GetName().AsCString(), 
+                                    base_type->GetClangForwardType(), 
+                                    typedef_type->GetSymbolFile()->GetClangDeclContextForTypeUID(typedef_type->GetID()));
 }
 
 void *
-TypeList::CreateClangLValueReferenceType (Type *type, bool forward_decl_is_ok)
+TypeList::CreateClangLValueReferenceType (Type *type)
 {
     assert(type);
-    return m_ast.CreateLValueReferenceType(type->GetClangType(forward_decl_is_ok));
+    return m_ast.CreateLValueReferenceType(type->GetClangForwardType());
 }
 
 void *
-TypeList::CreateClangRValueReferenceType (Type *type, bool forward_decl_is_ok)
+TypeList::CreateClangRValueReferenceType (Type *type)
 {
     assert(type);
-    return m_ast.CreateRValueReferenceType (type->GetClangType(forward_decl_is_ok));
+    return m_ast.CreateRValueReferenceType (type->GetClangForwardType());
 }
 
 





More information about the lldb-commits mailing list