Skip to content

Commit 1646670

Browse files
committed
Address review comments in cast test & fix clang-format issues.
1 parent 667b8ea commit 1646670

File tree

5 files changed

+113
-106
lines changed

5 files changed

+113
-106
lines changed

lldb/include/lldb/ValueObject/DILEval.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ class Interpreter : Visitor {
6363
llvm::Expected<lldb::ValueObjectSP>
6464
Visit(const CStyleCastNode *node) override;
6565

66-
67-
6866
llvm::Expected<CompilerType>
6967
PickIntegerType(lldb::TypeSystemSP type_system,
7068
std::shared_ptr<ExecutionContextScope> ctx,

lldb/source/ValueObject/DILParser.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ std::string DILParser::ParseUnqualifiedId() {
697697
return identifier;
698698
}
699699

700-
701700
CompilerType
702701
DILParser::ResolveTypeDeclarators(CompilerType type,
703702
const std::vector<Token> &ptr_operators) {
@@ -1026,7 +1025,6 @@ void DILParser::ExpectOneOf(std::vector<Token::Kind> kinds_vec) {
10261025
}
10271026
}
10281027

1029-
10301028
lldb::BasicType TypeDeclaration::GetBasicType() const {
10311029
if (!m_is_builtin)
10321030
return lldb::eBasicTypeInvalid;

lldb/test/API/commands/frame/var-dil/basics/LocalVars/TestFrameVarDILLocalVars.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import time
1313

1414

15+
1516
class TestFrameVarDILLocalVars(TestBase):
1617
# If your test case doesn't stress debug info, then
1718
# set this to true. That way it won't be run once for

lldb/test/API/commands/frame/var-dil/expr/CStyleCast/TestFrameVarDILCStyleCast.py

Lines changed: 112 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@
1212
import time
1313

1414
class TestFrameVarDILCStyleCast(TestBase):
15-
NO_DEBUG_INFO_TESTCASE = True
16-
17-
def expect_var_path(self, expr, compare_to_framevar=False, value=None, type=None):
18-
value_dil = super().expect_var_path(expr, value=value, type=type)
19-
if compare_to_framevar:
20-
self.runCmd("settings set target.experimental.use-DIL false")
21-
value_frv = super().expect_var_path(expr, value=value, type=type)
22-
self.runCmd("settings set target.experimental.use-DIL true")
23-
self.assertEqual(value_dil.GetValue(), value_frv.GetValue())
2415

2516
def test_type_cast(self):
2617
self.build()
@@ -36,35 +27,51 @@ def test_type_cast(self):
3627
self.expect_var_path("(long long)1", value="1", type="long long")
3728
self.expect_var_path("(unsigned long)1", value="1", type="unsigned long")
3829
self.expect_var_path("(char*)1", value="0x0000000000000001", type="char *")
39-
self.expect_var_path("(long long**)1", value="0x0000000000000001", type="long long **")
30+
self.expect_var_path(
31+
"(long long**)1", value="0x0000000000000001", type="long long **"
32+
)
4033

41-
self.expect("frame variable '(long&*)1'", error=True,
42-
substrs=["'type name' declared as a pointer to a reference"
43-
" of type 'long &'"])
34+
self.expect(
35+
"frame variable '(long&*)1'",
36+
error=True,
37+
substrs=[
38+
"'type name' declared as a pointer to a reference of type 'long &'"
39+
],
40+
)
4441

45-
self.expect("frame variable '(long& &)1'", error=True,
46-
substrs=["type name declared as a reference to a reference"])
42+
self.expect(
43+
"frame variable '(long& &)1'",
44+
error=True,
45+
substrs=["type name declared as a reference to a reference"],
46+
)
4747

48-
self.expect("frame variable '(long 1)1'", error=True,
49-
substrs=["expected 'r_paren', got: <'1' "
50-
"(integer_constant)>"])
48+
self.expect(
49+
"frame variable '(long 1)1'",
50+
error=True,
51+
substrs=["expected 'r_paren', got: <'1' (integer_constant)>"],
52+
)
5153

5254
# TestCStyleCastBasicType
5355

5456
# Test with integer literals.
5557
self.expect_var_path("(char)1", type="char", value="'\\x01'")
5658
self.expect_var_path("(long long)1", type="long long", value="1")
5759
self.expect_var_path("(short)65534", type="short", value="-2")
58-
self.expect_var_path("(unsigned short)100000",
59-
type="unsigned short", value="34464")
60+
self.expect_var_path(
61+
"(unsigned short)100000", type="unsigned short", value="34464"
62+
)
63+
self.expect_var_path("(int)false", type="int", value="0")
64+
self.expect_var_path("(int)true", type="int", value="1")
6065
self.expect_var_path("(float)1", type="float", value="1")
6166
self.expect_var_path("(float)1.1", type="float", value="1.10000002")
6267
self.expect_var_path("(float)1.1f", type="float", value="1.10000002")
68+
self.expect_var_path("(float)false", type="float", value="0")
69+
self.expect_var_path("(float)true", type="float", value="1")
6370
self.expect_var_path("(double)1", type="double", value="1")
64-
self.expect_var_path("(double)1.1",
65-
type="double", value="1.1000000000000001")
66-
self.expect_var_path("(double)1.1f",
67-
type="double", value="1.1000000238418579")
71+
self.expect_var_path("(double)1.1", type="double", value="1.1000000000000001")
72+
self.expect_var_path("(double)1.1f", type="double", value="1.1000000238418579")
73+
self.expect_var_path("(double)false", type="double", value="0")
74+
self.expect_var_path("(double)true", type="double", value="1")
6875
self.expect_var_path("(int)1.1", type="int", value="1")
6976
self.expect_var_path("(int)1.1f", type="int", value="1")
7077
self.expect_var_path("(long)1.1", type="long", value="1")
@@ -73,8 +80,11 @@ def test_type_cast(self):
7380
self.expect_var_path("(bool)0.0f", type="bool", value="false")
7481
self.expect_var_path("(bool)3", type="bool", value="true")
7582

76-
self.expect("frame variable '&(int)1'", error=True,
77-
substrs=["'result' doesn't have a valid address"])
83+
self.expect(
84+
"frame variable '&(int)1'",
85+
error=True,
86+
substrs=["'result' doesn't have a valid address"],
87+
)
7888

7989
# Test with variables.
8090
self.expect_var_path("(char)a", type="char", value="'\\x01'")
@@ -83,18 +93,21 @@ def test_type_cast(self):
8393
self.expect_var_path("(long long)a", type="long long", value="1")
8494
self.expect_var_path("(float)a", type="float", value="1")
8595
self.expect_var_path("(float)f", type="float", value="1.10000002")
86-
self.expect_var_path("(double)f",
87-
type="double", value="1.1000000238418579")
96+
self.expect_var_path("(double)f", type="double", value="1.1000000238418579")
8897
self.expect_var_path("(int)f", type="int", value="1")
8998
self.expect_var_path("(long)f", type="long", value="1")
9099
self.expect_var_path("(bool)finf", type="bool", value="true")
91100
self.expect_var_path("(bool)fnan", type="bool", value="true")
92101
self.expect_var_path("(bool)fsnan", type="bool", value="true")
93102
self.expect_var_path("(bool)fmax", type="bool", value="true")
94103
self.expect_var_path("(bool)fdenorm", type="bool", value="true")
95-
self.expect("frame variable '(int)ns_foo_'", error=True,
96-
substrs=["cannot convert 'ns::Foo' to 'int' without a "
97-
"conversion operator"])
104+
self.expect(
105+
"frame variable '(int)ns_foo_'",
106+
error=True,
107+
substrs=[
108+
"cannot convert 'ns::Foo' to 'int' without a conversion operator"
109+
],
110+
)
98111

99112
# Test with typedefs and namespaces.
100113
self.expect_var_path("(myint)1", type="myint", value="1")
@@ -109,46 +122,59 @@ def test_type_cast(self):
109122
self.expect_var_path("(long long)ns_myint_", type="long long", value="2")
110123
self.expect_var_path("(::ns::myint)myint_", type="ns::myint", value="1")
111124

112-
self.expect_var_path("(ns::inner::mydouble)1", type="ns::inner::mydouble", value="1")
113-
self.expect_var_path("(::ns::inner::mydouble)1.2",
114-
type="ns::inner::mydouble", value="1.2")
115-
self.expect_var_path("(ns::inner::mydouble)myint_",
116-
type="ns::inner::mydouble", value="1")
117-
self.expect_var_path("(::ns::inner::mydouble)ns_inner_mydouble_",
118-
type="ns::inner::mydouble", value="1.2")
119-
self.expect_var_path("(myint)ns_inner_mydouble_",
120-
type="myint", value="1")
125+
self.expect_var_path(
126+
"(ns::inner::mydouble)1", type="ns::inner::mydouble", value="1"
127+
)
128+
self.expect_var_path(
129+
"(::ns::inner::mydouble)1.2", type="ns::inner::mydouble", value="1.2"
130+
)
131+
self.expect_var_path(
132+
"(ns::inner::mydouble)myint_", type="ns::inner::mydouble", value="1"
133+
)
134+
self.expect_var_path(
135+
"(::ns::inner::mydouble)ns_inner_mydouble_",
136+
type="ns::inner::mydouble",
137+
value="1.2",
138+
)
139+
self.expect_var_path("(myint)ns_inner_mydouble_", type="myint", value="1")
121140

122141
# Test with pointers and arrays.
123142
self.expect_var_path("(long long)ap", type="long long")
124143
self.expect_var_path("(unsigned long long)vp", type="unsigned long long")
125144
self.expect_var_path("(long long)arr", type="long long")
126145
self.expect_var_path("(bool)ap", type="bool", value="true")
127-
self.expect_var_path("(bool)(int*)0x00000000",
128-
type="bool", value="false")
146+
self.expect_var_path("(bool)(int*)0x00000000", type="bool", value="false")
129147
self.expect_var_path("(bool)arr", type="bool", value="true")
130-
self.expect("frame variable '(char)ap'", error=True,
131-
substrs=["cast from pointer to smaller type 'char' loses "
132-
"information"])
148+
self.expect(
149+
"frame variable '(char)ap'",
150+
error=True,
151+
substrs=["cast from pointer to smaller type 'char' loses information"],
152+
)
133153
Is32Bit = False
134154
if self.target().GetAddressByteSize() == 4:
135-
Is32Bit = True;
155+
Is32Bit = True;
136156

137157
if Is32Bit:
138-
self.expect("frame variable '(int)arr'", error=True,
139-
substrs=["cast from pointer to smaller type 'int' loses"
140-
" information"])
158+
self.expect("frame variable '(int)arr'", type="int")
141159
else:
142-
self.expect("frame variable '(int)arr'", error=True,
143-
substrs=["cast from pointer to smaller type 'int' loses"
144-
" information"])
145-
146-
self.expect("frame variable '(float)ap'", error=True,
147-
substrs=["C-style cast from 'int *' to 'float' is not "
148-
"allowed"])
149-
self.expect("frame variable '(float)arr'", error=True,
150-
substrs=["C-style cast from 'int *' to 'float' is not "
151-
"allowed"])
160+
self.expect(
161+
"frame variable '(int)arr'",
162+
error=True,
163+
substrs=[
164+
"cast from pointer to smaller type 'int' loses information"
165+
],
166+
)
167+
168+
self.expect(
169+
"frame variable '(float)ap'",
170+
error=True,
171+
substrs=["C-style cast from 'int *' to 'float' is not allowed"],
172+
)
173+
self.expect(
174+
"frame variable '(float)arr'",
175+
error=True,
176+
substrs=["C-style cast from 'int *' to 'float' is not allowed"],
177+
)
152178

153179
# TestCStyleCastPointer
154180
self.expect_var_path("(void*)&a", type="void *")
@@ -160,57 +186,50 @@ def test_type_cast(self):
160186

161187

162188
if Is32Bit:
163-
self.expect_var_path("(void*)0",
164-
type="void *", value="0x00000000")
165-
self.expect_var_path("(void*)1",
166-
type="void *", value="0x00000001")
167-
self.expect_var_path("(void*)a",
168-
type="void *", value="0x00000001")
169-
self.expect_var_path("(void*)na",
170-
type="void *", value="0xffffffff")
189+
self.expect_var_path("(void*)0", type="void *", value="0x00000000")
190+
self.expect_var_path("(void*)1", type="void *", value="0x00000001")
191+
self.expect_var_path("(void*)a", type="void *", value="0x00000001")
192+
self.expect_var_path("(void*)na", type="void *", value="0xffffffff")
171193
else:
172-
self.expect_var_path("(void*)0",
173-
type="void *", value="0x0000000000000000")
174-
self.expect_var_path("(void*)1",
175-
type="void *", value="0x0000000000000001")
176-
self.expect_var_path("(void*)a",
177-
type="void *", value="0x0000000000000001")
178-
self.expect_var_path("(void*)na",
179-
type="void *", value="0xffffffffffffffff")
194+
self.expect_var_path("(void*)0", type="void *", value="0x0000000000000000")
195+
self.expect_var_path("(void*)1", type="void *", value="0x0000000000000001")
196+
self.expect_var_path("(void*)a", type="void *", value="0x0000000000000001")
197+
self.expect_var_path("(void*)na", type="void *", value="0xffffffffffffffff")
180198

181199
self.expect_var_path("(int*&)ap", type="int *")
182200

183-
self.expect("frame variable '(char*) 1.0'", error=True,
184-
substrs=["cannot cast from type 'double' to pointer type"
185-
" 'char *'"])
201+
self.expect(
202+
"frame variable '(char*) 1.0'",
203+
error=True,
204+
substrs=["cannot cast from type 'double' to pointer type 'char *'"],
205+
)
186206

187207
self.expect_var_path("*(int*)(void*)ap", type="int", value="1")
188208

189209
self.expect_var_path("(ns::Foo*)ns_inner_foo_ptr_", type="ns::Foo *")
190210
self.expect_var_path("(ns::inner::Foo*)ns_foo_ptr_", type="ns::inner::Foo *")
191211

192-
self.expect("frame variable '(int& &)ap'", error=True,
193-
substrs=["type name declared as a reference to a "
194-
"reference"])
195-
self.expect("frame variable '(int&*)ap'", error=True,
196-
substrs=["'type name' declared as a pointer "
197-
"to a reference of type 'int &'"])
212+
self.expect(
213+
"frame variable '(int& &)ap'",
214+
error=True,
215+
substrs=["type name declared as a reference to a reference"],
216+
)
217+
self.expect(
218+
"frame variable '(int&*)ap'",
219+
error=True,
220+
substrs=[
221+
"'type name' declared as a pointer to a reference of type 'int &'"
222+
],
223+
)
198224

199225
if Is32Bit:
200-
self.expect_var_path("(void *)0", type="void *", value="0x00000000")
226+
self.expect_var_path("(void *)0", type="void *", value="0x00000000")
201227
else:
202-
self.expect_var_path("(void *)0", type="void *", value="0x0000000000000000")
228+
self.expect_var_path("(void *)0", type="void *", value="0x0000000000000000")
203229

204230

205231
# TestCStyleCastArray
206232

207-
threads = lldbutil.continue_to_source_breakpoint(
208-
self, process,"Set a breakpoint here", lldb.SBFileSpec("main.cpp")
209-
)
210-
self.assertEqual(
211-
len(threads), 1, "There should be a thread stopped at our breakpoint"
212-
)
213-
214233
self.expect_var_path("(int*)arr_1d", type="int *")
215234
self.expect_var_path("(char*)arr_1d", type="char *")
216235
self.expect_var_path("((char*)arr_1d)[0]", type="char", value="'\\x01'")

lldb/test/API/commands/frame/var-dil/expr/CStyleCast/main.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ int main(int argc, char **argv) {
5757
float fmax = std::numeric_limits<float>::max();
5858
float fdenorm = std::numeric_limits<float>::denorm_min();
5959

60-
// TestCStyleCastBuiltins
61-
// TestCStyleCastBasicType
62-
// TestCStyleCastPointer
63-
// TestCStyleCastNullptrType
64-
if (false) { // Set a breakpoint here
65-
}
66-
6760
struct InnerFoo {
6861
int a;
6962
int b;
@@ -75,7 +68,5 @@ int main(int argc, char **argv) {
7568
int arr_1d[] = {1, 2, 3, 4};
7669
int arr_2d[2][3] = {{1, 2, 3}, {4, 5, 6}};
7770

78-
// TestCStyleCastArray
79-
// TestCStyleCastReference
8071
return 0; // Set a breakpoint here
8172
}

0 commit comments

Comments
 (0)