Make C++ constructors and destructors correctly within the clang types we
generate from DWARF.



git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@115268 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Expression/ClangExpressionDeclMap.cpp b/source/Expression/ClangExpressionDeclMap.cpp
index 43c4150..2c244bd 100644
--- a/source/Expression/ClangExpressionDeclMap.cpp
+++ b/source/Expression/ClangExpressionDeclMap.cpp
@@ -1119,11 +1119,12 @@
                                                                  1,
                                                                  false,
                                                                  ClangASTContext::GetTypeQualifiers(copied_type));
-        
+
         const bool is_virtual = false;
         const bool is_static = false;
         const bool is_inline = false;
-
+        const bool is_explicit = false;
+        
         ClangASTContext::AddMethodToCXXRecordType (parser_ast_context,
                                                    copied_type,
                                                    "___clang_expr",
@@ -1131,7 +1132,8 @@
                                                    lldb::eAccessPublic,
                                                    is_virtual,
                                                    is_static,
-                                                   is_inline);
+                                                   is_inline,
+                                                   is_explicit);
     }
     
     context.AddTypeDecl(copied_type);
diff --git a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9447929..f7a177d 100644
--- a/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2797,6 +2797,7 @@
                     bool is_inline = false;
                     bool is_static = false;
                     bool is_virtual = false;
+                    bool is_explicit = false;
 
                     unsigned type_quals = 0;
                     clang::StorageClass storage = clang::SC_None;//, Extern, Static, PrivateExtern
@@ -2828,6 +2829,8 @@
                                 case DW_AT_declaration:         is_forward_declaration = form_value.Unsigned() != 0; break;
                                 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_external:
                                     if (form_value.Unsigned())
                                     {
@@ -2846,7 +2849,6 @@
                                 case DW_AT_data_location:
                                 case DW_AT_elemental:
                                 case DW_AT_entry_pc:
-                                case DW_AT_explicit:
                                 case DW_AT_frame_base:
                                 case DW_AT_high_pc:
                                 case DW_AT_low_pc:
@@ -2872,12 +2874,17 @@
                         }
 
                         clang_type_t return_clang_type = NULL;
-                        Type *func_type = ResolveTypeUID(type_die_offset);
+                        Type *func_type = NULL;
+                        
+                        if (type_die_offset != DW_INVALID_OFFSET)
+                            func_type = ResolveTypeUID(type_die_offset);
+
                         if (func_type)
                             return_clang_type = func_type->GetClangType(true);
                         else
                             return_clang_type = type_list->GetClangASTContext().GetBuiltInType_void();
 
+
                         std::vector<clang_type_t> function_param_types;
                         std::vector<clang::ParmVarDecl*> function_param_decls;
 
@@ -2887,6 +2894,7 @@
 
                         // clang_type will get the function prototype clang type after this call
                         clang_type = type_list->GetClangASTContext().CreateFunctionType (return_clang_type, &function_param_types[0], function_param_types.size(), is_variadic, type_quals);
+
                         if (type_name_cstr)
                         {
                             bool type_handled = false;
@@ -2960,7 +2968,8 @@
                                                                                                                         accessibility,
                                                                                                                         is_virtual,
                                                                                                                         is_static,
-                                                                                                                        is_inline);
+                                                                                                                        is_inline,
+                                                                                                                        is_explicit);
                                             type_handled = cxx_method_decl != NULL;
                                         }
                                     }
diff --git a/source/Symbol/ClangASTContext.cpp b/source/Symbol/ClangASTContext.cpp
index 83d5709..6a03514 100644
--- a/source/Symbol/ClangASTContext.cpp
+++ b/source/Symbol/ClangASTContext.cpp
@@ -813,7 +813,8 @@
     lldb::AccessType access,
     bool is_virtual,
     bool is_static,
-    bool is_inline
+    bool is_inline,
+    bool is_explicit
 )
 {
     if (!record_opaque_type || !method_opaque_type || !name)
@@ -849,15 +850,34 @@
     
     QualType method_qual_type (QualType::getFromOpaquePtr (method_opaque_type));
     
-    CXXMethodDecl *cxx_method_decl = CXXMethodDecl::Create (*ast_context,
-                                                            cxx_record_decl,
-                                                            DeclarationNameInfo (DeclarationName (&identifier_table->get(name)), SourceLocation()),
-                                                            method_qual_type,
-                                                            NULL, // TypeSourceInfo *
-                                                            is_static,
-                                                            SC_None,
-                                                            is_inline);
+    CXXMethodDecl *cxx_method_decl = NULL;
     
+    DeclarationName decl_name (&identifier_table->get(name));
+    
+    if (name[0] == '~' || decl_name == record_decl->getDeclName())
+    {
+        bool is_implicitly_declared = false;
+        cxx_method_decl = CXXConstructorDecl::Create (*ast_context,
+                                                      cxx_record_decl,
+                                                      DeclarationNameInfo (decl_name, SourceLocation()),
+                                                      method_qual_type,
+                                                      NULL, // TypeSourceInfo *
+                                                      is_explicit, 
+                                                      is_inline,
+                                                      is_implicitly_declared);
+    }
+    else
+    {    
+        cxx_method_decl = CXXMethodDecl::Create (*ast_context,
+                                                 cxx_record_decl,
+                                                 DeclarationNameInfo (decl_name, SourceLocation()),
+                                                 method_qual_type,
+                                                 NULL, // TypeSourceInfo *
+                                                 is_static,
+                                                 SC_None,
+                                                 is_inline);
+    }
+        
     
     AccessSpecifier access_specifier = ConvertAccessTypeToAccessSpecifier (access);