@@ -142,8 +142,8 @@ class java_bytecode_parsert final : public parsert
142
142
error () << " unexpected end of bytecode file" << eom;
143
143
throw 0 ;
144
144
}
145
- result <<= 8 ;
146
- result |= in->get ();
145
+ result <<= 8u ;
146
+ result |= static_cast <u1>( in->get () );
147
147
}
148
148
return narrow_cast<T>(result);
149
149
}
@@ -185,7 +185,7 @@ class structured_pool_entryt
185
185
using pool_entryt = java_bytecode_parsert::pool_entryt;
186
186
using pool_entry_lookupt = std::function<pool_entryt &(u2)>;
187
187
188
- explicit structured_pool_entryt (pool_entryt entry) : tag(entry.tag)
188
+ explicit structured_pool_entryt (const pool_entryt & entry) : tag(entry.tag)
189
189
{
190
190
}
191
191
@@ -217,7 +217,7 @@ class class_infot : public structured_pool_entryt
217
217
name_index = entry.ref1 ;
218
218
}
219
219
220
- std::string get_name (pool_entry_lookupt pool_entry) const
220
+ std::string get_name (const pool_entry_lookupt & pool_entry) const
221
221
{
222
222
const pool_entryt &name_entry = pool_entry (name_index);
223
223
return read_utf8_constant (name_entry);
@@ -232,21 +232,21 @@ class class_infot : public structured_pool_entryt
232
232
class name_and_type_infot : public structured_pool_entryt
233
233
{
234
234
public:
235
- explicit name_and_type_infot (pool_entryt entry)
235
+ explicit name_and_type_infot (const pool_entryt & entry)
236
236
: structured_pool_entryt(entry)
237
237
{
238
238
PRECONDITION (entry.tag == CONSTANT_NameAndType);
239
239
name_index = entry.ref1 ;
240
240
descriptor_index = entry.ref2 ;
241
241
}
242
242
243
- std::string get_name (pool_entry_lookupt pool_entry) const
243
+ std::string get_name (const pool_entry_lookupt & pool_entry) const
244
244
{
245
245
const pool_entryt &name_entry = pool_entry (name_index);
246
246
return read_utf8_constant (name_entry);
247
247
}
248
248
249
- std::string get_descriptor (pool_entry_lookupt pool_entry) const
249
+ std::string get_descriptor (const pool_entry_lookupt & pool_entry) const
250
250
{
251
251
const pool_entryt &descriptor_entry = pool_entry (descriptor_index);
252
252
return read_utf8_constant (descriptor_entry);
@@ -260,7 +260,8 @@ class name_and_type_infot : public structured_pool_entryt
260
260
class base_ref_infot : public structured_pool_entryt
261
261
{
262
262
public:
263
- explicit base_ref_infot (pool_entryt entry) : structured_pool_entryt(entry)
263
+ explicit base_ref_infot (const pool_entryt &entry)
264
+ : structured_pool_entryt(entry)
264
265
{
265
266
PRECONDITION (
266
267
entry.tag == CONSTANT_Fieldref || entry.tag == CONSTANT_Methodref ||
@@ -278,7 +279,8 @@ class base_ref_infot : public structured_pool_entryt
278
279
return name_and_type_index;
279
280
}
280
281
281
- name_and_type_infot get_name_and_type (pool_entry_lookupt pool_entry) const
282
+ name_and_type_infot
283
+ get_name_and_type (const pool_entry_lookupt &pool_entry) const
282
284
{
283
285
const pool_entryt &name_and_type_entry = pool_entry (name_and_type_index);
284
286
@@ -290,7 +292,7 @@ class base_ref_infot : public structured_pool_entryt
290
292
return name_and_type_infot{name_and_type_entry};
291
293
}
292
294
293
- class_infot get_class (pool_entry_lookupt pool_entry) const
295
+ class_infot get_class (const pool_entry_lookupt & pool_entry) const
294
296
{
295
297
const pool_entryt &class_entry = pool_entry (class_index);
296
298
@@ -321,7 +323,7 @@ class method_handle_infot : public structured_pool_entryt
321
323
REF_invokeInterface = 9
322
324
};
323
325
324
- explicit method_handle_infot (pool_entryt entry)
326
+ explicit method_handle_infot (const pool_entryt & entry)
325
327
: structured_pool_entryt(entry)
326
328
{
327
329
PRECONDITION (entry.tag == CONSTANT_MethodHandle);
@@ -330,7 +332,7 @@ class method_handle_infot : public structured_pool_entryt
330
332
reference_index = entry.ref2 ;
331
333
}
332
334
333
- base_ref_infot get_reference (pool_entry_lookupt pool_entry) const
335
+ base_ref_infot get_reference (const pool_entry_lookupt & pool_entry) const
334
336
{
335
337
const base_ref_infot ref_entry{pool_entry (reference_index)};
336
338
@@ -403,20 +405,20 @@ bool java_bytecode_parsert::parse()
403
405
return false ;
404
406
}
405
407
406
- #define ACC_PUBLIC 0x0001
407
- #define ACC_PRIVATE 0x0002
408
- #define ACC_PROTECTED 0x0004
409
- #define ACC_STATIC 0x0008
410
- #define ACC_FINAL 0x0010
411
- #define ACC_SYNCHRONIZED 0x0020
412
- #define ACC_BRIDGE 0x0040
413
- #define ACC_NATIVE 0x0100
414
- #define ACC_INTERFACE 0x0200
415
- #define ACC_ABSTRACT 0x0400
416
- #define ACC_STRICT 0x0800
417
- #define ACC_SYNTHETIC 0x1000
418
- #define ACC_ANNOTATION 0x2000
419
- #define ACC_ENUM 0x4000
408
+ #define ACC_PUBLIC 0x0001u
409
+ #define ACC_PRIVATE 0x0002u
410
+ #define ACC_PROTECTED 0x0004u
411
+ #define ACC_STATIC 0x0008u
412
+ #define ACC_FINAL 0x0010u
413
+ #define ACC_SYNCHRONIZED 0x0020u
414
+ #define ACC_BRIDGE 0x0040u
415
+ #define ACC_NATIVE 0x0100u
416
+ #define ACC_INTERFACE 0x0200u
417
+ #define ACC_ABSTRACT 0x0400u
418
+ #define ACC_STRICT 0x0800u
419
+ #define ACC_SYNTHETIC 0x1000u
420
+ #define ACC_ANNOTATION 0x2000u
421
+ #define ACC_ENUM 0x4000u
420
422
421
423
#define UNUSED_u2 (x ) \
422
424
{ \
@@ -831,10 +833,6 @@ void java_bytecode_parsert::rconstant_pool()
831
833
entry.expr .type () = type;
832
834
}
833
835
break ;
834
-
835
- default :
836
- {
837
- };
838
836
}
839
837
});
840
838
}
@@ -918,7 +916,7 @@ void java_bytecode_parsert::rbytecode(std::vector<instructiont> &instructions)
918
916
bytecode_info[bytecode].mnemonic );
919
917
}
920
918
921
- instructions.push_back ( instructiont () );
919
+ instructions.emplace_back ( );
922
920
instructiont &instruction=instructions.back ();
923
921
instruction.bytecode = bytecode;
924
922
instruction.address =start_of_instruction;
@@ -1033,7 +1031,7 @@ void java_bytecode_parsert::rbytecode(std::vector<instructiont> &instructions)
1033
1031
u4 base_offset=address;
1034
1032
1035
1033
// first a pad to 32-bit align
1036
- while (((address + 1 ) & 3 ) != 0 )
1034
+ while (((address + 1u ) & 3u ) != 0 )
1037
1035
{
1038
1036
read <u1>();
1039
1037
address++;
@@ -1071,7 +1069,7 @@ void java_bytecode_parsert::rbytecode(std::vector<instructiont> &instructions)
1071
1069
size_t base_offset=address;
1072
1070
1073
1071
// first a pad to 32-bit align
1074
- while (((address + 1 ) & 3 ) != 0 )
1072
+ while (((address + 1u ) & 3u ) != 0 )
1075
1073
{
1076
1074
read <u1>();
1077
1075
address++;
@@ -1400,7 +1398,7 @@ void java_bytecode_parsert::rcode_attribute(methodt &method)
1400
1398
}
1401
1399
else if (252 <=frame_type && frame_type<=254 )
1402
1400
{
1403
- size_t new_locals=( size_t ) ( frame_type- 251 ) ;
1401
+ size_t new_locals = frame_type - 251 ;
1404
1402
method.stack_map_table [i].type =methodt::stack_map_table_entryt::APPEND;
1405
1403
method.stack_map_table [i].locals .resize (new_locals);
1406
1404
method.stack_map_table [i].stack .resize (0 );
@@ -1699,8 +1697,8 @@ void java_bytecode_parsert::rclass_attribute(classt &parsed_class)
1699
1697
const u2 sourcefile_index = read <u2>();
1700
1698
irep_idt sourcefile_name;
1701
1699
1702
- std::string fqn (id2string (parsed_class.name ));
1703
- size_t last_index= fqn.find_last_of (" . " );
1700
+ const std::string & fqn (id2string (parsed_class.name ));
1701
+ size_t last_index = fqn.find_last_of (' . ' );
1704
1702
if (last_index==std::string::npos)
1705
1703
sourcefile_name=pool_entry (sourcefile_index).s ;
1706
1704
else
@@ -1764,20 +1762,20 @@ void java_bytecode_parsert::rmethods(classt &parsed_class)
1764
1762
rmethod (parsed_class);
1765
1763
}
1766
1764
1767
- #define ACC_PUBLIC 0x0001
1768
- #define ACC_PRIVATE 0x0002
1769
- #define ACC_PROTECTED 0x0004
1770
- #define ACC_STATIC 0x0008
1771
- #define ACC_FINAL 0x0010
1772
- #define ACC_VARARGS 0x0080
1773
- #define ACC_SUPER 0x0020
1774
- #define ACC_VOLATILE 0x0040
1775
- #define ACC_TRANSIENT 0x0080
1776
- #define ACC_INTERFACE 0x0200
1777
- #define ACC_ABSTRACT 0x0400
1778
- #define ACC_SYNTHETIC 0x1000
1779
- #define ACC_ANNOTATION 0x2000
1780
- #define ACC_ENUM 0x4000
1765
+ #define ACC_PUBLIC 0x0001u
1766
+ #define ACC_PRIVATE 0x0002u
1767
+ #define ACC_PROTECTED 0x0004u
1768
+ #define ACC_STATIC 0x0008u
1769
+ #define ACC_FINAL 0x0010u
1770
+ #define ACC_VARARGS 0x0080u
1771
+ #define ACC_SUPER 0x0020u
1772
+ #define ACC_VOLATILE 0x0040u
1773
+ #define ACC_TRANSIENT 0x0080u
1774
+ #define ACC_INTERFACE 0x0200u
1775
+ #define ACC_ABSTRACT 0x0400u
1776
+ #define ACC_SYNTHETIC 0x1000u
1777
+ #define ACC_ANNOTATION 0x2000u
1778
+ #define ACC_ENUM 0x4000u
1781
1779
1782
1780
void java_bytecode_parsert::rmethod (classt &parsed_class)
1783
1781
{
0 commit comments