[Lldb-commits] [lldb] r125691 - in /lldb/trunk: include/lldb/Core/Value.h include/lldb/Symbol/Function.h include/lldb/Symbol/Type.h source/Commands/CommandObjectImage.cpp source/Core/Value.cpp source/Expression/ClangExpressionDeclMap.cpp source/Expression/ClangFunction.cpp source/Expression/ClangUserExpression.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/ClangASTContext.cpp source/Symbol/Function.cpp source/Symbol/Type.cpp

Greg Clayton gclayton at apple.com
Wed Feb 16 15:00:21 PST 2011


Author: gclayton
Date: Wed Feb 16 17:00:21 2011
New Revision: 125691

URL: http://llvm.org/viewvc/llvm-project?rev=125691&view=rev
Log:
Clean up a bit of the type getting code where lldb_private:Type now has

    clang_type_t
    GetClangFullType(); // Get a completely defined clang type

    clang_type_t
    GetClangLayoutType(); // Get a clang type that can be used for type layout
    
    clang_type_t
    GetClangForwardType(); // A type that can be completed if needed, but is more efficient.
    


Modified:
    lldb/trunk/include/lldb/Core/Value.h
    lldb/trunk/include/lldb/Symbol/Function.h
    lldb/trunk/include/lldb/Symbol/Type.h
    lldb/trunk/source/Commands/CommandObjectImage.cpp
    lldb/trunk/source/Core/Value.cpp
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Expression/ClangFunction.cpp
    lldb/trunk/source/Expression/ClangUserExpression.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp
    lldb/trunk/source/Symbol/Function.cpp
    lldb/trunk/source/Symbol/Type.cpp

Modified: lldb/trunk/include/lldb/Core/Value.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Value.h?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Value.h (original)
+++ lldb/trunk/include/lldb/Core/Value.h Wed Feb 16 17:00:21 2011
@@ -74,7 +74,7 @@
     Value *
     GetProxyTarget();
 
-    void *
+    lldb::clang_type_t
     GetClangType();
 
     ValueType

Modified: lldb/trunk/include/lldb/Symbol/Function.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Function.h?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Function.h (original)
+++ lldb/trunk/include/lldb/Symbol/Function.h Wed Feb 16 17:00:21 2011
@@ -546,19 +546,16 @@
     const Type*
     GetType() const;
 
-    Type
-    GetReturnType ();
+    lldb::clang_type_t
+    GetReturnClangType ();
 
     // The Number of arguments, or -1 for an unprototyped function.
     int
     GetArgumentCount ();
 
-    const Type
+    lldb::clang_type_t
     GetArgumentTypeAtIndex (size_t idx);
 
-    const char *
-    GetArgumentNameAtIndex (size_t idx);
-
     bool
     IsVariadic ();
 

Modified: lldb/trunk/include/lldb/Symbol/Type.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Type.h?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Type.h (original)
+++ lldb/trunk/include/lldb/Symbol/Type.h Wed Feb 16 17:00:21 2011
@@ -185,7 +185,7 @@
     // Get the clang type, and resolve definitions for any 
     // class/struct/union/enum types completely.
     lldb::clang_type_t 
-    GetClangType ();
+    GetClangFullType ();
 
     // Get the clang type, and resolve definitions enough so that the type could
     // have layout performed. This allows ptrs and refs to class/struct/union/enum 

Modified: lldb/trunk/source/Commands/CommandObjectImage.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectImage.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectImage.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectImage.cpp Wed Feb 16 17:00:21 2011
@@ -442,7 +442,7 @@
                     {
                         // Resolve the clang type so that any forward references
                         // to types that haven't yet been parsed will get parsed.
-                        type_sp->GetClangType ();
+                        type_sp->GetClangFullType ();
                         type_sp->GetDescription (&strm, eDescriptionLevelFull, true);
                     }
                     strm.EOL();

Modified: lldb/trunk/source/Core/Value.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Value.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Core/Value.cpp (original)
+++ lldb/trunk/source/Core/Value.cpp Wed Feb 16 17:00:21 2011
@@ -409,7 +409,7 @@
     return byte_size;
 }
 
