mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Relaxed assert in AsmJsonImporter::createAsmNode.
This commit is contained in:
parent
211227f50b
commit
3416c029cf
@ -76,8 +76,7 @@ struct SourceLocation
|
|||||||
source &&
|
source &&
|
||||||
0 <= start &&
|
0 <= start &&
|
||||||
start <= end &&
|
start <= end &&
|
||||||
// in some cases (json import) source->source() can be empty
|
end <= int(source->source().length());
|
||||||
(source->source().empty() || end <= int(source->source().length()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string text() const
|
std::string text() const
|
||||||
@ -125,7 +124,7 @@ inline std::ostream& operator<<(std::ostream& _out, SourceLocation const& _locat
|
|||||||
if (_location.source)
|
if (_location.source)
|
||||||
_out << _location.source->name();
|
_out << _location.source->name();
|
||||||
|
|
||||||
_out << "[" << _location.start << "," << _location.end << ")";
|
_out << "[" << _location.start << "," << _location.end << "]";
|
||||||
|
|
||||||
return _out;
|
return _out;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,10 @@ T AsmJsonImporter::createAsmNode(Json::Value const& _node)
|
|||||||
{
|
{
|
||||||
T r;
|
T r;
|
||||||
r.location = createSourceLocation(_node);
|
r.location = createSourceLocation(_node);
|
||||||
astAssert(r.location.hasText(), "Invalid source location in Asm AST");
|
astAssert(
|
||||||
|
r.location.source && 0 <= r.location.start && r.location.start <= r.location.end,
|
||||||
|
"Invalid source location in Asm AST"
|
||||||
|
);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ BOOST_AUTO_TEST_SUITE(Assembler)
|
|||||||
BOOST_AUTO_TEST_CASE(all_assembly_items)
|
BOOST_AUTO_TEST_CASE(all_assembly_items)
|
||||||
{
|
{
|
||||||
Assembly _assembly;
|
Assembly _assembly;
|
||||||
auto root_asm = make_shared<CharStream>("", "root.asm");
|
auto root_asm = make_shared<CharStream>("lorem ipsum", "root.asm");
|
||||||
_assembly.setSourceLocation({1, 3, root_asm});
|
_assembly.setSourceLocation({1, 3, root_asm});
|
||||||
|
|
||||||
Assembly _subAsm;
|
Assembly _subAsm;
|
||||||
auto sub_asm = make_shared<CharStream>("", "sub.asm");
|
auto sub_asm = make_shared<CharStream>("lorem ipsum", "sub.asm");
|
||||||
_subAsm.setSourceLocation({6, 8, sub_asm});
|
_subAsm.setSourceLocation({6, 8, sub_asm});
|
||||||
_subAsm.append(Instruction::INVALID);
|
_subAsm.append(Instruction::INVALID);
|
||||||
shared_ptr<Assembly> _subAsmPtr = make_shared<Assembly>(_subAsm);
|
shared_ptr<Assembly> _subAsmPtr = make_shared<Assembly>(_subAsm);
|
||||||
|
@ -33,9 +33,9 @@ BOOST_AUTO_TEST_SUITE(SourceLocationTest)
|
|||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(test_fail)
|
BOOST_AUTO_TEST_CASE(test_fail)
|
||||||
{
|
{
|
||||||
auto const source = std::make_shared<CharStream>("", "source");
|
auto const source = std::make_shared<CharStream>("lorem ipsum", "source");
|
||||||
auto const sourceA = std::make_shared<CharStream>("", "sourceA");
|
auto const sourceA = std::make_shared<CharStream>("lorem ipsum", "sourceA");
|
||||||
auto const sourceB = std::make_shared<CharStream>("", "sourceB");
|
auto const sourceB = std::make_shared<CharStream>("lorem ipsum", "sourceB");
|
||||||
|
|
||||||
BOOST_CHECK(SourceLocation{} == SourceLocation{});
|
BOOST_CHECK(SourceLocation{} == SourceLocation{});
|
||||||
BOOST_CHECK((SourceLocation{0, 3, sourceA} != SourceLocation{0, 3, sourceB}));
|
BOOST_CHECK((SourceLocation{0, 3, sourceA} != SourceLocation{0, 3, sourceB}));
|
||||||
|
Loading…
Reference in New Issue
Block a user