[Lldb-commits] [lldb] [SymbolFileDWARF][NFC] Remove duplicated code checking for type tags (PR #74773)

Felipe de Azevedo Piovezan via lldb-commits lldb-commits at lists.llvm.org
Fri Dec 8 05:34:35 PST 2023


================
@@ -3128,36 +3121,11 @@ SymbolFileDWARF::FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) {
       if (type_system &&
           !type_system->SupportsLanguage(GetLanguage(*type_die.GetCU())))
         return true;
-      bool try_resolving_type = false;
 
-      // Don't try and resolve the DIE we are looking for with the DIE
-      // itself!
       const dw_tag_t type_tag = type_die.Tag();
-      // Make sure the tags match
-      if (type_tag == tag) {
-        // The tags match, lets try resolving this type
-        try_resolving_type = true;
-      } else {
-        // The tags don't match, but we need to watch our for a forward
-        // declaration for a struct and ("struct foo") ends up being a
-        // class ("class foo { ... };") or vice versa.
-        switch (type_tag) {
-        case DW_TAG_class_type:
-          // We had a "class foo", see if we ended up with a "struct foo
-          // { ... };"
-          try_resolving_type = (tag == DW_TAG_structure_type);
-          break;
-        case DW_TAG_structure_type:
-          // We had a "struct foo", see if we ended up with a "class foo
-          // { ... };"
-          try_resolving_type = (tag == DW_TAG_class_type);
-          break;
-        default:
-          // Tags don't match, don't event try to resolve using this type
-          // whose name matches....
-          break;
-        }
-      }
+      // Resolve the type if both have the same tag or {class, struct} tags.
+      const bool try_resolving_type =
+          type_tag == tag || (IsTypeTag(type_tag) && IsTypeTag(tag));
----------------
felipepiovezan wrote:

I'm not sure I follow, the logic of the opposite: equality failed, so we have to test whether both are "clasd-ish" tags. If one is a class but the other is a namespace, we need this expression to be false

https://github.com/llvm/llvm-project/pull/74773


More information about the lldb-commits mailing list