Skip to content

Commit 62c8011

Browse files
committed
Add a test
1 parent b2f5a17 commit 62c8011

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-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: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Test LLDB type promotion of unscoped enums.
3+
"""
4+
5+
import lldb
6+
from lldbsuite.test.decorators import *
7+
from lldbsuite.test.lldbtest import *
8+
from lldbsuite.test import lldbutil
9+
10+
class TestCPPEnumPromotion(TestBase):
11+
12+
@skipIf(debug_info=no_match(["dwarf", "dwo"]))
13+
def test(self):
14+
self.build()
15+
lldbutil.run_to_source_breakpoint(
16+
self, "// break here", lldb.SBFileSpec("main.cpp")
17+
)
18+
UChar_promoted = self.frame().FindVariable("UChar_promoted")
19+
UShort_promoted = self.frame().FindVariable("UShort_promoted")
20+
UInt_promoted = self.frame().FindVariable("UInt_promoted")
21+
SLong_promoted = self.frame().FindVariable("SLong_promoted")
22+
ULong_promoted = self.frame().FindVariable("ULong_promoted")
23+
NChar_promoted = self.frame().FindVariable("NChar_promoted")
24+
NShort_promoted = self.frame().FindVariable("NShort_promoted")
25+
NInt_promoted = self.frame().FindVariable("NInt_promoted")
26+
NLong_promoted = self.frame().FindVariable("NLong_promoted")
27+
28+
# Check that LLDB's promoted type is the same as the compiler's
29+
self.expect_expr("+EnumUChar::UChar", result_type=UChar_promoted.type.name)
30+
self.expect_expr("+EnumUShort::UShort", result_type=UShort_promoted.type.name)
31+
self.expect_expr("+EnumUInt::UInt", result_type=UInt_promoted.type.name)
32+
self.expect_expr("+EnumSLong::SLong", result_type=SLong_promoted.type.name)
33+
self.expect_expr("+EnumULong::ULong", result_type=ULong_promoted.type.name)
34+
self.expect_expr("+EnumNChar::NChar", result_type=NChar_promoted.type.name)
35+
self.expect_expr("+EnumNShort::NShort", result_type=NShort_promoted.type.name)
36+
self.expect_expr("+EnumNInt::NInt", result_type=NInt_promoted.type.name)
37+
self.expect_expr("+EnumNLong::NLong", result_type=NLong_promoted.type.name)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
enum EnumUChar { UChar = 1 };
2+
enum EnumUShort { UShort = 0x101 };
3+
enum EnumUInt { UInt = 0x10001 };
4+
enum EnumSLong { SLong = 0x100000001 };
5+
enum EnumULong { ULong = 0xFFFFFFFFFFFFFFF0 };
6+
enum EnumNChar { NChar = -1 };
7+
enum EnumNShort { NShort= -0x101 };
8+
enum EnumNInt { NInt = -0x10001 };
9+
enum EnumNLong { NLong = -0x100000001 };
10+
11+
int main() {
12+
auto UChar_promoted = +EnumUChar::UChar;
13+
auto UShort_promoted = +EnumUShort::UShort;
14+
auto UInt_promoted = +EnumUInt::UInt;
15+
auto SLong_promoted = +EnumSLong::SLong;
16+
auto ULong_promoted = +EnumULong::ULong;
17+
auto NChar_promoted = +EnumNChar::NChar;
18+
auto NShort_promoted = +EnumNShort::NShort;
19+
auto NInt_promoted = +EnumNInt::NInt;
20+
auto NLong_promoted = +EnumNLong::NLong;
21+
return 0; // break here
22+
}

0 commit comments

Comments
 (0)