Skip to content

Commit 13f734a

Browse files
authored
Merge pull request #3494 from tautschnig/construct-j-parse-tree
Add a new constructor to java_bytecode_parse_treet
2 parents 2d8994e + 1dfd5cd commit 13f734a

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

jbmc/src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ struct java_bytecode_parse_treet
199199
{
200200
classt() = default;
201201

202+
/// Create a class \p name.
203+
explicit classt(const irep_idt &name) : name(name)
204+
{
205+
}
206+
202207
// Disallow copy construction and copy assignment, but allow move
203208
// construction and move assignment.
204209
#ifndef _MSC_VER // Ommit this on MS VC2013 as move is not supported.
@@ -296,7 +301,6 @@ struct java_bytecode_parse_treet
296301
}
297302

298303
void output(std::ostream &out) const;
299-
300304
};
301305

302306
classt parsed_class;
@@ -307,9 +311,14 @@ struct java_bytecode_parse_treet
307311
typedef std::set<irep_idt> class_refst;
308312
class_refst class_refs;
309313

310-
bool loading_successful;
314+
bool loading_successful = false;
315+
316+
/// An empty bytecode parse tree, no class name set
317+
java_bytecode_parse_treet() = default;
311318

312-
java_bytecode_parse_treet():loading_successful(false)
319+
/// Create a blank parse tree for class \p class_name.
320+
explicit java_bytecode_parse_treet(const irep_idt &class_name)
321+
: parsed_class(class_name)
313322
{
314323
}
315324
};

jbmc/src/java_bytecode/java_class_loader.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@ java_class_loadert::get_parse_tree(
120120
if(!class_loader_limit.load_class_file(class_name_to_jar_file(class_name)))
121121
{
122122
debug() << "not loading " << class_name << " because of limit" << eom;
123-
java_bytecode_parse_treet parse_tree;
124-
parse_tree.parsed_class.name = class_name;
125-
parse_trees.push_back(std::move(parse_tree));
123+
parse_trees.emplace_back(class_name);
126124
return parse_trees;
127125
}
128126

@@ -179,9 +177,7 @@ java_class_loadert::get_parse_tree(
179177

180178
// Not found or failed to load
181179
warning() << "failed to load class `" << class_name << '\'' << eom;
182-
java_bytecode_parse_treet parse_tree;
183-
parse_tree.parsed_class.name=class_name;
184-
parse_trees.push_back(std::move(parse_tree));
180+
parse_trees.emplace_back(class_name);
185181
return parse_trees;
186182
}
187183

0 commit comments

Comments
 (0)