-void *
+clang_type_t
 Value::GetClangType ()
 {
     if (m_context_type == eContextTypeValue)
@@ -429,12 +429,12 @@
 
     case eContextTypeLLDBType:
         if (GetType())
-            return GetType()->GetClangType();
+            return GetType()->GetClangForwardType();
         break;
 
     case eContextTypeVariable:
         if (GetVariable())
-            return GetVariable()->GetType()->GetClangType();
+            return GetVariable()->GetType()->GetClangForwardType();
         break;
     }
 

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Wed Feb 16 17:00:21 2011
@@ -1503,7 +1503,7 @@
     {
         if (type->GetASTContext() == var_sp->GetType()->GetClangAST())
         {
-            if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangType()))
+            if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var_sp->GetType()->GetClangFullType()))
                 return NULL;
         }
         else
@@ -1642,7 +1642,7 @@
                 log->PutCString (strm.GetData());
             }
 
-            TypeFromUser this_user_type(this_type->GetClangType(),
+            TypeFromUser this_user_type(this_type->GetClangFullType(),
                                         this_type->GetClangAST());
             
             m_struct_vars->m_object_pointer_type = this_user_type;
@@ -1689,7 +1689,7 @@
             if (!self_type)
                 return;
         
-            TypeFromUser self_user_type(self_type->GetClangType(),
+            TypeFromUser self_user_type(self_type->GetClangFullType(),
                                         self_type->GetClangAST());
             
             m_struct_vars->m_object_pointer_type = self_user_type;
@@ -1747,7 +1747,7 @@
             log->PutCString (strm.GetData());
         }
 
-        TypeFromUser user_type (type_sp->GetClangType(),
+        TypeFromUser user_type (type_sp->GetClangFullType(),
                                 type_sp->GetClangAST());
             
         AddOneType(context, user_type, false);
@@ -1775,7 +1775,7 @@
         return NULL;
     }
     
-    void *var_opaque_type = var_type->GetClangType();
+    clang_type_t var_opaque_type = var_type->GetClangFullType();
     
     if (!var_opaque_type)
     {
@@ -2031,7 +2031,7 @@
             return;
         }
         
-        fun_opaque_type = fun_type->GetClangType();
+        fun_opaque_type = fun_type->GetClangFullType();
         
         if (!fun_opaque_type)
         {

Modified: lldb/trunk/source/Expression/ClangFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangFunction.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangFunction.cpp (original)
+++ lldb/trunk/source/Expression/ClangFunction.cpp Wed Feb 16 17:00:21 2011
@@ -103,7 +103,7 @@
     }
 
     m_function_addr = m_function_ptr->GetAddressRange().GetBaseAddress();
-    m_function_return_qual_type = m_function_ptr->GetReturnType().GetClangType();
+    m_function_return_qual_type = m_function_ptr->GetReturnClangType();
 }
 
 //----------------------------------------------------------------------
