Skip to content

Commit

Permalink
[evmasm] Fix handling of missing source locations during import.
Browse files Browse the repository at this point in the history
  • Loading branch information
aarlt committed Mar 1, 2024
1 parent 7676ab1 commit 6b417dd
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Compiler Features:

Bugfixes:
* Assembler: Prevent incorrect calculation of tag sizes.
* EVM Assembly Import: Fix handling of missing source locations during import.
* SMTChecker: Fix internal error caused by not respecting the sign of an integer type when constructing zero-value SMT expressions.
* SMTChecker: Ensure query is properly flushed to a file before calling solver when using SMT-LIB interface.

Expand Down
6 changes: 4 additions & 2 deletions libevmasm/Assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,10 @@ AssemblyItem Assembly::createAssemblyItemFromJSON(Json::Value const& _json, std:
solRequire(!name.empty(), AssemblyImportException, "Member 'name' is empty.");

SourceLocation location;
location.start = get<int>(_json["begin"]);
location.end = get<int>(_json["end"]);
if (_json.isMember("begin"))
location.start = get<int>(_json["begin"]);
if (_json.isMember("end"))
location.end = get<int>(_json["end"]);
int srcIndex = getOrDefault<int>(_json["source"], -1);
size_t modifierDepth = static_cast<size_t>(getOrDefault<int>(_json["modifierDepth"], 0));
std::string value = getOrDefault<std::string>(_json["value"], "");
Expand Down
20 changes: 10 additions & 10 deletions test/cmdlineTests/asm_json_import_all_valid_flags/output
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
".code":
[
{
"begin": 0,
"end": 0,
"begin": -1,
"end": -1,
"name": "PUSH",
"source": -1,
"value": "0"
Expand All @@ -22,8 +22,8 @@
".code":
[
{
"begin": 0,
"end": 0,
"begin": -1,
"end": -1,
"name": "PUSH",
"source": -1,
"value": "1"
Expand All @@ -40,8 +40,8 @@
"bin": "5ffe",
"bin-runtime": "6001",
"opcodes": "PUSH0 INVALID ",
"srcmap": "0:0::-:0",
"srcmap-runtime": "0:0::-:0"
"srcmap": ":::-:0",
"srcmap-runtime": ":::-:0"
}
},
"sourceList":
Expand All @@ -60,8 +60,8 @@ EVM assembly:
".code":
[
{
"begin": 0,
"end": 0,
"begin": -1,
"end": -1,
"name": "PUSH",
"source": -1,
"value": "0"
Expand All @@ -74,8 +74,8 @@ EVM assembly:
".code":
[
{
"begin": 0,
"end": 0,
"begin": -1,
"end": -1,
"name": "PUSH",
"source": -1,
"value": "1"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Opcodes:
PREVRANDAO PREVRANDAO
EVM assembly:
/* */
prevrandao
prevrandao
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Opcodes:
PUSH0 INVALID
EVM assembly:
/* */
0x00
stop

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
Opcodes:
PUSH0 INVALID
EVM assembly:
/* */
0x00
stop

Expand Down

0 comments on commit 6b417dd

Please sign in to comment.