mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11141 from ethereum/compilation-framework-fuzzer
Enable multi-source fuzzing.
This commit is contained in:
commit
6f3095a199
@ -59,7 +59,7 @@ DEFINE_PROTO_FUZZER(Contract const& _contract)
|
||||
langutil::EVMVersion version;
|
||||
EVMHost hostContext(version, evmone);
|
||||
string contractName = ":C";
|
||||
CompilerInput cInput(version, contractSource, contractName, OptimiserSettings::minimal(), {}, false);
|
||||
CompilerInput cInput(version, {{"test.sol", contractSource}}, contractName, OptimiserSettings::minimal(), {});
|
||||
EvmoneUtility evmoneUtil(
|
||||
hostContext,
|
||||
cInput,
|
||||
|
@ -32,10 +32,11 @@ using namespace std;
|
||||
|
||||
optional<CompilerOutput> SolidityCompilationFramework::compileContract()
|
||||
{
|
||||
m_compiler.setSources({{"", m_compilerInput.sourceCode}});
|
||||
m_compiler.setSources(m_compilerInput.sourceCode);
|
||||
m_compiler.setLibraries(m_compilerInput.libraryAddresses);
|
||||
m_compiler.setEVMVersion(m_compilerInput.evmVersion);
|
||||
m_compiler.setOptimiserSettings(m_compilerInput.optimiserSettings);
|
||||
m_compiler.setViaIR(m_compilerInput.viaIR);
|
||||
if (!m_compiler.compile())
|
||||
{
|
||||
if (m_compilerInput.debugFailure)
|
||||
@ -68,7 +69,7 @@ bool EvmoneUtility::zeroWord(uint8_t const* _result, size_t _length)
|
||||
{
|
||||
return _length == 32 &&
|
||||
ranges::all_of(
|
||||
ranges::span(_result, _length),
|
||||
ranges::span(_result, static_cast<long>(_length)),
|
||||
[](uint8_t _v) { return _v == 0; });
|
||||
}
|
||||
|
||||
|
@ -42,23 +42,25 @@ struct CompilerInput
|
||||
{
|
||||
CompilerInput(
|
||||
langutil::EVMVersion _evmVersion,
|
||||
std::string const& _sourceCode,
|
||||
StringMap const& _sourceCode,
|
||||
std::string const& _contractName,
|
||||
frontend::OptimiserSettings _optimiserSettings,
|
||||
std::map<std::string, solidity::util::h160> _libraryAddresses,
|
||||
bool _debugFailure
|
||||
bool _debugFailure = false,
|
||||
bool _viaIR = false
|
||||
):
|
||||
evmVersion(_evmVersion),
|
||||
sourceCode(_sourceCode),
|
||||
contractName(_contractName),
|
||||
optimiserSettings(_optimiserSettings),
|
||||
libraryAddresses(_libraryAddresses),
|
||||
debugFailure(_debugFailure)
|
||||
debugFailure(_debugFailure),
|
||||
viaIR(_viaIR)
|
||||
{}
|
||||
/// EVM target version
|
||||
langutil::EVMVersion evmVersion;
|
||||
/// Source code to be compiled
|
||||
std::string const& sourceCode;
|
||||
StringMap const& sourceCode;
|
||||
/// Contract name
|
||||
std::string contractName;
|
||||
/// Optimiser setting to be used during compilation
|
||||
@ -67,6 +69,8 @@ struct CompilerInput
|
||||
std::map<std::string, solidity::util::h160> libraryAddresses;
|
||||
/// Flag used for debugging
|
||||
bool debugFailure;
|
||||
/// Flag to enable new code generator.
|
||||
bool viaIR;
|
||||
};
|
||||
|
||||
class SolidityCompilationFramework
|
||||
|
@ -50,7 +50,7 @@ DEFINE_PROTO_FUZZER(Contract const& _input)
|
||||
EVMHost hostContext(version, evmone);
|
||||
string contractName = ":C";
|
||||
string methodName = "test()";
|
||||
CompilerInput cInput(version, contract_source, contractName, OptimiserSettings::minimal(), {}, false);
|
||||
CompilerInput cInput(version, {{"test.sol", contract_source}}, contractName, OptimiserSettings::minimal(), {});
|
||||
EvmoneUtility evmoneUtil(
|
||||
hostContext,
|
||||
cInput,
|
||||
|
@ -69,7 +69,7 @@ DEFINE_PROTO_FUZZER(Program const& _input)
|
||||
string contractName = ":C";
|
||||
string libraryName = converter.libraryTest() ? converter.libraryName() : "";
|
||||
string methodName = "test()";
|
||||
CompilerInput cInput(version, sol_source, contractName, OptimiserSettings::minimal(), {}, false);
|
||||
CompilerInput cInput(version, {{"test.sol", sol_source}}, contractName, OptimiserSettings::minimal(), {});
|
||||
EvmoneUtility evmoneUtil(
|
||||
hostContext,
|
||||
cInput,
|
||||
|
Loading…
Reference in New Issue
Block a user