aboutsummaryrefslogtreecommitdiff
path: root/packages/Python/lldbsuite/test/lang/cpp/global_operators/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/cpp/global_operators/main.cpp')
-rw-r--r--packages/Python/lldbsuite/test/lang/cpp/global_operators/main.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/global_operators/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/global_operators/main.cpp
index a0dd0787fa32..c6dafd295865 100644
--- a/packages/Python/lldbsuite/test/lang/cpp/global_operators/main.cpp
+++ b/packages/Python/lldbsuite/test/lang/cpp/global_operators/main.cpp
@@ -1,3 +1,10 @@
+#include <new>
+
+struct new_tag_t
+{
+};
+new_tag_t new_tag;
+
struct Struct {
int value;
};
@@ -6,6 +13,25 @@ bool operator==(const Struct &a, const Struct &b) {
return a.value == b.value;
}
+typedef char buf_t[sizeof(Struct)];
+buf_t global_new_buf, tagged_new_buf;
+
+// This overrides global operator new
+// This function and the following does not actually allocate memory. We are merely
+// trying to make sure it is getting called.
+void *
+operator new(std::size_t count)
+{
+ return &global_new_buf;
+}
+
+// A custom allocator
+void *
+operator new(std::size_t count, const new_tag_t &)
+{
+ return &tagged_new_buf;
+}
+
int main() {
Struct s1, s2, s3;
s1.value = 3;