[Lldb-commits] [lldb] r143526 - in /lldb/trunk: include/lldb/Symbol/ClangASTContext.h source/Expression/ClangExpressionDeclMap.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Symbol/ClangASTContext.cpp

Sean Callanan scallanan at apple.com
Tue Nov 1 18:38:59 PDT 2011


Author: spyffe
Date: Tue Nov  1 20:38:59 2011
New Revision: 143526

URL: http://llvm.org/viewvc/llvm-project?rev=143526&view=rev
Log:
Sometimes the debug information includes artifically-
generated special member functions (constructors,
destructors, etc.) for classes that don't really have
them.  We needed to mark these as artificial to reflect
the debug information; this bug does that for
constructors and destructors.

The "etc." case (certain assignment operators, mostly)
remains to be fixed.

Modified:
    lldb/trunk/include/lldb/Symbol/ClangASTContext.h
    lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
    lldb/trunk/source/Symbol/ClangASTContext.cpp

Modified: lldb/trunk/include/lldb/Symbol/ClangASTContext.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTContext.h?rev=143526&r1=143525&r2=143526&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTContext.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTContext.h Tue Nov  1 20:38:59 2011
@@ -280,7 +280,8 @@
                               bool is_static,
                               bool is_inline,
                               bool is_explicit,
-                              bool is_attr_used);
+                              bool is_attr_used,
+                              bool is_artificial);
     
     clang::CXXMethodDecl *
     AddMethodToCXXRecordType (lldb::clang_type_t record_opaque_type,
@@ -291,7 +292,8 @@
                               bool is_static,
                               bool is_inline,
                               bool is_explicit,
-                              bool is_attr_used)
+                              bool is_attr_used,
+                              bool is_artificial)
     
     {
         return ClangASTContext::AddMethodToCXXRecordType (getASTContext(),
@@ -303,7 +305,8 @@
                                                           is_static,
                                                           is_inline,
                                                           is_explicit,
-                                                          is_attr_used);
+                                                          is_attr_used,
+                                                          is_artificial);
     }
     
     class TemplateParameterInfos

Modified: lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp?rev=143526&r1=143525&r2=143526&view=diff
==============================================================================
--- lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp (original)
+++ lldb/trunk/source/Expression/ClangExpressionDeclMap.cpp Tue Nov  1 20:38:59 2011
@@ -3017,6 +3017,7 @@
         const bool is_inline = false;
         const bool is_explicit = false;
         const bool is_attr_used = false;
+        const bool is_artificial = false;
         
         ClangASTContext::AddMethodToCXXRecordType (parser_ast_context,
                                                    copied_type,
@@ -3027,7 +3028,8 @@
                                                    is_static,
                                                    is_inline,
                                                    is_explicit,
-                                                   is_attr_used);
+                                                   is_attr_used,
+                                                   is_artificial);
     }
     
     context.AddTypeDecl(copied_type);

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=143526&r1=143525&r2=143526&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Tue Nov  1 20:38:59 2011
@@ -4298,6 +4298,7 @@
                     bool is_static = false;
                     bool is_virtual = false;
                     bool is_explicit = false;
+                    bool is_artificial = false;
                     dw_offset_t specification_die_offset = DW_INVALID_OFFSET;
                     dw_offset_t abstract_origin_die_offset = DW_INVALID_OFFSET;
 
@@ -4332,6 +4333,8 @@
                                 case DW_AT_inline:              is_inline = form_value.Unsigned() != 0; break;
                                 case DW_AT_virtuality:          is_virtual = form_value.Unsigned() != 0;  break;
                                 case DW_AT_explicit:            is_explicit = form_value.Unsigned() != 0;  break; 
+                                case DW_AT_artificial:          is_artificial = form_value.Unsigned() != 0;  break; 
+                                        
 
                                 case DW_AT_external:
                                     if (form_value.Unsigned())
@@ -4351,11 +4354,9 @@
                                     abstract_origin_die_offset = form_value.Reference(dwarf_cu);
                                     break;
 
-
                                 case DW_AT_allocated:
                                 case DW_AT_associated:
                                 case DW_AT_address_class:
-                                case DW_AT_artificial:
                                 case DW_AT_calling_convention:
                                 case DW_AT_data_location:
                                 case DW_AT_elemental:
