labath created this revision.
labath added reviewers: clayborg, JDevlieghere, aprantl.
Herald added a subscriber: jdoerfert.

The function was not being consistent in how it retrieved the language
of the current compile unit. Sometimes it did so from the lldb CU
object, and sometimes from the DWARF die. This patch unifies the
handling on the latter. The reason for choosing the DWARF method is
because I'd eventually like to stop creating lldb CUs for dwarf type
units (and so this code needs to would need to work without them).


https://reviews.llvm.org/D62481

Files:
  source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp


Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -294,6 +294,7 @@
 
   dw_attr_t attr;
   TypeSP type_sp;
+  LanguageType cu_language = die.GetLanguage();
   switch (tag) {
   case DW_TAG_typedef:
   case DW_TAG_base_type:
@@ -468,11 +469,8 @@
         }
       }
 
-      bool translation_unit_is_objc =
-          (sc.comp_unit->GetLanguage() == eLanguageTypeObjC ||
-           sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
-
-      if (translation_unit_is_objc) {
+      if (cu_language == eLanguageTypeObjC ||
+          cu_language == eLanguageTypeObjC_plus_plus) {
         if (type_name_cstr != nullptr) {
           static ConstString g_objc_type_name_id("id");
           static ConstString g_objc_type_name_Class("Class");
@@ -629,8 +627,7 @@
     Declaration unique_decl(decl);
 
     if (type_name_const_str) {
-      LanguageType die_language = die.GetLanguage();
-      if (Language::LanguageIsCPlusPlus(die_language)) {
+      if (Language::LanguageIsCPlusPlus(cu_language)) {
         // For C++, we rely solely upon the one definition rule that says
         // only one thing can exist at a given decl context. We ignore the
         // file and line that things are declared on.
@@ -668,7 +665,7 @@
     }
 
     if (byte_size && *byte_size == 0 && type_name_cstr && !die.HasChildren() &&
-        sc.comp_unit->GetLanguage() == eLanguageTypeObjC) {
+        cu_language == eLanguageTypeObjC) {
       // Work around an issue with clang at the moment where forward
       // declarations for objective C classes are emitted as:
       //  DW_TAG_structure_type [2]


Index: source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -294,6 +294,7 @@
 
   dw_attr_t attr;
   TypeSP type_sp;
+  LanguageType cu_language = die.GetLanguage();
   switch (tag) {
   case DW_TAG_typedef:
   case DW_TAG_base_type:
@@ -468,11 +469,8 @@
         }
       }
 
-      bool translation_unit_is_objc =
-          (sc.comp_unit->GetLanguage() == eLanguageTypeObjC ||
-           sc.comp_unit->GetLanguage() == eLanguageTypeObjC_plus_plus);
-
-      if (translation_unit_is_objc) {
+      if (cu_language == eLanguageTypeObjC ||
+          cu_language == eLanguageTypeObjC_plus_plus) {
         if (type_name_cstr != nullptr) {
           static ConstString g_objc_type_name_id("id");
           static ConstString g_objc_type_name_Class("Class");
@@ -629,8 +627,7 @@
     Declaration unique_decl(decl);
 
     if (type_name_const_str) {
-      LanguageType die_language = die.GetLanguage();
-      if (Language::LanguageIsCPlusPlus(die_language)) {
+      if (Language::LanguageIsCPlusPlus(cu_language)) {
         // For C++, we rely solely upon the one definition rule that says
         // only one thing can exist at a given decl context. We ignore the
         // file and line that things are declared on.
@@ -668,7 +665,7 @@
     }
 
     if (byte_size && *byte_size == 0 && type_name_cstr && !die.HasChildren() &&
-        sc.comp_unit->GetLanguage() == eLanguageTypeObjC) {
+        cu_language == eLanguageTypeObjC) {
       // Work around an issue with clang at the moment where forward
       // declarations for objective C classes are emitted as:
       //  DW_TAG_structure_type [2]
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to