diff options
author | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2015-10-28 17:43:26 +0000 |
commit | c432c8f856e0bd84de980a9d9bb2d31b06fa95b1 (patch) | |
tree | 4efa528e074a6e2df782345e4cd97f5d85d038c4 /lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp | |
parent | a8a3bd210086b50242903ed95048fe5e53897878 (diff) | |
download | bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.tar.gz bcm5719-llvm-c432c8f856e0bd84de980a9d9bb2d31b06fa95b1.zip |
Move lldb/test to lldb/packages/Python/lldbsuite/test.
This is the conclusion of an effort to get LLDB's Python code
structured into a bona-fide Python package. This has a number
of benefits, but most notably the ability to more easily share
Python code between different but related pieces of LLDB's Python
infrastructure (for example, `scripts` can now share code with
`test`).
llvm-svn: 251532
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp')
-rw-r--r-- | lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp b/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp new file mode 100644 index 00000000000..00fd7dad438 --- /dev/null +++ b/lldb/packages/Python/lldbsuite/test/lang/cpp/dynamic-value/sbvalue-cast.cpp @@ -0,0 +1,80 @@ +//===-- sbvalue-cast.cpp ----------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +#ifdef DO_VIRTUAL_INHERITANCE +#define VIRTUAL virtual +#else +#define VIRTUAL +#endif + +#include <stdio.h> + +class Base +{ +public: + Base(int val) : m_base_val (val) {} + virtual ~Base() {} + + virtual void + forcast(int input) { + int future_val = m_base_val + input * 1; + printf("Forcasting %d\n", future_val); + } + +protected: + int m_base_val; +}; + +class DerivedA : public VIRTUAL Base +{ +public: + DerivedA(int val) : Base(val*2), m_a_val(val) { + printf("DerivedA::ctor()->\n"); + printf("m_base_val=%d\n", m_base_val); + printf("m_a_val=%d\n", m_a_val); + } + virtual ~DerivedA() {} + +private: + int m_a_val; +}; + +class DerivedB : public VIRTUAL Base +{ +public: + DerivedB(int val) : Base(val), m_b_val(val*3) { + printf("DerivedB::ctor()->\n"); + printf("m_base_val=%d\n", m_base_val); + printf("m_b_val=%d\n", m_b_val); + } + virtual ~DerivedB() {} + + virtual void + forcast(int input) { + int future_val = m_b_val + input * 2; + printf("Forcasting %d\n", future_val); + } + +private: + int m_b_val; +}; + +int +main(int argc, char **argv) +{ + DerivedA* dA = new DerivedA(10); + DerivedB* dB = new DerivedB(12); + Base *array[2] = {dA, dB}; + Base *teller = NULL; + for (int i = 0; i < 2; ++i) { + teller = array[i]; + teller->forcast(i); // Set breakpoint here. + } + + return 0; +} |