From de2c7cab715e195c9d559d317beb760cf0b95262 Mon Sep 17 00:00:00 2001 From: shafik Date: Mon, 28 Oct 2019 14:26:54 -0700 Subject: 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 --- .../Python/lldbsuite/test/python_api/type/TestTypeList.py | 8 ++++++-- lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'lldb/packages/Python/lldbsuite/test/python_api') diff --git a/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py b/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py index b3b321c6ca8..75a793a95b2 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py +++ b/lldb/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py @@ -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) diff --git a/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp b/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp index 8f5b93927c7..b43b617b0f9 100644 --- a/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp +++ b/lldb/packages/Python/lldbsuite/test/python_api/type/main.cpp @@ -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; -- cgit v1.2.3