[Lldb-commits] [lldb] r124619 - in /lldb/trunk/test/cpp: ./ virtual/ virtual/main.cpp
Greg Clayton
gclayton at apple.com
Mon Jan 31 15:14:36 PST 2011
Author: gclayton
Date: Mon Jan 31 17:14:35 2011
New Revision: 124619
URL: http://llvm.org/viewvc/llvm-project?rev=124619&view=rev
Log:
Added a virtual C++ test case that catches some interesting cases
that you run into with inheritance.
Added:
lldb/trunk/test/cpp/
lldb/trunk/test/cpp/virtual/
lldb/trunk/test/cpp/virtual/main.cpp
Added: lldb/trunk/test/cpp/virtual/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/cpp/virtual/main.cpp?rev=124619&view=auto
==============================================================================
--- lldb/trunk/test/cpp/virtual/main.cpp (added)
+++ lldb/trunk/test/cpp/virtual/main.cpp Mon Jan 31 17:14:35 2011
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdint.h>
+
+class A
+{
+public:
+ A () : m_pad ('c') {}
+
+ virtual ~A () {}
+
+ virtual const char * a()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+
+ virtual const char * b()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+
+ virtual const char * c()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+protected:
+ char m_pad;
+};
+
+class AA
+{
+public:
+ AA () : m_pad('A') {}
+ virtual ~AA () {}
+
+ virtual const char * aa()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+
+protected:
+ char m_pad;
+};
+
+class B : virtual public A, public AA
+{
+public:
+ B () : m_pad ('c') {}
+
+ virtual ~B () {}
+
+ virtual const char * a()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+
+ virtual const char * b()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+protected:
+ char m_pad;
+};
+
+class C : public B, virtual public A
+{
+public:
+ C () : m_pad ('c') {}
+
+ virtual ~C () {}
+
+ virtual const char * a()
+ {
+ return __PRETTY_FUNCTION__;
+ }
+protected:
+ char m_pad;
+};
+
+int main (int argc, char const *argv[], char const *envp[])
+{
+ A *a_as_A = new A();
+ B *b_as_B = new B();
+ A *b_as_A = b_as_B;
+ C *c_as_C = new C();
+ A *c_as_A = c_as_C;
+
+ printf ("a_as_A->a() = '%s'\n", a_as_A->a());
+ printf ("a_as_A->b() = '%s'\n", a_as_A->b());
+ printf ("a_as_A->c() = '%s'\n", a_as_A->c());
+ printf ("b_as_A->a() = '%s'\n", b_as_A->a());
+ printf ("b_as_A->b() = '%s'\n", b_as_A->b());
+ printf ("b_as_A->c() = '%s'\n", b_as_A->c());
+ printf ("b_as_B->aa() = '%s'\n", b_as_B->aa());
+ printf ("c_as_A->a() = '%s'\n", c_as_A->a());
+ printf ("c_as_A->b() = '%s'\n", c_as_A->b());
+ printf ("c_as_A->c() = '%s'\n", c_as_A->c());
+ printf ("c_as_C->aa() = '%s'\n", c_as_C->aa());
+ return 0; // Set first breakpoint here.
+ // then evaluate:
+ // expression a_as_A->a()
+ // expression a_as_A->b()
+ // expression a_as_A->c()
+ // expression b_as_A->a()
+ // expression b_as_A->b()
+ // expression b_as_A->c()
+ // expression b_as_B->aa()
+ // expression c_as_A->a()
+ // expression c_as_A->b()
+ // expression c_as_A->c()
+ // expression c_as_C->aa()
+}
More information about the lldb-commits
mailing list