@@ -163,12 +163,12 @@
     std::string args_list_buffer;  // This one stores the argument list called from the structure.
     for (size_t i = 0; i < num_args; i++)
     {
-        const char *type_string;
-        std::string type_stdstr;
+        std::string type_name;
 
         if (trust_function)
         {
-            type_string = m_function_ptr->GetArgumentTypeAtIndex(i).GetName().AsCString();
+            lldb::clang_type_t arg_clang_type = m_function_ptr->GetArgumentTypeAtIndex(i);
+            type_name = ClangASTContext::GetTypeName(arg_clang_type);
         }
         else
         {
@@ -176,8 +176,7 @@
             void *clang_qual_type = arg_value->GetClangType ();
             if (clang_qual_type != NULL)
             {
-                type_stdstr = ClangASTContext::GetTypeName(clang_qual_type);
-                type_string = type_stdstr.c_str();
+                type_name = ClangASTContext::GetTypeName(clang_qual_type);
             }
             else
             {   
@@ -186,13 +185,13 @@
             }
         }
 
-        m_wrapper_function_text.append (type_string);
+        m_wrapper_function_text.append (type_name);
         if (i < num_args - 1)
             m_wrapper_function_text.append (", ");
 
         char arg_buf[32];
         args_buffer.append ("    ");
-        args_buffer.append (type_string);
+        args_buffer.append (type_name);
         snprintf(arg_buf, 31, "arg_%zd", i);
         args_buffer.push_back (' ');
         args_buffer.append (arg_buf);

Modified: lldb/trunk/source/Expression/ClangUserExpression.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangUserExpression.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangUserExpression.cpp (original)
+++ lldb/trunk/source/Expression/ClangUserExpression.cpp Wed Feb 16 17:00:21 2011
@@ -84,13 +84,12 @@
         
         lldb::clang_type_t pointer_target_type;
         
-        if (ClangASTContext::IsPointerType(this_type->GetClangType(),
+        if (ClangASTContext::IsPointerType(this_type->GetClangForwardType(),
                                            &pointer_target_type))
         {
             TypeFromUser target_ast_type(pointer_target_type, this_type->GetClangAST());
             
-            if (target_ast_type.IsDefined() &&
-                ClangASTContext::IsCXXClassType(target_ast_type.GetOpaqueQualType()))
+            if (ClangASTContext::IsCXXClassType(target_ast_type.GetOpaqueQualType()))
             {
                 m_cplusplus = true;
             

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=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Feb 16 17:00:21 2011
@@ -670,7 +670,7 @@
         {
             Type *class_type = ResolveType (dwarf_cu, parent_die);
             if (class_type)
-                class_type->GetClangType();
+                class_type->GetClangFullType();
         }
         break;
 
@@ -1312,17 +1312,18 @@
                     Type *base_class_type = ResolveTypeUID(encoding_uid);
                     assert(base_class_type);
                     
+                    clang_type_t base_class_clang_type = base_class_type->GetClangFullType();
+                    assert (base_class_clang_type);
                     if (class_language == eLanguageTypeObjC)
                     {
-                        GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_type->GetClangType());
+                        GetClangASTContext().SetObjCSuperClass(class_clang_type, base_class_clang_type);
                     }
                     else
                     {
-                        base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_type->GetClangType(), 
+                        base_classes.push_back (GetClangASTContext().CreateBaseClassSpecifier (base_class_clang_type, 
                                                                                                accessibility, 
                                                                                                is_virtual, 
                                                                                                is_base_of_class));
-                        assert(base_classes.back());
                     }
                 }
             }
@@ -3723,7 +3724,7 @@
                                 element_orders.push_back (1);
                             if (byte_stride == 0 && bit_stride == 0)
                                 byte_stride = element_type->GetByteSize();
-                            clang_type_t array_element_type = element_type->GetClangType();
+                            clang_type_t array_element_type = element_type->GetClangFullType();
                             uint64_t array_element_bit_stride = byte_stride * 8 + bit_stride;
                             uint64_t num_elements = 0;
                             std::vector<uint64_t>::const_reverse_iterator pos;

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Wed Feb 16 17:00:21 2011
@@ -957,8 +957,8 @@
              clang_type_t type1,
              clang_type_t type2)
 {
-    return ast->hasSameType(QualType::getFromOpaquePtr(type1),
-                                    QualType::getFromOpaquePtr(type2));
+    return ast->hasSameType (QualType::getFromOpaquePtr(type1),
+                             QualType::getFromOpaquePtr(type2));
 }
 
 #pragma mark CVR modifiers

Modified: lldb/trunk/source/Symbol/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Function.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Function.cpp (original)
+++ lldb/trunk/source/Symbol/Function.cpp Wed Feb 16 17:00:21 2011
@@ -399,39 +399,20 @@
     return m_type;
 }
 
-Type
-Function::GetReturnType ()
+clang_type_t
+Function::GetReturnClangType ()
 {
-    clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType()));
-    assert (clang_type->isFunctionType());
+    clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType()));
     const clang::FunctionType *function_type = dyn_cast<clang::FunctionType> (clang_type);
