More granular error reporting in warnOnInstruction in AsmAnalysis

This commit is contained in:
Alex Beregszaszi 2019-02-25 18:04:55 +00:00
parent 80417e3d8c
commit 5fc8e29fff

View File

@ -641,7 +641,22 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio
solAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), ""); solAssert(m_evmVersion.hasBitwiseShifting() == m_evmVersion.hasCreate2(), "");
solAssert(m_dialect->flavour != AsmFlavour::Yul, ""); solAssert(m_dialect->flavour != AsmFlavour::Yul, "");
auto warningForVM = [=](string const& vmKindMessage) {
m_errorReporter.warning(
_location,
"The \"" +
boost::to_lower_copy(instructionInfo(_instr).name)
+ "\" instruction is " +
vmKindMessage +
" VMs. " +
"You are currently compiling for \"" +
m_evmVersion.name() +
"\", where it will be interpreted as an invalid instruction."
);
};
if (_instr == solidity::Instruction::EXTCODEHASH) if (_instr == solidity::Instruction::EXTCODEHASH)
{
m_errorReporter.warning( m_errorReporter.warning(
_location, _location,
"The \"" + "The \"" +
@ -651,35 +666,30 @@ void AsmAnalyzer::warnOnInstructions(solidity::Instruction _instr, SourceLocatio
"\" you are currently compiling for. " + "\" you are currently compiling for. " +
"It will be interpreted as an invalid instruction on this VM." "It will be interpreted as an invalid instruction on this VM."
); );
}
else if (( else if ((
_instr == solidity::Instruction::RETURNDATACOPY || _instr == solidity::Instruction::RETURNDATACOPY ||
_instr == solidity::Instruction::RETURNDATASIZE || _instr == solidity::Instruction::RETURNDATASIZE
_instr == solidity::Instruction::STATICCALL
) && !m_evmVersion.supportsReturndata()) ) && !m_evmVersion.supportsReturndata())
m_errorReporter.warning( {
_location, warningForVM("only available for Byzantium-compatible");
"The \"" + }
boost::to_lower_copy(instructionInfo(_instr).name) else if (_instr == solidity::Instruction::STATICCALL && !m_evmVersion.hasStaticCall())
+ "\" instruction is only available for Byzantium-compatible VMs. " + {
"You are currently compiling for \"" + warningForVM("only available for Byzantium-compatible");
m_evmVersion.name() + }
"\", where it will be interpreted as an invalid instruction."
);
else if (( else if ((
_instr == solidity::Instruction::SHL || _instr == solidity::Instruction::SHL ||
_instr == solidity::Instruction::SHR || _instr == solidity::Instruction::SHR ||
_instr == solidity::Instruction::SAR || _instr == solidity::Instruction::SAR
_instr == solidity::Instruction::CREATE2
) && !m_evmVersion.hasBitwiseShifting()) ) && !m_evmVersion.hasBitwiseShifting())
m_errorReporter.warning( {
_location, warningForVM("only available for Constantinople-compatible");
"The \"" + }
boost::to_lower_copy(instructionInfo(_instr).name) else if (_instr == solidity::Instruction::CREATE2 && !m_evmVersion.hasCreate2())
+ "\" instruction is only available for Constantinople-compatible VMs. " + {
"You are currently compiling for \"" + warningForVM("only available for Constantinople-compatible");
m_evmVersion.name() + }
"\", where it will be interpreted as an invalid instruction."
);
else if (_instr == solidity::Instruction::JUMP || _instr == solidity::Instruction::JUMPI || _instr == solidity::Instruction::JUMPDEST) else if (_instr == solidity::Instruction::JUMP || _instr == solidity::Instruction::JUMPI || _instr == solidity::Instruction::JUMPDEST)
{ {
if (m_dialect->flavour == AsmFlavour::Loose) if (m_dialect->flavour == AsmFlavour::Loose)