mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
C++ namespace cleanup (except tests).
This commit is contained in:
committed by
Daniel Kirchner
parent
8385256bdc
commit
6b23412fae
@@ -27,8 +27,8 @@
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
void ConstantEvaluator::endVisit(UnaryOperation const& _operation)
|
||||
{
|
||||
|
||||
@@ -24,14 +24,12 @@
|
||||
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
class TypeChecker;
|
||||
@@ -72,4 +70,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -361,10 +361,10 @@ void ContractLevelChecker::checkExternalTypeClashes(ContractDefinition const& _c
|
||||
|
||||
void ContractLevelChecker::checkHashCollisions(ContractDefinition const& _contract)
|
||||
{
|
||||
set<FixedHash<4>> hashes;
|
||||
set<util::FixedHash<4>> hashes;
|
||||
for (auto const& it: _contract.interfaceFunctionList())
|
||||
{
|
||||
FixedHash<4> const& hash = it.first;
|
||||
util::FixedHash<4> const& hash = it.first;
|
||||
if (hashes.count(hash))
|
||||
m_errorReporter.typeError(
|
||||
_contract.location(),
|
||||
|
||||
@@ -28,14 +28,12 @@
|
||||
#include <functional>
|
||||
#include <set>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -90,4 +88,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <boost/range/algorithm/sort.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
bool ControlFlowAnalyzer::analyze(ASTNode const& _astRoot)
|
||||
{
|
||||
@@ -151,7 +151,7 @@ void ControlFlowAnalyzer::checkUninitializedAccess(CFGNode const* _entry, CFGNod
|
||||
void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const* _exit, CFGNode const* _revert) const
|
||||
{
|
||||
// collect all nodes reachable from the entry point
|
||||
std::set<CFGNode const*> reachable = BreadthFirstSearch<CFGNode const*>{{_entry}}.run(
|
||||
std::set<CFGNode const*> reachable = util::BreadthFirstSearch<CFGNode const*>{{_entry}}.run(
|
||||
[](CFGNode const* _node, auto&& _addChild) {
|
||||
for (CFGNode const* exit: _node->exits)
|
||||
_addChild(exit);
|
||||
@@ -161,7 +161,7 @@ void ControlFlowAnalyzer::checkUnreachable(CFGNode const* _entry, CFGNode const*
|
||||
// traverse all paths backwards from exit and revert
|
||||
// and extract (valid) source locations of unreachable nodes into sorted set
|
||||
std::set<SourceLocation> unreachable;
|
||||
BreadthFirstSearch<CFGNode const*>{{_exit, _revert}}.run(
|
||||
util::BreadthFirstSearch<CFGNode const*>{{_exit, _revert}}.run(
|
||||
[&](CFGNode const* _node, auto&& _addChild) {
|
||||
if (!reachable.count(_node) && !_node->location.isEmpty())
|
||||
unreachable.insert(_node->location);
|
||||
|
||||
@@ -20,9 +20,7 @@
|
||||
#include <libsolidity/analysis/ControlFlowGraph.h>
|
||||
#include <set>
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
class ControlFlowAnalyzer: private ASTConstVisitor
|
||||
@@ -47,4 +45,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
#include <libsolidity/analysis/ControlFlowBuilder.h>
|
||||
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
using namespace std;
|
||||
|
||||
ControlFlowBuilder::ControlFlowBuilder(CFG::NodeContainer& _nodeContainer, FunctionFlow const& _functionFlow):
|
||||
|
||||
@@ -24,8 +24,7 @@
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
namespace dev {
|
||||
namespace solidity {
|
||||
namespace solidity::frontend {
|
||||
|
||||
/** Helper class that builds the control flow of a function or modifier.
|
||||
* Modifiers are not yet applied to the functions. This is done in a second
|
||||
@@ -161,4 +160,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
#include <algorithm>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
bool CFG::constructFlow(ASTNode const& _astRoot)
|
||||
{
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -154,4 +152,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include <libdevcore/StringUtils.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
Declaration const* DeclarationContainer::conflictingDeclaration(
|
||||
Declaration const& _declaration,
|
||||
@@ -118,7 +118,7 @@ bool DeclarationContainer::registerDeclaration(
|
||||
return false;
|
||||
|
||||
vector<Declaration const*>& decls = _invisible ? m_invisibleDeclarations[*_name] : m_declarations[*_name];
|
||||
if (!contains(decls, &_declaration))
|
||||
if (!util::contains(decls, &_declaration))
|
||||
decls.push_back(&_declaration);
|
||||
return true;
|
||||
}
|
||||
@@ -148,13 +148,13 @@ vector<ASTString> DeclarationContainer::similarNames(ASTString const& _name) con
|
||||
for (auto const& declaration: m_declarations)
|
||||
{
|
||||
string const& declarationName = declaration.first;
|
||||
if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
||||
if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
||||
similar.push_back(declarationName);
|
||||
}
|
||||
for (auto const& declaration: m_invisibleDeclarations)
|
||||
{
|
||||
string const& declarationName = declaration.first;
|
||||
if (stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
||||
if (util::stringWithinDistance(_name, declarationName, maximumEditDistance, MAXIMUM_LENGTH_THRESHOLD))
|
||||
similar.push_back(declarationName);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -76,4 +74,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
#include <liblangutil/ErrorReporter.h>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
bool DocStringAnalyser::analyseDocStrings(SourceUnit const& _sourceUnit)
|
||||
{
|
||||
|
||||
@@ -25,14 +25,12 @@
|
||||
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -82,4 +80,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,9 +30,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
inline vector<shared_ptr<MagicVariableDeclaration const>> constructMagicVariables()
|
||||
@@ -112,4 +110,3 @@ MagicVariableDeclaration const* GlobalContext::currentSuper() const
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,9 +29,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
class Type; // forward
|
||||
@@ -61,4 +59,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,11 +29,9 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
NameAndTypeResolver::NameAndTypeResolver(
|
||||
@@ -244,7 +242,7 @@ vector<Declaration const*> NameAndTypeResolver::cleanedDeclarations(
|
||||
|
||||
void NameAndTypeResolver::warnVariablesNamedLikeInstructions()
|
||||
{
|
||||
for (auto const& instruction: dev::eth::c_instructions)
|
||||
for (auto const& instruction: evmasm::c_instructions)
|
||||
{
|
||||
string const instructionName{boost::algorithm::to_lower_copy(instruction.first)};
|
||||
auto declarations = nameFromCurrentScope(instructionName, true);
|
||||
@@ -460,7 +458,7 @@ vector<_T const*> NameAndTypeResolver::cThreeMerge(list<list<_T const*>>& _toMer
|
||||
|
||||
string NameAndTypeResolver::similarNameSuggestions(ASTString const& _name) const
|
||||
{
|
||||
return quotedAlternativesList(m_currentScope->similarNames(_name));
|
||||
return util::quotedAlternativesList(m_currentScope->similarNames(_name));
|
||||
}
|
||||
|
||||
DeclarationRegistrationHelper::DeclarationRegistrationHelper(
|
||||
@@ -786,4 +784,3 @@ string DeclarationRegistrationHelper::currentCanonicalName() const
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,14 +35,12 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -214,4 +212,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,9 +32,13 @@
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::frontend;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
using solidity::util::GenericVisitor;
|
||||
using solidity::util::contains_if;
|
||||
using solidity::util::joinHumanReadable;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -29,15 +29,13 @@
|
||||
#include <variant>
|
||||
#include <optional>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
struct SourceLocation;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
class FunctionType;
|
||||
class ModifierType;
|
||||
@@ -193,4 +191,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
bool PostTypeChecker::check(ASTNode const& _astRoot)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker
|
||||
|
||||
VariableDeclaration const* findCycle(VariableDeclaration const& _startingFrom)
|
||||
{
|
||||
auto visitor = [&](VariableDeclaration const& _variable, CycleDetector<VariableDeclaration>& _cycleDetector, size_t _depth)
|
||||
auto visitor = [&](VariableDeclaration const& _variable, util::CycleDetector<VariableDeclaration>& _cycleDetector, size_t _depth)
|
||||
{
|
||||
if (_depth >= 256)
|
||||
m_errorReporter.fatalDeclarationError(_variable.location(), "Variable definition exhausting cyclic dependency validator.");
|
||||
@@ -148,7 +148,7 @@ struct ConstStateVarCircularReferenceChecker: public PostTypeChecker::Checker
|
||||
if (_cycleDetector.run(*v))
|
||||
return;
|
||||
};
|
||||
return CycleDetector<VariableDeclaration>(visitor).run(_startingFrom);
|
||||
return util::CycleDetector<VariableDeclaration>(visitor).run(_startingFrom);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -23,15 +23,13 @@
|
||||
#include <libsolidity/ast/ASTForward.h>
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
struct SourceLocation;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -93,4 +91,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,11 +40,9 @@
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
|
||||
using namespace std;
|
||||
using namespace langutil;
|
||||
using namespace solidity::langutil;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
bool ReferencesResolver::resolve(ASTNode const& _root)
|
||||
@@ -405,7 +403,7 @@ void ReferencesResolver::endVisit(VariableDeclaration const& _variable)
|
||||
else
|
||||
{
|
||||
errorString = "Data location must be " +
|
||||
joinHumanReadable(
|
||||
util::joinHumanReadable(
|
||||
allowedDataLocations | boost::adaptors::transformed(locationToString),
|
||||
", ",
|
||||
" or "
|
||||
@@ -501,4 +499,3 @@ void ReferencesResolver::fatalDeclarationError(SourceLocation const& _location,
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,13 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
struct SourceLocation;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
class NameAndTypeResolver;
|
||||
@@ -110,4 +108,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
#include <memory>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
/**
|
||||
* Helper class that determines whether a contract's constructor uses inline assembly.
|
||||
*/
|
||||
class dev::solidity::ConstructorUsesAssembly
|
||||
class solidity::frontend::ConstructorUsesAssembly
|
||||
{
|
||||
public:
|
||||
/// @returns true if and only if the contract's or any of its bases' constructors
|
||||
|
||||
@@ -28,14 +28,12 @@
|
||||
#include <libsolidity/ast/ASTForward.h>
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
class ConstructorUsesAssembly;
|
||||
@@ -102,4 +100,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,9 +34,9 @@
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
|
||||
bool SyntaxChecker::checkSyntax(ASTNode const& _astRoot)
|
||||
|
||||
@@ -23,14 +23,12 @@
|
||||
#include <libsolidity/ast/ASTForward.h>
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -109,4 +107,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,10 @@
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::util;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
bool TypeChecker::typeSupportedByOldABIEncoder(Type const& _type, bool _isLibraryCall)
|
||||
{
|
||||
|
||||
@@ -29,14 +29,12 @@
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
#include <libsolidity/ast/Types.h>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
/**
|
||||
@@ -179,4 +177,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
#include <variant>
|
||||
|
||||
using namespace std;
|
||||
using namespace dev;
|
||||
using namespace langutil;
|
||||
using namespace dev::solidity;
|
||||
using namespace solidity;
|
||||
using namespace solidity::langutil;
|
||||
using namespace solidity::frontend;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -110,11 +110,11 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
void checkInstruction(SourceLocation _location, dev::eth::Instruction _instruction)
|
||||
void checkInstruction(SourceLocation _location, evmasm::Instruction _instruction)
|
||||
{
|
||||
if (eth::SemanticInformation::invalidInViewFunctions(_instruction))
|
||||
if (evmasm::SemanticInformation::invalidInViewFunctions(_instruction))
|
||||
m_reportMutability(StateMutability::NonPayable, _location);
|
||||
else if (eth::SemanticInformation::invalidInPureFunctions(_instruction))
|
||||
else if (evmasm::SemanticInformation::invalidInPureFunctions(_instruction))
|
||||
m_reportMutability(StateMutability::View, _location);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,15 +25,13 @@
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
namespace langutil
|
||||
namespace solidity::langutil
|
||||
{
|
||||
class ErrorReporter;
|
||||
struct SourceLocation;
|
||||
}
|
||||
|
||||
namespace dev
|
||||
{
|
||||
namespace solidity
|
||||
namespace solidity::frontend
|
||||
{
|
||||
|
||||
class ViewPureChecker: private ASTConstVisitor
|
||||
@@ -82,4 +80,3 @@ private:
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user