C++ namespace cleanup (except tests).

This commit is contained in:
Christian Parpart
2020-01-07 15:51:50 +01:00
committed by Daniel Kirchner
parent 8385256bdc
commit 6b23412fae
403 changed files with 1656 additions and 1926 deletions
+2 -1
View File
@@ -54,7 +54,8 @@
#include <liblangutil/Exceptions.h>
using namespace std;
using namespace langutil;
using namespace solidity;
using namespace solidity::langutil;
char CharStream::advanceAndGet(size_t _chars)
{
+1 -1
View File
@@ -56,7 +56,7 @@
#include <string>
#include <tuple>
namespace langutil
namespace solidity::langutil
{
/**
+1 -1
View File
@@ -14,7 +14,7 @@
#pragma once
namespace langutil
namespace solidity::langutil
{
inline bool isDecimalDigit(char c)
+3 -2
View File
@@ -20,8 +20,9 @@
#include <liblangutil/EVMVersion.h>
using namespace langutil;
using namespace dev::eth;
using namespace solidity;
using namespace solidity::evmasm;
using namespace solidity::langutil;
bool EVMVersion::hasOpcode(Instruction _opcode) const
{
+2 -2
View File
@@ -28,7 +28,7 @@
#include <boost/operators.hpp>
namespace langutil
namespace solidity::langutil
{
/**
@@ -87,7 +87,7 @@ public:
bool hasChainID() const { return *this >= istanbul(); }
bool hasSelfBalance() const { return *this >= istanbul(); }
bool hasOpcode(dev::eth::Instruction _opcode) const;
bool hasOpcode(evmasm::Instruction _opcode) const;
/// Whether we have to retain the costs for the call opcode itself (false),
/// or whether we can just forward easily all remaining gas (true).
+6 -6
View File
@@ -25,8 +25,8 @@
#include <memory>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace solidity::langutil;
ErrorReporter& ErrorReporter::operator=(ErrorReporter const& _errorReporter)
{
@@ -67,7 +67,7 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, st
auto err = make_shared<Error>(_type);
*err <<
errinfo_sourceLocation(_location) <<
errinfo_comment(_description);
util::errinfo_comment(_description);
m_errorList.push_back(err);
}
@@ -81,7 +81,7 @@ void ErrorReporter::error(Error::Type _type, SourceLocation const& _location, Se
*err <<
errinfo_sourceLocation(_location) <<
errinfo_secondarySourceLocation(_secondaryLocation) <<
errinfo_comment(_description);
util::errinfo_comment(_description);
m_errorList.push_back(err);
}
@@ -100,7 +100,7 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type)
if (m_warningCount == c_maxWarningsAllowed)
{
auto err = make_shared<Error>(Error::Type::Warning);
*err << errinfo_comment("There are more than 256 warnings. Ignoring the rest.");
*err << util::errinfo_comment("There are more than 256 warnings. Ignoring the rest.");
m_errorList.push_back(err);
}
@@ -114,7 +114,7 @@ bool ErrorReporter::checkForExcessiveErrors(Error::Type _type)
if (m_errorCount > c_maxErrorsAllowed)
{
auto err = make_shared<Error>(Error::Type::Warning);
*err << errinfo_comment("There are more than 256 errors. Aborting.");
*err << util::errinfo_comment("There are more than 256 errors. Aborting.");
m_errorList.push_back(err);
BOOST_THROW_EXCEPTION(FatalError());
}
+2 -2
View File
@@ -30,7 +30,7 @@
#include <boost/range/adaptor/filtered.hpp>
namespace langutil
namespace solidity::langutil
{
class ErrorReporter
@@ -98,7 +98,7 @@ public:
auto filterEmpty = boost::adaptors::filtered([](std::string const& _s) { return !_s.empty(); });
std::string errorStr = dev::joinHumanReadable(descs | filterEmpty, " ");
std::string errorStr = util::joinHumanReadable(descs | filterEmpty, " ");
error(Error::Type::TypeError, _location, errorStr);
}
+4 -4
View File
@@ -23,8 +23,8 @@
#include <liblangutil/Exceptions.h>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace solidity::langutil;
Error::Error(Type _type, SourceLocation const& _location, string const& _description):
m_type(_type)
@@ -54,7 +54,7 @@ Error::Error(Type _type, SourceLocation const& _location, string const& _descrip
if (!_location.isEmpty())
*this << errinfo_sourceLocation(_location);
if (!_description.empty())
*this << errinfo_comment(_description);
*this << util::errinfo_comment(_description);
}
Error::Error(Error::Type _type, std::string const& _description, SourceLocation const& _location):
@@ -62,5 +62,5 @@ Error::Error(Error::Type _type, std::string const& _description, SourceLocation
{
if (!_location.isEmpty())
*this << errinfo_sourceLocation(_location);
*this << errinfo_comment(_description);
*this << util::errinfo_comment(_description);
}
+8 -8
View File
@@ -31,27 +31,27 @@
#include <libdevcore/CommonData.h>
#include <liblangutil/SourceLocation.h>
namespace langutil
namespace solidity::langutil
{
class Error;
using ErrorList = std::vector<std::shared_ptr<Error const>>;
struct CompilerError: virtual dev::Exception {};
struct InternalCompilerError: virtual dev::Exception {};
struct FatalError: virtual dev::Exception {};
struct UnimplementedFeatureError: virtual dev::Exception {};
struct CompilerError: virtual util::Exception {};
struct InternalCompilerError: virtual util::Exception {};
struct FatalError: virtual util::Exception {};
struct UnimplementedFeatureError: virtual util::Exception {};
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
#define solAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::langutil::InternalCompilerError, DESCRIPTION)
assertThrow(CONDITION, ::solidity::langutil::InternalCompilerError, DESCRIPTION)
#define solUnimplementedAssert(CONDITION, DESCRIPTION) \
assertThrow(CONDITION, ::langutil::UnimplementedFeatureError, DESCRIPTION)
assertThrow(CONDITION, ::solidity::langutil::UnimplementedFeatureError, DESCRIPTION)
#define solUnimplemented(DESCRIPTION) \
solUnimplementedAssert(false, DESCRIPTION)
class Error: virtual public dev::Exception
class Error: virtual public util::Exception
{
public:
enum class Type
+2 -1
View File
@@ -25,7 +25,8 @@
#include <liblangutil/ErrorReporter.h>
using namespace std;
using namespace langutil;
using namespace solidity;
using namespace solidity::langutil;
int ParserBase::position() const
{
+1 -1
View File
@@ -27,7 +27,7 @@
#include <memory>
#include <string>
namespace langutil
namespace solidity::langutil
{
class ErrorReporter;
+6 -8
View File
@@ -60,9 +60,10 @@
#include <tuple>
using namespace std;
using namespace langutil;
string langutil::to_string(ScannerError _errorCode)
namespace solidity::langutil {
string to_string(ScannerError _errorCode)
{
switch (_errorCode)
{
@@ -84,14 +85,11 @@ string langutil::to_string(ScannerError _errorCode)
}
ostream& langutil::operator<<(ostream& os, ScannerError _errorCode)
ostream& operator<<(ostream& os, ScannerError _errorCode)
{
return os << to_string(_errorCode);
}
namespace langutil
{
/// Scoped helper for literal recording. Automatically drops the literal
/// if aborting the scanning before it's complete.
enum LiteralType
@@ -132,8 +130,6 @@ private:
bool m_complete;
};
}
void Scanner::reset(CharStream _source)
{
m_source = make_shared<CharStream>(std::move(_source));
@@ -933,3 +929,5 @@ tuple<Token, unsigned, unsigned> Scanner::scanIdentifierOrKeyword()
literal.complete();
return TokenTraits::fromIdentifierOrKeyword(m_nextToken.literal);
}
} // namespace solidity::langutil
+1 -1
View File
@@ -61,7 +61,7 @@
#include <optional>
#include <iosfwd>
namespace langutil
namespace solidity::langutil
{
class AstRawString;
+2 -2
View File
@@ -25,8 +25,8 @@
#include <functional>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace solidity::langutil;
SemVerVersion::SemVerVersion(string const& _versionString)
{
+2 -2
View File
@@ -26,10 +26,10 @@
#include <string>
#include <vector>
namespace langutil
namespace solidity::langutil
{
class SemVerError: dev::Exception
class SemVerError: util::Exception
{
};
+2 -2
View File
@@ -31,9 +31,9 @@
#include <ostream>
#include <tuple>
namespace langutil
namespace solidity::langutil
{
struct SourceLocationError: virtual dev::Exception {};
struct SourceLocationError: virtual util::Exception {};
/**
* Representation of an interval of source positions.
+4 -4
View File
@@ -22,14 +22,14 @@
#include <iomanip>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace solidity::langutil;
SourceReferenceExtractor::Message SourceReferenceExtractor::extract(Exception const& _exception, string _category)
SourceReferenceExtractor::Message SourceReferenceExtractor::extract(util::Exception const& _exception, string _category)
{
SourceLocation const* location = boost::get_error_info<errinfo_sourceLocation>(_exception);
string const* message = boost::get_error_info<errinfo_comment>(_exception);
string const* message = boost::get_error_info<util::errinfo_comment>(_exception);
SourceReference primary = extract(location, message ? *message : "");
std::vector<SourceReference> secondary;
+3 -3
View File
@@ -21,12 +21,12 @@
#include <tuple>
#include <vector>
namespace dev
namespace solidity::util
{
struct Exception;
}
namespace langutil
namespace solidity::langutil
{
struct LineColumn
@@ -68,7 +68,7 @@ namespace SourceReferenceExtractor
std::vector<SourceReference> secondary;
};
Message extract(dev::Exception const& _exception, std::string _category);
Message extract(util::Exception const& _exception, std::string _category);
SourceReference extract(SourceLocation const* _location, std::string message = "");
}
+4 -3
View File
@@ -25,8 +25,9 @@
#include <liblangutil/Exceptions.h>
using namespace std;
using namespace dev;
using namespace langutil;
using namespace solidity;
using namespace solidity::util;
using namespace solidity::langutil;
void SourceReferenceFormatter::printSourceLocation(SourceLocation const* _location)
{
@@ -70,7 +71,7 @@ void SourceReferenceFormatter::printSourceName(SourceReference const& _ref)
m_stream << _ref.sourceName << ":" << (_ref.position.line + 1) << ":" << (_ref.position.column + 1) << ": ";
}
void SourceReferenceFormatter::printExceptionInformation(dev::Exception const& _exception, std::string const& _category)
void SourceReferenceFormatter::printExceptionInformation(util::Exception const& _exception, std::string const& _category)
{
printExceptionInformation(SourceReferenceExtractor::extract(_exception, _category));
}
+4 -4
View File
@@ -28,12 +28,12 @@
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceExtractor.h>
namespace dev
namespace solidity::util
{
struct Exception; // forward
}
namespace langutil
namespace solidity::langutil
{
struct SourceLocation;
class Scanner;
@@ -52,7 +52,7 @@ public:
virtual void printExceptionInformation(SourceReferenceExtractor::Message const& _msg);
virtual void printSourceLocation(SourceLocation const* _location);
virtual void printExceptionInformation(dev::Exception const& _exception, std::string const& _category);
virtual void printExceptionInformation(util::Exception const& _exception, std::string const& _category);
virtual void printErrorInformation(Error const& _error);
static std::string formatErrorInformation(Error const& _error)
@@ -64,7 +64,7 @@ public:
}
static std::string formatExceptionInformation(
dev::Exception const& _exception,
util::Exception const& _exception,
std::string const& _name
)
{
@@ -25,9 +25,10 @@
#include <iomanip>
using namespace std;
using namespace dev;
using namespace dev::formatting;
using namespace langutil;
using namespace solidity;
using namespace solidity::langutil;
using namespace solidity::util;
using namespace solidity::util::formatting;
AnsiColorized SourceReferenceFormatterHuman::normalColored() const
{
+10 -10
View File
@@ -29,12 +29,12 @@
#include <sstream>
#include <functional>
namespace dev
namespace solidity::util
{
struct Exception; // forward
}
namespace langutil
namespace solidity::langutil
{
struct SourceLocation;
@@ -52,7 +52,7 @@ public:
using SourceReferenceFormatter::printExceptionInformation;
static std::string formatExceptionInformation(
dev::Exception const& _exception,
util::Exception const& _exception,
std::string const& _name,
bool colored = false
)
@@ -65,13 +65,13 @@ public:
}
private:
dev::AnsiColorized normalColored() const;
dev::AnsiColorized frameColored() const;
dev::AnsiColorized errorColored() const;
dev::AnsiColorized messageColored() const;
dev::AnsiColorized secondaryColored() const;
dev::AnsiColorized highlightColored() const;
dev::AnsiColorized diagColored() const;
util::AnsiColorized normalColored() const;
util::AnsiColorized frameColored() const;
util::AnsiColorized errorColored() const;
util::AnsiColorized messageColored() const;
util::AnsiColorized secondaryColored() const;
util::AnsiColorized highlightColored() const;
util::AnsiColorized diagColored() const;
private:
bool m_colored;
+1 -2
View File
@@ -46,7 +46,7 @@
using namespace std;
namespace langutil
namespace solidity::langutil
{
void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _first, unsigned const& _second)
@@ -82,7 +82,6 @@ void ElementaryTypeNameToken::assertDetails(Token _baseType, unsigned const& _fi
namespace TokenTraits
{
char const* toString(Token tok)
{
switch (tok)
+1 -1
View File
@@ -50,7 +50,7 @@
#include <string>
#include <tuple>
namespace langutil
namespace solidity::langutil
{
// TOKEN_LIST takes a list of 3 macros M, all of which satisfy the