@@ -4580,7 +4581,8 @@
                                                                                                     is_static,
                                                                                                     is_inline,
                                                                                                     is_explicit,
-                                                                                                    is_attr_used);
+                                                                                                    is_attr_used,
+                                                                                                    is_artificial);
                                                     LinkDeclContextToDIE(ClangASTContext::GetAsDeclContext(cxx_method_decl), die);
 
                                                     type_handled = cxx_method_decl != NULL;

Modified: lldb/trunk/source/Symbol/ClangASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTContext.cpp?rev=143526&r1=143525&r2=143526&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTContext.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTContext.cpp Tue Nov  1 20:38:59 2011
@@ -1575,7 +1575,8 @@
     bool is_static,
     bool is_inline,
     bool is_explicit,
-    bool is_attr_used
+    bool is_attr_used,
+    bool is_artificial
 )
 {
     if (!record_opaque_type || !method_opaque_type || !name)
@@ -1600,8 +1601,6 @@
     
     DeclarationName decl_name (&identifier_table->get(name));
 
-    const bool is_implicitly_declared = false;
-    
     const clang::FunctionType *function_Type = dyn_cast<FunctionType>(method_qual_type.getTypePtr());
     
     if (function_Type == NULL)
@@ -1614,29 +1613,34 @@
     
     unsigned int num_params = method_function_prototype->getNumArgs();
     
+    CXXDestructorDecl *cxx_dtor_decl(NULL);
+    CXXConstructorDecl *cxx_ctor_decl(NULL);
+    
     if (name[0] == '~')
     {
-        cxx_method_decl = CXXDestructorDecl::Create (*ast,
-                                                     cxx_record_decl,
-                                                     SourceLocation(),
-                                                     DeclarationNameInfo (ast->DeclarationNames.getCXXDestructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
-                                                     method_qual_type,
-                                                     NULL,
-                                                     is_inline,
-                                                     is_implicitly_declared);
+        cxx_dtor_decl = CXXDestructorDecl::Create (*ast,
+                                                   cxx_record_decl,
+                                                   SourceLocation(),
+                                                   DeclarationNameInfo (ast->DeclarationNames.getCXXDestructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
+                                                   method_qual_type,
+                                                   NULL,
+                                                   is_inline,
+                                                   is_artificial);
+        cxx_method_decl = cxx_dtor_decl;
     }
     else if (decl_name == cxx_record_decl->getDeclName())
     {
-        cxx_method_decl = CXXConstructorDecl::Create (*ast,
-                                                      cxx_record_decl,
-                                                      SourceLocation(),
-                                                      DeclarationNameInfo (ast->DeclarationNames.getCXXConstructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
-                                                      method_qual_type,
-                                                      NULL, // TypeSourceInfo *
-                                                      is_explicit, 
-                                                      is_inline,
-                                                      is_implicitly_declared,
-                                                      false /*is_constexpr*/);
+       cxx_ctor_decl = CXXConstructorDecl::Create (*ast,
+                                                   cxx_record_decl,
+                                                   SourceLocation(),
+                                                   DeclarationNameInfo (ast->DeclarationNames.getCXXConstructorName (ast->getCanonicalType (record_qual_type)), SourceLocation()),
+                                                   method_qual_type,
+                                                   NULL, // TypeSourceInfo *
+                                                   is_explicit, 
+                                                   is_inline,
+                                                   is_artificial,
+                                                   false /*is_constexpr*/);
+        cxx_method_decl = cxx_ctor_decl;
     }
     else
     {   
@@ -1729,6 +1733,20 @@
     
     cxx_record_decl->addDecl (cxx_method_decl);
     
+    if (is_artificial)
+    {
+        if (cxx_ctor_decl && cxx_ctor_decl->isCopyConstructor() && cxx_record_decl->hasTrivialCopyConstructor())
+        {
+            cxx_ctor_decl->setDefaulted();
+            cxx_ctor_decl->setTrivial(true);
+        }
+        else if (cxx_dtor_decl && cxx_record_decl->hasTrivialDestructor())
+        {
+            cxx_dtor_decl->setDefaulted();
+            cxx_dtor_decl->setTrivial(true);
+        }
+    }
+    
 #ifdef LLDB_CONFIGURATION_DEBUG
     VerifyDecl(cxx_method_decl);
 #endif





More information about the lldb-commits mailing list