summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-05-25 10:49:11 +0000
committerPavel Labath <labath@google.com>2018-05-25 10:49:11 +0000
commita2aad28f6d18b3d9590cd52d650a4598800ce298 (patch)
treebf69730e6670eabb7ae2bce1ece2b71dc4e6ad8a
parentc82f38214a279c70eb049eeafb831c73be558042 (diff)
downloadbcm5719-llvm-a2aad28f6d18b3d9590cd52d650a4598800ce298.tar.gz
bcm5719-llvm-a2aad28f6d18b3d9590cd52d650a4598800ce298.zip
ManualDWARFIndex: Fix misclassification of methods in unions
Apple index was already treating them as methods. Not doing the same seems like an omission. llvm-svn: 333266
-rw-r--r--lldb/lit/SymbolFile/DWARF/find-method.cpp31
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp5
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h2
-rw-r--r--lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp9
4 files changed, 39 insertions, 8 deletions
diff --git a/lldb/lit/SymbolFile/DWARF/find-method.cpp b/lldb/lit/SymbolFile/DWARF/find-method.cpp
new file mode 100644
index 00000000000..740460124ea
--- /dev/null
+++ b/lldb/lit/SymbolFile/DWARF/find-method.cpp
@@ -0,0 +1,31 @@
+// REQUIRES: lld
+
+// RUN: clang %s -g -c -o %t.o --target=x86_64-pc-linux
+// RUN: ld.lld %t.o -o %t
+// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
+// RUN: FileCheck %s
+//
+// RUN: clang %s -g -c -o %t --target=x86_64-apple-macosx
+// RUN: lldb-test symbols --name=foo --find=function --function-flags=method %t | \
+// RUN: FileCheck %s
+
+// CHECK-DAG: name = "A::foo()", mangled = "_ZN1A3fooEv"
+// CHECK-DAG: name = "B::foo()", mangled = "_ZN1B3fooEv"
+// CHECK-DAG: name = "C::foo()", mangled = "_ZN1C3fooEv"
+
+struct A {
+ void foo();
+};
+void A::foo() {}
+
+class B {
+ void foo();
+};
+void B::foo() {}
+
+union C {
+ void foo();
+};
+void C::foo() {}
+
+extern "C" void _start() {}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
index fc167c9fd90..d7190047348 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp
@@ -209,9 +209,10 @@ DWARFDIE::GetParentDeclContextDIE() const {
return DWARFDIE();
}
-bool DWARFDIE::IsStructOrClass() const {
+bool DWARFDIE::IsStructClassOrUnion() const {
const dw_tag_t tag = Tag();
- return tag == DW_TAG_class_type || tag == DW_TAG_structure_type;
+ return tag == DW_TAG_class_type || tag == DW_TAG_structure_type ||
+ tag == DW_TAG_union_type;
}
DWARFDIE
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
index cd96a67a078..ca124f3c24c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h
@@ -19,7 +19,7 @@ public:
//----------------------------------------------------------------------
// Tests
//----------------------------------------------------------------------
- bool IsStructOrClass() const;
+ bool IsStructClassOrUnion() const;
//----------------------------------------------------------------------
// Accessors
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
index fea31e80bdf..719478537ac 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -290,16 +290,15 @@ void ManualDWARFIndex::IndexUnitImpl(
const DWARFDebugInfoEntry *parent = die.GetParent();
bool is_method = false;
if (parent) {
- dw_tag_t parent_tag = parent->Tag();
- if (parent_tag == DW_TAG_class_type ||
- parent_tag == DW_TAG_structure_type) {
+ DWARFDIE parent_die(&unit, parent);
+ if (parent_die.IsStructClassOrUnion())
is_method = true;
- } else {
+ else {
if (specification_die_form.IsValid()) {
DWARFDIE specification_die =
unit.GetSymbolFileDWARF()->DebugInfo()->GetDIE(
DIERef(specification_die_form));
- if (specification_die.GetParent().IsStructOrClass())
+ if (specification_die.GetParent().IsStructClassOrUnion())
is_method = true;
}
}
OpenPOWER on IntegriCloud