-    clang::QualType fun_return_qualtype = function_type->getResultType();
-
-    const ConstString fun_return_name(ClangASTType::GetClangTypeName(fun_return_qualtype.getAsOpaquePtr()));
-
-    SymbolContext sc;
-    CalculateSymbolContext (&sc);
-    // Null out everything below the CompUnit 'cause we don't actually know these.
-
-    size_t bit_size = ClangASTType::GetClangTypeBitWidth (GetType()->GetClangASTContext().getASTContext(), 
-                                                          fun_return_qualtype.getAsOpaquePtr());
-    Type return_type (0, 
-                      GetType()->GetSymbolFile(), 
-                      fun_return_name, 
-                      bit_size, 
-                      sc.comp_unit, 
-                      0, 
-                      Type::eEncodingIsSyntheticUID, 
-                      Declaration(), 
-                      fun_return_qualtype.getAsOpaquePtr(), 
-                      Type::eResolveStateFull);
-    return return_type;
+    if (function_type)
+        return function_type->getResultType().getAsOpaquePtr();
+    return NULL;
 }
 
 int
 Function::GetArgumentCount ()
 {
-    clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType()));
+    clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType()));
     assert (clang_type->isFunctionType());
     if (!clang_type->isFunctionProtoType())
         return -1;
@@ -443,67 +424,33 @@
     return 0;
 }
 
-const Type
+clang_type_t
 Function::GetArgumentTypeAtIndex (size_t idx)
 {
-    clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangType()));
-   assert (clang_type->isFunctionType());
-   if (!clang_type->isFunctionProtoType())
-        return Type();
-
+    clang::QualType clang_type (clang::QualType::getFromOpaquePtr(GetType()->GetClangFullType()));
     const clang::FunctionProtoType *function_proto_type = dyn_cast<clang::FunctionProtoType>(clang_type);
-    if (function_proto_type != NULL)
+    if (function_proto_type)
     {
         unsigned num_args = function_proto_type->getNumArgs();
         if (idx >= num_args)
-            return Type();
-        clang::QualType arg_qualtype = (function_proto_type->arg_type_begin())[idx];
-
-        const ConstString arg_return_name(ClangASTType::GetClangTypeName(arg_qualtype.getAsOpaquePtr()));
-        SymbolContext sc;
-        CalculateSymbolContext (&sc);
-        // Null out everything below the CompUnit 'cause we don't actually know these.
-
-        size_t bit_size = ClangASTType::GetClangTypeBitWidth ((GetType()->GetClangASTContext().getASTContext()), arg_qualtype.getAsOpaquePtr());
-        Type arg_type (0, 
-                       GetType()->GetSymbolFile(), 
-                       arg_return_name, 
-                       bit_size, 
-                       sc.comp_unit, 
-                       0, 
-                       Type::eEncodingIsSyntheticUID, 
-                       Declaration(), 
-                       arg_qualtype.getAsOpaquePtr(), 
-                       Type::eResolveStateFull);
-        return arg_type;
+            return NULL;
+        
+        return (function_proto_type->arg_type_begin())[idx].getAsOpaquePtr();
     }
-
-    return Type();
-}
-
-const char *
-Function::GetArgumentNameAtIndex (size_t idx)
-{
-   const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangType())->getTypePtr();
-   assert (clang_type->isFunctionType());
-   if (!clang_type->isFunctionProtoType())
-       return NULL;
     return NULL;
 }
 
 bool
 Function::IsVariadic ()
 {
-   const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangType())->getTypePtr();
+   const clang::Type *clang_type = static_cast<clang::QualType *>(GetType()->GetClangFullType())->getTypePtr();
    assert (clang_type->isFunctionType());
    if (!clang_type->isFunctionProtoType())
         return false;
 
     const clang::FunctionProtoType *function_proto_type = dyn_cast<clang::FunctionProtoType>(clang_type);
-    if (function_proto_type != NULL)
-    {
+    if (function_proto_type)
         return function_proto_type->isVariadic();
-    }
 
     return false;
 }

Modified: lldb/trunk/source/Symbol/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Type.cpp?rev=125691&r1=125690&r2=125691&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/Type.cpp (original)
+++ lldb/trunk/source/Symbol/Type.cpp Wed Feb 16 17:00:21 2011
@@ -578,7 +578,7 @@
 }
 
 clang_type_t 
-Type::GetClangType ()
+Type::GetClangFullType ()
 {
     ResolveClangType(eResolveStateFull);
     return m_clang_type;





More information about the lldb-commits mailing list