Skip to content

Commit f53f6f7

Browse files
authored
[lldb][test] Add basic API tests for DW_TAG_template_alias (#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`).
1 parent 0bb0e26 commit f53f6f7

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CXX_SOURCES := main.cpp
2+
3+
include Makefile.rules
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import lldb
2+
import lldbsuite.test.lldbutil as lldbutil
3+
from lldbsuite.test.decorators import *
4+
from lldbsuite.test.lldbtest import *
5+
6+
7+
class TestTemplateAlias(TestBase):
8+
def do_test(self, extra_flags):
9+
self.build(dictionary=extra_flags)
10+
self.main_source_file = lldb.SBFileSpec("main.cpp")
11+
lldbutil.run_to_source_breakpoint(self, "return", lldb.SBFileSpec("main.cpp"))
12+
13+
self.expect_expr("f1", result_type="Foo<int>")
14+
self.expect_expr("f2", result_type="Foo<double>")
15+
self.expect_expr("b1", result_type="Bar<int>")
16+
self.expect_expr("b2", result_type="Bar<double>")
17+
self.expect_expr("bf1", result_type="Bar<int>")
18+
self.expect_expr("bf2", result_type="Bar<double>")
19+
self.expect_expr("bf1", result_type="Bar<int>")
20+
self.expect_expr("bf2", result_type="Bar<double>")
21+
self.expect_expr("cbf1", result_type="Container<int>")
22+
23+
@expectedFailureAll(
24+
bugnumber="LLDB doesn't reconstruct template alias names from template parameters"
25+
)
26+
def test_tag_alias_simple(self):
27+
self.do_test(
28+
dict(CXXFLAGS_EXTRAS="-gdwarf-5 -gtemplate-alias -gsimple-template-names")
29+
)
30+
31+
def test_tag_alias_no_simple(self):
32+
self.do_test(
33+
dict(
34+
CXXFLAGS_EXTRAS="-gdwarf-5 -gtemplate-alias -gno-simple-template-names"
35+
)
36+
)
37+
38+
def test_no_tag_alias_simple(self):
39+
self.do_test(
40+
dict(
41+
CXXFLAGS_EXTRAS="-gdwarf-5 -gno-template-alias -gsimple-template-names"
42+
)
43+
)
44+
45+
def test_no_tag_alias_no_simple(self):
46+
self.do_test(
47+
dict(
48+
CXXFLAGS_EXTRAS="-gdwarf-5 -gno-template-alias -gno-simple-template-names"
49+
)
50+
)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
template <typename T> using Foo = T;
2+
3+
template <typename T> using Bar = Foo<T>;
4+
5+
template <typename T> struct Container {};
6+
7+
int main() {
8+
Foo<int> f1;
9+
Foo<double> f2;
10+
Bar<int> b1;
11+
Bar<double> b2;
12+
Bar<Foo<int>> bf1;
13+
Bar<Foo<double>> bf2;
14+
Container<Bar<Foo<int>>> cbf1;
15+
return 0;
16+
}

0 commit comments

Comments
 (0)