Merge pull request #8075 from ethereum/refactor-namespaces

Refactor namespaces
This commit is contained in:
Daniel Kirchner
2020-01-07 16:52:20 +01:00
committed by GitHub
544 changed files with 2881 additions and 3548 deletions
+3 -3
View File
@@ -1,13 +1,13 @@
#include <test/tools/ossfuzz/abiV2FuzzerCommon.h>
using namespace dev::test::abiv2fuzzer;
using namespace solidity::test::abiv2fuzzer;
SolidityCompilationFramework::SolidityCompilationFramework(langutil::EVMVersion _evmVersion)
{
m_evmVersion = _evmVersion;
}
dev::bytes SolidityCompilationFramework::compileContract(
solidity::bytes SolidityCompilationFramework::compileContract(
std::string const& _sourceCode,
std::string const& _contractName
)
@@ -27,7 +27,7 @@ dev::bytes SolidityCompilationFramework::compileContract(
);
std::cerr << "Compiling contract failed" << std::endl;
}
dev::eth::LinkerObject obj = m_compiler.object(
evmasm::LinkerObject obj = m_compiler.object(
_contractName.empty() ?
m_compiler.lastContractName() :
_contractName
+7 -11
View File
@@ -7,14 +7,11 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libdevcore/Keccak256.h>
#include <libsolutil/Keccak256.h>
namespace dev
{
namespace test
{
namespace abiv2fuzzer
namespace solidity::test::abiv2fuzzer
{
class SolidityCompilationFramework
{
public:
@@ -24,15 +21,14 @@ public:
{
return m_compiler.methodIdentifiers(m_compiler.lastContractName());
}
dev::bytes compileContract(
bytes compileContract(
std::string const& _sourceCode,
std::string const& _contractName = {}
);
protected:
dev::solidity::CompilerStack m_compiler;
frontend::CompilerStack m_compiler;
langutil::EVMVersion m_evmVersion;
dev::solidity::OptimiserSettings m_optimiserSettings = dev::solidity::OptimiserSettings::none();
frontend::OptimiserSettings m_optimiserSettings = frontend::OptimiserSettings::none();
};
}
}
}
+1 -1
View File
@@ -101,4 +101,4 @@ message Contract {
required Test test = 3;
}
package dev.test.abiv2fuzzer;
package solidity.test.abiv2fuzzer;
+10 -9
View File
@@ -26,9 +26,10 @@
static evmc::VM evmone = evmc::VM{evmc_create_evmone()};
using namespace dev::test::abiv2fuzzer;
using namespace dev::test;
using namespace dev;
using namespace solidity::test::abiv2fuzzer;
using namespace solidity::test;
using namespace solidity::util;
using namespace solidity;
using namespace std;
namespace
@@ -59,7 +60,7 @@ bool isOutputExpected(uint8_t const* _result, size_t _length)
/// The gas field is set to the maximum permissible value so that we
/// don't run into out of gas errors. The input field is copied from
/// user input.
evmc_message initializeMessage(dev::bytes const& _input)
evmc_message initializeMessage(bytes const& _input)
{
// Zero initialize all message fields
evmc_message msg = {};
@@ -76,7 +77,7 @@ evmc_message initializeMessage(dev::bytes const& _input)
/// input and returns the result of the execution of the called function.
evmc::result executeContract(
EVMHost& _hostContext,
dev::bytes const& _functionHash,
bytes const& _functionHash,
evmc_address _deployedAddress
)
{
@@ -89,7 +90,7 @@ evmc::result executeContract(
/// Accepts a reference to host context implementation and byte code
/// as input and deploys it on the simulated blockchain. Returns the
/// result of deployment.
evmc::result deployContract(EVMHost& _hostContext, dev::bytes const& _code)
evmc::result deployContract(EVMHost& _hostContext, bytes const& _code)
{
evmc_message message = initializeMessage(_code);
message.kind = EVMC_CREATE;
@@ -110,7 +111,7 @@ DEFINE_PROTO_FUZZER(Contract const& _input)
}
// Raw runtime byte code generated by solidity
dev::bytes byteCode;
bytes byteCode;
std::string hexEncodedInput;
try
@@ -124,7 +125,7 @@ DEFINE_PROTO_FUZZER(Contract const& _input)
hexEncodedInput = methodIdentifiers["test()"].asString();
}
// Ignore stack too deep errors during compilation
catch (eth::StackTooDeepException const&)
catch (evmasm::StackTooDeepException const&)
{
return;
}
@@ -166,4 +167,4 @@ DEFINE_PROTO_FUZZER(Contract const& _input)
isOutputExpected(callResult.output_data, callResult.output_size),
"Proto ABIv2 fuzzer: ABIv2 coding failure found"
);
}
}
+3 -2
View File
@@ -1,8 +1,9 @@
#include <test/tools/ossfuzz/protoToAbiV2.h>
using namespace std;
using namespace dev;
using namespace dev::test::abiv2fuzzer;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::test::abiv2fuzzer;
string ProtoConverter::getVarDecl(
string const& _type,
+9 -13
View File
@@ -2,10 +2,10 @@
#include <test/tools/ossfuzz/abiV2Proto.pb.h>
#include <libdevcore/FixedHash.h>
#include <libdevcore/Keccak256.h>
#include <libdevcore/StringUtils.h>
#include <libdevcore/Whiskers.h>
#include <libsolutil/FixedHash.h>
#include <libsolutil/Keccak256.h>
#include <libsolutil/StringUtils.h>
#include <libsolutil/Whiskers.h>
#include <liblangutil/Exceptions.h>
@@ -131,12 +131,9 @@
* }
*/
namespace dev
{
namespace test
{
namespace abiv2fuzzer
namespace solidity::test::abiv2fuzzer
{
/// Converts a protobuf input into a Solidity program that tests
/// abi coding.
class ProtoConverter
@@ -485,7 +482,7 @@ public:
// Convert _counter to string and return its keccak256 hash
static u256 hashUnsignedInt(unsigned _counter)
{
return keccak256(h256(_counter));
return util::keccak256(util::h256(_counter));
}
static u256 maskUnsignedInt(unsigned _counter, unsigned _numMaskNibbles)
@@ -497,7 +494,7 @@ public:
// Note: Don't change HexPrefix::Add. See comment in fixedByteValueAsString().
static std::string maskUnsignedIntToHex(unsigned _counter, unsigned _numMaskNibbles)
{
return toHex(maskUnsignedInt(_counter, _numMaskNibbles), HexPrefix::Add);
return toHex(maskUnsignedInt(_counter, _numMaskNibbles), util::HexPrefix::Add);
}
/// Dynamically sized arrays can have a length of at least zero
@@ -933,6 +930,5 @@ public:
using AbiV2ProtoVisitor<bool>::visit;
};
}
}
}
+7 -5
View File
@@ -20,7 +20,7 @@
#include <libyul/Exceptions.h>
#include <libdevcore/StringUtils.h>
#include <libsolutil/StringUtils.h>
#include <boost/algorithm/cxx11/all_of.hpp>
#include <boost/algorithm/string/classification.hpp>
@@ -28,8 +28,10 @@
#include <boost/range/algorithm_ext/erase.hpp>
using namespace std;
using namespace yul::test::yul_fuzzer;
using namespace dev;
using namespace solidity::yul::test::yul_fuzzer;
using namespace solidity::yul::test;
using namespace solidity::util;
using namespace solidity;
string ProtoConverter::dictionaryToken(HexPrefix _p)
{
@@ -1232,7 +1234,7 @@ void ProtoConverter::visit(Block const& _x)
vector<string> ProtoConverter::createVars(unsigned _startIdx, unsigned _endIdx)
{
yulAssert(_endIdx > _startIdx, "Proto fuzzer: Variable indices not in range");
string varsStr = dev::suffixedVariableNameList("x_", _startIdx, _endIdx);
string varsStr = suffixedVariableNameList("x_", _startIdx, _endIdx);
m_output << varsStr;
vector<string> varsVec;
boost::split(
@@ -1546,4 +1548,4 @@ std::string ProtoConverter::functionTypeToString(NumFunctionReturns _type)
case NumFunctionReturns::Multiple:
return "m";
}
}
}
+7 -13
View File
@@ -27,15 +27,11 @@
#include <test/tools/ossfuzz/yulProto.pb.h>
#include <libdevcore/Common.h>
#include <libdevcore/FixedHash.h>
#include <libdevcore/Whiskers.h>
#include <libsolutil/Common.h>
#include <libsolutil/FixedHash.h>
#include <libsolutil/Whiskers.h>
namespace yul
{
namespace test
{
namespace yul_fuzzer
namespace solidity::yul::test::yul_fuzzer
{
class ProtoConverter
{
@@ -269,7 +265,7 @@ private:
/// index = (m_inputSize * m_inputSize + counter) % dictionarySize
/// where m_inputSize is the size of the protobuf input and
/// dictionarySize is the total number of entries in the dictionary.
std::string dictionaryToken(dev::HexPrefix _p = dev::HexPrefix::Add);
std::string dictionaryToken(util::HexPrefix _p = util::HexPrefix::Add);
/// Returns a monotonically increasing counter that starts from zero.
unsigned counter()
@@ -296,7 +292,7 @@ private:
/// enclosed within double quotes.
std::string newObjectId(bool _decorate = true)
{
return dev::Whiskers(R"(<?decorate>"</decorate>object<id><?decorate>"</decorate>)")
return util::Whiskers(R"(<?decorate>"</decorate>object<id><?decorate>"</decorate>)")
("decorate", _decorate)
("id", std::to_string(m_objectId++))
.render();
@@ -325,7 +321,7 @@ private:
/// Maps FunctionDef object to its name
std::map<FunctionDef const*, std::string> m_functionDefMap;
// Set that is used for deduplicating switch case literals
std::stack<std::set<dev::u256>> m_switchLiteralSetPerScope;
std::stack<std::set<u256>> m_switchLiteralSetPerScope;
// Look-up table per function type that holds the number of input (output) function parameters
std::map<std::string, std::pair<unsigned, unsigned>> m_functionSigMap;
/// Tree of objects and their scopes
@@ -356,5 +352,3 @@ private:
bool m_isObject;
};
}
}
}
@@ -19,7 +19,8 @@
#include <liblangutil/EVMVersion.h>
#include <libyul/backends/evm/EVMCodeTransform.h>
using namespace yul;
using namespace solidity;
using namespace solidity::yul;
using namespace std;
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
@@ -33,7 +34,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
dev::solidity::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full()
);
if (!stack.parseAndAnalyze("source", input))
@@ -27,8 +27,8 @@
#include <liblangutil/EVMVersion.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libdevcore/CommonIO.h>
#include <libdevcore/CommonData.h>
#include <libsolutil/CommonIO.h>
#include <libsolutil/CommonData.h>
#include <test/tools/ossfuzz/yulFuzzerCommon.h>
@@ -36,12 +36,12 @@
#include <memory>
#include <iostream>
using namespace yul;
using namespace std;
using namespace langutil;
using namespace dev;
using namespace yul::test::yul_fuzzer;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::yul::test::yul_fuzzer;
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
{
@@ -60,7 +60,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
dev::solidity::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full()
);
try
{
+4 -2
View File
@@ -18,7 +18,9 @@
#include <libyul/AssemblyStack.h>
#include <liblangutil/EVMVersion.h>
using namespace yul;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::yul;
using namespace std;
extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
@@ -32,7 +34,7 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t const* _data, size_t _size)
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
dev::solidity::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full()
);
if (!stack.parseAndAnalyze("source", input))
+3 -2
View File
@@ -17,8 +17,9 @@
#include <test/tools/ossfuzz/yulFuzzerCommon.h>
using namespace std;
using namespace yul;
using namespace yul::test::yul_fuzzer;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::yul::test::yul_fuzzer;
yulFuzzerUtil::TerminationReason yulFuzzerUtil::interpret(
ostream& _os,
+3 -7
View File
@@ -17,12 +17,9 @@
#include <test/tools/yulInterpreter/Interpreter.h>
#include <libyul/backends/evm/EVMDialect.h>
namespace yul
{
namespace test
{
namespace yul_fuzzer
namespace solidity::yul::test::yul_fuzzer
{
struct yulFuzzerUtil
{
enum class TerminationReason
@@ -43,6 +40,5 @@ struct yulFuzzerUtil
static size_t constexpr maxSteps = 100;
static size_t constexpr maxTraceSize = 75;
};
}
}
}
+1 -1
View File
@@ -411,4 +411,4 @@ message Program {
}
}
package yul.test.yul_fuzzer;
package solidity.yul.test.yul_fuzzer;
+4 -3
View File
@@ -26,8 +26,9 @@
#include <liblangutil/EVMVersion.h>
#include <libyul/Exceptions.h>
using namespace yul;
using namespace yul::test::yul_fuzzer;
using namespace solidity;
using namespace solidity::yul;
using namespace solidity::yul::test::yul_fuzzer;
using namespace std;
DEFINE_PROTO_FUZZER(Program const& _input)
@@ -52,7 +53,7 @@ DEFINE_PROTO_FUZZER(Program const& _input)
AssemblyStack stack(
langutil::EVMVersion(),
AssemblyStack::Language::StrictAssembly,
dev::solidity::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full()
);
// Parse protobuf mutated YUL code
+7 -7
View File
@@ -31,13 +31,13 @@
#include <test/tools/ossfuzz/yulFuzzerCommon.h>
using namespace yul;
using namespace yul::test::yul_fuzzer;
using namespace std;
using namespace langutil;
using namespace dev;
using namespace yul::test;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::langutil;
using namespace solidity::yul;
using namespace solidity::yul::test;
using namespace solidity::yul::test::yul_fuzzer;
namespace
{
@@ -71,7 +71,7 @@ DEFINE_PROTO_FUZZER(Program const& _input)
AssemblyStack stack(
langutil::EVMVersion::berlin(),
AssemblyStack::Language::StrictAssembly,
dev::solidity::OptimiserSettings::full()
solidity::frontend::OptimiserSettings::full()
);
// Parse protobuf mutated YUL code