mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #10855 from ethereum/clang-tidy-fixes-solgen
Solidity fuzzer: Clang tidy suggested fixes in Solidity generator
This commit is contained in:
commit
b5525668de
@ -62,7 +62,7 @@ struct GenerationProbability
|
|||||||
{
|
{
|
||||||
/// @returns an unsigned integer in the range [1, @param _n] chosen
|
/// @returns an unsigned integer in the range [1, @param _n] chosen
|
||||||
/// uniformly at random.
|
/// uniformly at random.
|
||||||
static size_t distributionOneToN(size_t _n, std::shared_ptr<RandomEngine> _rand)
|
static size_t distributionOneToN(size_t _n, std::shared_ptr<RandomEngine> const& _rand)
|
||||||
{
|
{
|
||||||
return Distribution(1, _n)(*_rand);
|
return Distribution(1, _n)(*_rand);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ struct GeneratorVisitor
|
|||||||
|
|
||||||
struct GeneratorBase
|
struct GeneratorBase
|
||||||
{
|
{
|
||||||
GeneratorBase(std::shared_ptr<SolidityGenerator> _mutator);
|
explicit GeneratorBase(std::shared_ptr<SolidityGenerator> _mutator);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<T> generator()
|
std::shared_ptr<T> generator()
|
||||||
{
|
{
|
||||||
@ -141,7 +141,7 @@ struct GeneratorBase
|
|||||||
class TestCaseGenerator: public GeneratorBase
|
class TestCaseGenerator: public GeneratorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestCaseGenerator(std::shared_ptr<SolidityGenerator> _mutator):
|
explicit TestCaseGenerator(std::shared_ptr<SolidityGenerator> _mutator):
|
||||||
GeneratorBase(std::move(_mutator)),
|
GeneratorBase(std::move(_mutator)),
|
||||||
m_numSourceUnits(0)
|
m_numSourceUnits(0)
|
||||||
{}
|
{}
|
||||||
@ -152,7 +152,11 @@ public:
|
|||||||
return "Test case generator";
|
return "Test case generator";
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::string path() const
|
/// Returns a new source path name that is formed by concatenating
|
||||||
|
/// a static prefix @name m_sourceUnitNamePrefix, a monotonically
|
||||||
|
/// increasing counter starting from 0 and the postfix (extension)
|
||||||
|
/// ".sol".
|
||||||
|
[[nodiscard]] std::string path() const
|
||||||
{
|
{
|
||||||
return m_sourceUnitNamePrefix + std::to_string(m_numSourceUnits) + ".sol";
|
return m_sourceUnitNamePrefix + std::to_string(m_numSourceUnits) + ".sol";
|
||||||
}
|
}
|
||||||
@ -167,7 +171,7 @@ private:
|
|||||||
class SourceUnitGenerator: public GeneratorBase
|
class SourceUnitGenerator: public GeneratorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SourceUnitGenerator(std::shared_ptr<SolidityGenerator> _mutator):
|
explicit SourceUnitGenerator(std::shared_ptr<SolidityGenerator> _mutator):
|
||||||
GeneratorBase(std::move(_mutator))
|
GeneratorBase(std::move(_mutator))
|
||||||
{}
|
{}
|
||||||
void setup() override;
|
void setup() override;
|
||||||
@ -178,7 +182,7 @@ public:
|
|||||||
class PragmaGenerator: public GeneratorBase
|
class PragmaGenerator: public GeneratorBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PragmaGenerator(std::shared_ptr<SolidityGenerator> _mutator):
|
explicit PragmaGenerator(std::shared_ptr<SolidityGenerator> _mutator):
|
||||||
GeneratorBase(std::move(_mutator))
|
GeneratorBase(std::move(_mutator))
|
||||||
{}
|
{}
|
||||||
std::string visit() override;
|
std::string visit() override;
|
||||||
@ -190,8 +194,6 @@ class SolidityGenerator: public std::enable_shared_from_this<SolidityGenerator>
|
|||||||
public:
|
public:
|
||||||
explicit SolidityGenerator(unsigned _seed);
|
explicit SolidityGenerator(unsigned _seed);
|
||||||
|
|
||||||
/// Returns a multi-source test case.
|
|
||||||
std::string visit();
|
|
||||||
/// Returns the generator of type @param T.
|
/// Returns the generator of type @param T.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
std::shared_ptr<T> generator();
|
std::shared_ptr<T> generator();
|
||||||
|
Loading…
Reference in New Issue
Block a user