summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof
diff options
context:
space:
mode:
authorRaphael Isemann <teemperor@gmail.com>2019-07-18 17:58:04 +0000
committerRaphael Isemann <teemperor@gmail.com>2019-07-18 17:58:04 +0000
commite21fc8770ca4900c131f51a749dac480006d6591 (patch)
tree6bf54a7c1e78378dd70bcf75edbfa566e2c0fa04 /lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof
parent801fa8e6b9eb2398a051752bb0e9d81279360d14 (diff)
downloadbcm5719-llvm-e21fc8770ca4900c131f51a749dac480006d6591.tar.gz
bcm5719-llvm-e21fc8770ca4900c131f51a749dac480006d6591.zip
Add offsetof support to expression evaluator.
Summary: We currently don't support offsetof in the expression evaluator as it is implemented as a macro (which then calls __builtin_offsetof) in stddef.h. The best solution would be to include that header (or even better, import Clang's builtin module), but header-parsing and (cross-platform) importing modules is not ready yet. Until we get this working with modules I would say we add the macro to our existing macro list as we already do with other macros from stddef.h/stdint.h. We should be able to drop all of them once we can import the relevant modules by default. rdar://26040641 Reviewers: shafik, davide Reviewed By: davide Subscribers: clayborg, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D64917 llvm-svn: 366476
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/Makefile3
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/TestOffsetofCpp.py3
-rw-r--r--lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/main.cpp25
3 files changed, 31 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/Makefile b/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/Makefile
new file mode 100644
index 00000000000..99bfa7e03b4
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/Makefile
@@ -0,0 +1,3 @@
+LEVEL = ../../../make
+CXX_SOURCES := main.cpp
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/TestOffsetofCpp.py b/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/TestOffsetofCpp.py
new file mode 100644
index 00000000000..1311a149326
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/TestOffsetofCpp.py
@@ -0,0 +1,3 @@
+from lldbsuite.test import lldbinline
+
+lldbinline.MakeInlineTest(__file__, globals())
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/main.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/main.cpp
new file mode 100644
index 00000000000..ab379f839c8
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/offsetof/main.cpp
@@ -0,0 +1,25 @@
+#include <cstdint>
+
+class Base {
+ int32_t a;
+};
+class Class1 : Base {
+public:
+ int32_t b;
+};
+
+class EmptyBase {
+};
+class Class2 : EmptyBase {
+public:
+ int32_t b;
+};
+
+int main(int argc, char **argv) {
+ Class1 c1;
+ Class2 c2;
+ //% self.expect("expr offsetof(Base, a)", substrs=["= 0"])
+ //% self.expect("expr offsetof(Class1, b)", substrs=["= 4"])
+ //% self.expect("expr offsetof(Class2, b)", substrs=["= 0"])
+ return c1.b + c2.b;
+}
OpenPOWER on IntegriCloud