Did a lot of code cleanup.

Fixed the DWARF plug-in such that when it gets all attributes for a DIE, that
it omits the DW_AT_sibling and DW_AT_declaration when getting attributes
from a DW_AT_abstract_origin or DW_AT_specification DIE.

llvm-svn: 118654
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 4fd7681..7c24398 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -145,6 +145,7 @@
 SymbolFileDWARF::SymbolFileDWARF(ObjectFile* objfile) :
     SymbolFile (objfile),
     m_debug_map_symfile (NULL),
+    m_clang_tu_decl (NULL),
     m_flags(),
     m_data_debug_abbrev(),
     m_data_debug_frame(),
@@ -2531,7 +2532,10 @@
 
         die = die->GetParent();
     }
-    return NULL;
+    // Right now we have only one translation unit per module...
+    if (m_clang_tu_decl == NULL)
+        m_clang_tu_decl = m_obj_file->GetModule()->GetTypeList()->GetClangASTContext().getASTContext()->getTranslationUnitDecl();
+    return m_clang_tu_decl;
 }
 
 // This function can be used when a DIE is found that is a forward declaration
@@ -2810,12 +2814,7 @@
                                     break;
 
                                 case DW_AT_declaration: 
-                                    // Make sure the declaration is from this DIE, and not from 
-                                    // a DW_AT_specification or DW_AT_abstract_origin by checking
-                                    // this die and seeing if its abbreviations have the
-                                    // DW_AT_declaration attribute
-                                    if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX)
-                                        is_forward_declaration = form_value.Unsigned() != 0; 
+                                    is_forward_declaration = form_value.Unsigned() != 0; 
                                     break;
 
                                 case DW_AT_APPLE_runtime_class: 
@@ -2938,24 +2937,17 @@
                             {
                                 switch (attr)
                                 {
-                                case DW_AT_decl_file:   decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
-                                case DW_AT_decl_line:   decl.SetLine(form_value.Unsigned()); break;
-                                case DW_AT_decl_column: decl.SetColumn(form_value.Unsigned()); break;
+                                case DW_AT_decl_file:       decl.SetFile(sc.comp_unit->GetSupportFiles().GetFileSpecAtIndex(form_value.Unsigned())); break;
+                                case DW_AT_decl_line:       decl.SetLine(form_value.Unsigned()); break;
+                                case DW_AT_decl_column:     decl.SetColumn(form_value.Unsigned()); break;
                                 case DW_AT_name:
                                     type_name_cstr = form_value.AsCString(&get_debug_str_data());
                                     type_name_const_str.SetCString(type_name_cstr);
                                     break;
-                                case DW_AT_type:        encoding_uid = form_value.Reference(dwarf_cu); break;
-                                case DW_AT_byte_size:   byte_size = form_value.Unsigned(); break;
-                                case DW_AT_accessibility: accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
-                                case DW_AT_declaration: 
-                                    // Make sure the declaration is from this DIE, and not from 
-                                    // a DW_AT_specification or DW_AT_abstract_origin by checking
-                                    // this die and seeing if its abbreviations have the
-                                    // DW_AT_declaration attribute
-                                    if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX)
-                                        is_forward_declaration = form_value.Unsigned() != 0; 
-                                    break;
+                                case DW_AT_type:            encoding_uid = form_value.Reference(dwarf_cu); break;
+                                case DW_AT_byte_size:       byte_size = form_value.Unsigned(); break;
+                                case DW_AT_accessibility:   accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
+                                case DW_AT_declaration:     is_forward_declaration = form_value.Unsigned() != 0; break;
                                 case DW_AT_allocated:
                                 case DW_AT_associated:
                                 case DW_AT_bit_stride:
@@ -3047,14 +3039,7 @@
                                 case DW_AT_MIPS_linkage_name:   mangled = form_value.AsCString(&get_debug_str_data()); break;
                                 case DW_AT_type:                type_die_offset = form_value.Reference(dwarf_cu); break;
                                 case DW_AT_accessibility:       accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
-                                case DW_AT_declaration: 
-                                    // Make sure the declaration is from this DIE, and not from 
-                                    // a DW_AT_specification or DW_AT_abstract_origin by checking
-                                    // this die and seeing if its abbreviations have the
-                                    // DW_AT_declaration attribute
-                                    if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX)
-                                        is_forward_declaration = form_value.Unsigned() != 0; 
-                                    break;
+                                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; 
@@ -3267,14 +3252,7 @@
                                 case DW_AT_byte_stride:     byte_stride = form_value.Unsigned(); break;
                                 case DW_AT_bit_stride:      bit_stride = form_value.Unsigned(); break;
                                 case DW_AT_accessibility:   accessibility = DW_ACCESS_to_AccessType(form_value.Unsigned()); break;
-                                case DW_AT_declaration: 
-                                    // Make sure the declaration is from this DIE, and not from 
-                                    // a DW_AT_specification or DW_AT_abstract_origin by checking
-                                    // this die and seeing if its abbreviations have the
-                                    // DW_AT_declaration attribute
-                                    if (die->GetAbbreviationDeclarationPtr()->FindAttributeIndex (DW_AT_declaration) != DW_INVALID_INDEX)
-                                        is_forward_declaration = form_value.Unsigned() != 0; 
-                                    break;
+                                case DW_AT_declaration:     is_forward_declaration = form_value.Unsigned() != 0; break;
                                 case DW_AT_allocated:
                                 case DW_AT_associated:
                                 case DW_AT_data_location: