summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python
diff options
context:
space:
mode:
authorShafik Yaghmour <syaghmour@apple.com>2019-05-01 22:23:06 +0000
committerShafik Yaghmour <syaghmour@apple.com>2019-05-01 22:23:06 +0000
commit2097b1f84d47419f18a4a737e4a00cc26313b868 (patch)
tree603ff0f38d3dd9202ed34bcc4ec7feb31c9b8c2e /lldb/packages/Python
parentfbcec6cad03969405e3712a73531c4703dd030a3 (diff)
downloadbcm5719-llvm-2097b1f84d47419f18a4a737e4a00cc26313b868.tar.gz
bcm5719-llvm-2097b1f84d47419f18a4a737e4a00cc26313b868.zip
Set a CXXRecordDecl to not be passed in registers if DW_CC_pass_by_reference when loading from DWARF
Summary: This will fix a bug where during expression parsing we are not setting a CXXRecordDecl to not be passed in registers and the resulting code generation is wrong. The DWARF attribute DW_CC_pass_by_reference tells us that we should not be passing in registers i.e. RAA_Indirect. This change depends this clang change which fixes the fact that the ASTImporter does not copy RecordDeclBits for CXXRecordDecl: https://reviews.llvm.org/D61140 Differential Revision: https://reviews.llvm.org/D61146 llvm-svn: 359732
Diffstat (limited to 'lldb/packages/Python')
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile5
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py32
-rw-r--r--lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp19
3 files changed, 56 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile b/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile
new file mode 100644
index 00000000000..8a7102e347a
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py b/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py
new file mode 100644
index 00000000000..5cf05db1f8b
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py
@@ -0,0 +1,32 @@
+"""
+This is a test to ensure that both lldb is reconstructing the right
+calling convention for a CXXRecordDecl as represented by:
+
+ DW_CC_pass_by_reference
+ DW_CC_pass_by_value
+
+and to also make sure that the ASTImporter is copying over this
+setting when importing the CXXRecordDecl via setArgPassingRestrictions.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestArgumentPassingRestrictions(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_argument_passing_restrictions(self):
+ self.build()
+
+ lldbutil.run_to_source_breakpoint(self, '// break here',
+ lldb.SBFileSpec("main.cpp"))
+
+ self.expect("expr returnPassByRef()",
+ substrs=['(PassByRef)', '= 11223344'])
+
+ self.expect("expr takePassByRef(p)",
+ substrs=['(int)', '= 42'])
diff --git a/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp b/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp
new file mode 100644
index 00000000000..4b3b6950455
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp
@@ -0,0 +1,19 @@
+// This structure has a non-trivial copy constructor so
+// it needs to be passed by reference.
+struct PassByRef {
+ PassByRef() = default;
+ PassByRef(const PassByRef &p){x = p.x;};
+
+ int x = 11223344;
+};
+
+PassByRef returnPassByRef() { return PassByRef(); }
+int takePassByRef(PassByRef p) {
+ return p.x;
+}
+
+int main() {
+ PassByRef p = returnPassByRef();
+ p.x = 42;
+ return takePassByRef(p); // break here
+}
OpenPOWER on IntegriCloud