https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/170804
Basic API tests to check how template aliases are rendered by LLDB (using both `DW_TAG_template_alias` and `DW_TAG_typedef`, with and without `-gsimple-template-names`). >From f2820166e6419f7aef8efba29398738f343dbca9 Mon Sep 17 00:00:00 2001 From: Michael Buch <[email protected]> Date: Fri, 5 Dec 2025 14:38:46 +0800 Subject: [PATCH] [lldb][test] Add basic API tests for DW_TAG_template_alias --- .../test/API/lang/cpp/template-alias/Makefile | 3 ++ .../cpp/template-alias/TestTemplateAlias.py | 50 +++++++++++++++++++ .../test/API/lang/cpp/template-alias/main.cpp | 19 +++++++ 3 files changed, 72 insertions(+) create mode 100644 lldb/test/API/lang/cpp/template-alias/Makefile create mode 100644 lldb/test/API/lang/cpp/template-alias/TestTemplateAlias.py create mode 100644 lldb/test/API/lang/cpp/template-alias/main.cpp diff --git a/lldb/test/API/lang/cpp/template-alias/Makefile b/lldb/test/API/lang/cpp/template-alias/Makefile new file mode 100644 index 0000000000000..99998b20bcb05 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-alias/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/template-alias/TestTemplateAlias.py b/lldb/test/API/lang/cpp/template-alias/TestTemplateAlias.py new file mode 100644 index 0000000000000..b8314eb7cff08 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-alias/TestTemplateAlias.py @@ -0,0 +1,50 @@ +import lldb +import lldbsuite.test.lldbutil as lldbutil +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * + + +class TestTemplateAlias(TestBase): + def do_test(self, extra_flags): + self.build(dictionary=extra_flags) + self.main_source_file = lldb.SBFileSpec("main.cpp") + lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp")) + + self.expect_expr("f1", result_type="Foo<int>") + self.expect_expr("f2", result_type="Foo<double>") + self.expect_expr("b1", result_type="Bar<int>") + self.expect_expr("b2", result_type="Bar<double>") + self.expect_expr("bf1", result_type="Bar<int>") + self.expect_expr("bf2", result_type="Bar<double>") + self.expect_expr("bf1", result_type="Bar<int>") + self.expect_expr("bf2", result_type="Bar<double>") + self.expect_expr("cbf1", result_type="Container<int>") + + @expectedFailureAll( + bugnumber="LLDB doesn't reconstruct template alias names from template parameters" + ) + def test_tag_alias_simple(self): + self.do_test( + dict(CXXFLAGS_EXTRAS="-gdwarf-5 -gtemplate-alias -gsimple-template-names") + ) + + def test_tag_alias_no_simple(self): + self.do_test( + dict( + CXXFLAGS_EXTRAS="-gdwarf-5 -gtemplate-alias -gno-simple-template-names" + ) + ) + + def test_no_tag_alias_simple(self): + self.do_test( + dict( + CXXFLAGS_EXTRAS="-gdwarf-5 -gno-template-alias -gsimple-template-names" + ) + ) + + def test_no_tag_alias_no_simple(self): + self.do_test( + dict( + CXXFLAGS_EXTRAS="-gdwarf-5 -gno-template-alias -gno-simple-template-names" + ) + ) diff --git a/lldb/test/API/lang/cpp/template-alias/main.cpp b/lldb/test/API/lang/cpp/template-alias/main.cpp new file mode 100644 index 0000000000000..2a2fefe085d7a --- /dev/null +++ b/lldb/test/API/lang/cpp/template-alias/main.cpp @@ -0,0 +1,19 @@ +template<typename T> +using Foo = T; + +template<typename T> +using Bar = Foo<T>; + +template<typename T> +struct Container {}; + +int main() { + Foo<int> f1; + Foo<double> f2; + Bar<int> b1; + Bar<double> b2; + Bar<Foo<int>> bf1; + Bar<Foo<double>> bf2; + Container<Bar<Foo<int>>> cbf1; + return 0; +} _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
