summaryrefslogtreecommitdiff
path: root/lldb/test/API/lang/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test/API/lang/cpp')
-rw-r--r--lldb/test/API/lang/cpp/namespace/TestNamespace.py2
-rw-r--r--lldb/test/API/lang/cpp/typedef-to-outer-fwd/Makefile3
-rw-r--r--lldb/test/API/lang/cpp/typedef-to-outer-fwd/TestTypedefToOuterFwd.py38
-rw-r--r--lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.cpp10
-rw-r--r--lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.h7
-rw-r--r--lldb/test/API/lang/cpp/typedef-to-outer-fwd/main.cpp12
6 files changed, 71 insertions, 1 deletions
diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespace.py b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
index 8b013d928f9c..40cbff9cb3c9 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespace.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespace.py
@@ -161,7 +161,7 @@ class NamespaceTestCase(TestBase):
# On Mac OS X, gcc 4.2 emits the wrong debug info with respect to
# types.
slist = ["(int) a = 12", "anon_uint", "a_uint", "b_uint", "y_uint"]
- if self.platformIsDarwin() and self.getCompiler() in ["clang", "llvm-gcc"]:
+ if self.platformIsDarwin() and self.getCompiler() in ["clang"]:
slist = [
"(int) a = 12",
"::my_uint_t",
diff --git a/lldb/test/API/lang/cpp/typedef-to-outer-fwd/Makefile b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/Makefile
new file mode 100644
index 000000000000..d9db5666f9b6
--- /dev/null
+++ b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := lib.cpp main.cpp
+
+include Makefile.rules
diff --git a/lldb/test/API/lang/cpp/typedef-to-outer-fwd/TestTypedefToOuterFwd.py b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/TestTypedefToOuterFwd.py
new file mode 100644
index 000000000000..7e9f6967a128
--- /dev/null
+++ b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/TestTypedefToOuterFwd.py
@@ -0,0 +1,38 @@
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestCaseTypedefToOuterFwd(TestBase):
+ """
+ We find a global variable whose type is forward declared
+ (whose definition is in either main.o or lib.o). We then
+ try to get the 'Ref' typedef nested within that forward
+ declared type. This test makes sure we correctly resolve
+ this typedef.
+
+ We test this for two cases, where the definition lives
+ in main.o or lib.o.
+ """
+
+ def check_global_var(self, target, name: str):
+ var = target.FindFirstGlobalVariable(name)
+ self.assertSuccess(var.GetError(), f"Found {name}")
+
+ var_type = var.GetType()
+ self.assertTrue(var_type)
+
+ impl = var_type.GetPointeeType()
+ self.assertTrue(impl)
+
+ ref = impl.FindDirectNestedType("Ref")
+ self.assertTrue(ref)
+
+ self.assertEqual(ref.GetCanonicalType(), var_type)
+
+ def test(self):
+ self.build()
+ target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
+ self.check_global_var(target, "gLibExternalDef")
+ self.check_global_var(target, "gMainExternalDef")
diff --git a/lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.cpp b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.cpp
new file mode 100644
index 000000000000..b50a13afe1ac
--- /dev/null
+++ b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.cpp
@@ -0,0 +1,10 @@
+#include "lib.h"
+
+template <typename T> struct FooImpl {
+ using Ref = FooImpl<T> *;
+
+ Ref Create() { return new FooImpl<T>(); }
+};
+
+FooImpl<char> gLibLocalDef;
+BarImpl<char> *gLibExternalDef = nullptr;
diff --git a/lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.h b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.h
new file mode 100644
index 000000000000..d909fe58df12
--- /dev/null
+++ b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/lib.h
@@ -0,0 +1,7 @@
+#ifndef LIB_H_IN
+#define LIB_H_IN
+
+template <typename T> struct FooImpl;
+template <typename T> struct BarImpl;
+
+#endif // LIB_H_IN
diff --git a/lldb/test/API/lang/cpp/typedef-to-outer-fwd/main.cpp b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/main.cpp
new file mode 100644
index 000000000000..acf8337a69d0
--- /dev/null
+++ b/lldb/test/API/lang/cpp/typedef-to-outer-fwd/main.cpp
@@ -0,0 +1,12 @@
+#include "lib.h"
+
+template <typename T> struct BarImpl {
+ using Ref = BarImpl<T> *;
+
+ Ref Create() { return new BarImpl<T>(); }
+};
+
+BarImpl<char> gMainLocalDef;
+FooImpl<char> *gMainExternalDef = nullptr;
+
+int main() { return 0; }