Commit de2c7cab authored by shafik's avatar shafik
Browse files

Add support for DW_AT_export_symbols for anonymous structs

Summary:
We add support for DW_AT_export_symbols to detect anonymous struct on top of the heuristics implemented in D66175
This should allow us to differentiate anonymous structs and unnamed structs.
We also fix TestTypeList.py which was incorrectly detecting an unnamed struct as an anonymous struct.

Differential Revision: https://reviews.llvm.org/D68961
parent 85b718f5
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -261,7 +261,8 @@ public:
  CompilerType CreateRecordType(clang::DeclContext *decl_ctx,
                                lldb::AccessType access_type, const char *name,
                                int kind, lldb::LanguageType language,
                                ClangASTMetadata *metadata = nullptr);
                                ClangASTMetadata *metadata = nullptr,
                                bool exports_symbols = false);

  class TemplateParameterInfos {
  public:
+6 −2
Original line number Diff line number Diff line
@@ -73,13 +73,17 @@ class TypeAndTypeListTestCase(TestBase):
                        self.assertTrue(enum_member)
                        self.DebugSBType(enum_member.type)
                elif field.name == "my_type_is_nameless":
                    self.assertTrue(
                    self.assertFalse(
                        field.type.IsAnonymousType(),
                        "my_type_is_nameless has an anonymous type")
                        "my_type_is_nameless is not an anonymous type")
                elif field.name == "my_type_is_named":
                    self.assertFalse(
                        field.type.IsAnonymousType(),
                        "my_type_is_named has a named type")
                elif field.name == None:
                    self.assertTrue(
                        field.type.IsAnonymousType(),
                        "Nameless type is not anonymous")

        # Pass an empty string.  LLDB should not crash. :-)
        fuzz_types = target.FindTypes(None)
+8 −0
Original line number Diff line number Diff line
@@ -15,6 +15,14 @@ public:
        TASK_TYPE_1,
        TASK_TYPE_2
    } type;
    // This struct is anonymous b/c it does not have a name
    // and it is not unnamed class.
    // Anonymous classes are a GNU extension.
    struct {
      int y;
    };
    // This struct is an unnamed class see [class.pre]p1
    // http://eel.is/c++draft/class#pre-1.sentence-6
    struct {
      int x;
    } my_type_is_nameless;
+4 −1
Original line number Diff line number Diff line
@@ -347,6 +347,9 @@ ParsedDWARFTypeAttributes::ParsedDWARFTypeAttributes(const DWARFDIE &die) {
    case DW_AT_GNU_vector:
      is_vector = form_value.Boolean();
      break;
    case DW_AT_export_symbols:
      exports_symbols = form_value.Boolean();
      break;
    }
  }
}
@@ -1546,7 +1549,7 @@ DWARFASTParserClang::ParseStructureLikeDIE(const DWARFDIE &die,
      clang_type_was_created = true;
      clang_type = m_ast.CreateRecordType(
          decl_ctx, attrs.accessibility, attrs.name.GetCString(), tag_decl_kind,
          attrs.class_language, &metadata);
          attrs.class_language, &metadata, attrs.exports_symbols);
    }
  }

+1 −0
Original line number Diff line number Diff line
@@ -181,6 +181,7 @@ struct ParsedDWARFTypeAttributes {
  bool is_scoped_enum = false;
  bool is_vector = false;
  bool is_virtual = false;
  bool exports_symbols = false;
  clang::StorageClass storage = clang::SC_None;
  const char *mangled_name = nullptr;
  lldb_private::ConstString name;
Loading