mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Removed clang-formatting
This commit is contained in:
parent
58851e751b
commit
830d740359
@ -23,44 +23,31 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <liblangutil/SourceLocation.h>
|
#include <libsolutil/Exceptions.h>
|
||||||
#include <libsolutil/Assertions.h>
|
#include <libsolutil/Assertions.h>
|
||||||
#include <libsolutil/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
#include <libsolutil/Exceptions.h>
|
#include <liblangutil/SourceLocation.h>
|
||||||
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
#include <boost/preprocessor/facilities/empty.hpp>
|
#include <boost/preprocessor/facilities/empty.hpp>
|
||||||
#include <boost/preprocessor/facilities/overload.hpp>
|
#include <boost/preprocessor/facilities/overload.hpp>
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <optional>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace solidity::langutil
|
namespace solidity::langutil
|
||||||
{
|
{
|
||||||
class Error;
|
class Error;
|
||||||
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
using ErrorList = std::vector<std::shared_ptr<Error const>>;
|
||||||
|
|
||||||
struct CompilerError: virtual util::Exception
|
struct CompilerError: virtual util::Exception {};
|
||||||
{
|
struct StackTooDeepError: virtual CompilerError {};
|
||||||
};
|
struct InternalCompilerError: virtual util::Exception {};
|
||||||
struct StackTooDeepError: virtual CompilerError
|
struct FatalError: virtual util::Exception {};
|
||||||
{
|
struct UnimplementedFeatureError: virtual util::Exception {};
|
||||||
};
|
struct InvalidAstError: virtual util::Exception {};
|
||||||
struct InternalCompilerError: virtual util::Exception
|
|
||||||
{
|
|
||||||
};
|
|
||||||
struct FatalError: virtual util::Exception
|
|
||||||
{
|
|
||||||
};
|
|
||||||
struct UnimplementedFeatureError: virtual util::Exception
|
|
||||||
{
|
|
||||||
};
|
|
||||||
struct InvalidAstError: virtual util::Exception
|
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
|
/// Assertion that throws an InternalCompilerError containing the given description if it is not met.
|
||||||
@ -173,7 +160,7 @@ struct ErrorId
|
|||||||
bool operator!=(ErrorId const& _rhs) const { return !(*this == _rhs); }
|
bool operator!=(ErrorId const& _rhs) const { return !(*this == _rhs); }
|
||||||
bool operator<(ErrorId const& _rhs) const { return error < _rhs.error; }
|
bool operator<(ErrorId const& _rhs) const { return error < _rhs.error; }
|
||||||
};
|
};
|
||||||
constexpr ErrorId operator"" _error(unsigned long long _error) { return ErrorId{_error}; }
|
constexpr ErrorId operator"" _error(unsigned long long _error) { return ErrorId{ _error }; }
|
||||||
|
|
||||||
class Error: virtual public util::Exception
|
class Error: virtual public util::Exception
|
||||||
{
|
{
|
||||||
@ -202,7 +189,8 @@ public:
|
|||||||
Type _type,
|
Type _type,
|
||||||
std::string const& _description,
|
std::string const& _description,
|
||||||
SourceLocation const& _location = SourceLocation(),
|
SourceLocation const& _location = SourceLocation(),
|
||||||
SecondarySourceLocation const& _secondaryLocation = SecondarySourceLocation());
|
SecondarySourceLocation const& _secondaryLocation = SecondarySourceLocation()
|
||||||
|
);
|
||||||
|
|
||||||
ErrorId errorId() const { return m_errorId; }
|
ErrorId errorId() const { return m_errorId; }
|
||||||
Type type() const { return m_type; }
|
Type type() const { return m_type; }
|
||||||
@ -226,9 +214,15 @@ public:
|
|||||||
return Severity::Error;
|
return Severity::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isError(Severity _severity) { return _severity == Severity::Error; }
|
static bool isError(Severity _severity)
|
||||||
|
{
|
||||||
|
return _severity == Severity::Error;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isError(Type _type) { return isError(errorSeverity(_type)); }
|
static bool isError(Type _type)
|
||||||
|
{
|
||||||
|
return isError(errorSeverity(_type));
|
||||||
|
}
|
||||||
|
|
||||||
static bool containsErrors(ErrorList const& _list)
|
static bool containsErrors(ErrorList const& _list)
|
||||||
{
|
{
|
||||||
@ -248,7 +242,7 @@ public:
|
|||||||
return "Error";
|
return "Error";
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::optional<std::string> stringToSeverity(Severity _severity)
|
static std::optional<std::string> stringToSeverity(Severity _severity)
|
||||||
{
|
{
|
||||||
return _severity ? std::optional<std::string>{"Error, Warning, Info"} : std::nullopt;
|
return _severity ? std::optional<std::string>{"Error, Warning, Info"} : std::nullopt;
|
||||||
}
|
}
|
||||||
@ -273,4 +267,5 @@ private:
|
|||||||
Type m_type;
|
Type m_type;
|
||||||
std::string m_typeName;
|
std::string m_typeName;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
* Formatting functions for errors referencing positions and locations in the source.
|
* Formatting functions for errors referencing positions and locations in the source.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <iomanip>
|
#include <liblangutil/SourceReferenceFormatter.h>
|
||||||
|
#include <liblangutil/Exceptions.h>
|
||||||
#include <liblangutil/CharStream.h>
|
#include <liblangutil/CharStream.h>
|
||||||
#include <liblangutil/CharStreamProvider.h>
|
#include <liblangutil/CharStreamProvider.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
|
||||||
#include <liblangutil/SourceReferenceFormatter.h>
|
|
||||||
#include <libsolutil/UTF8.h>
|
#include <libsolutil/UTF8.h>
|
||||||
|
#include <iomanip>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -35,6 +35,7 @@ using namespace solidity::util::formatting;
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string replaceNonTabs(std::string_view _utf8Input, char _filler)
|
std::string replaceNonTabs(std::string_view _utf8Input, char _filler)
|
||||||
{
|
{
|
||||||
std::string output;
|
std::string output;
|
||||||
@ -48,17 +49,26 @@ std::string replaceNonTabs(std::string_view _utf8Input, char _filler)
|
|||||||
|
|
||||||
std::string SourceReferenceFormatter::formatErrorInformation(Error const& _error, CharStream const& _charStream)
|
std::string SourceReferenceFormatter::formatErrorInformation(Error const& _error, CharStream const& _charStream)
|
||||||
{
|
{
|
||||||
return formatErrorInformation(_error, SingletonCharStreamProvider(_charStream));
|
return formatErrorInformation(
|
||||||
|
_error,
|
||||||
|
SingletonCharStreamProvider(_charStream)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::normalColored() const { return AnsiColorized(m_stream, m_colored, {WHITE}); }
|
AnsiColorized SourceReferenceFormatter::normalColored() const
|
||||||
|
{
|
||||||
|
return AnsiColorized(m_stream, m_colored, {WHITE});
|
||||||
|
}
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::frameColored() const
|
AnsiColorized SourceReferenceFormatter::frameColored() const
|
||||||
{
|
{
|
||||||
return AnsiColorized(m_stream, m_colored, {BOLD, BLUE});
|
return AnsiColorized(m_stream, m_colored, {BOLD, BLUE});
|
||||||
}
|
}
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::errorColored() const { return AnsiColorized(m_stream, m_colored, {BOLD, RED}); }
|
AnsiColorized SourceReferenceFormatter::errorColored() const
|
||||||
|
{
|
||||||
|
return AnsiColorized(m_stream, m_colored, {BOLD, RED});
|
||||||
|
}
|
||||||
|
|
||||||
AnsiColorized SourceReferenceFormatter::infoColored() const
|
AnsiColorized SourceReferenceFormatter::infoColored() const
|
||||||
{
|
{
|
||||||
@ -138,10 +148,11 @@ void SourceReferenceFormatter::printSourceLocation(SourceReference const& _ref)
|
|||||||
frameColored() << '|';
|
frameColored() << '|';
|
||||||
|
|
||||||
m_stream << ' ' << replaceNonTabs(text.substr(0, static_cast<size_t>(_ref.startColumn)), ' ');
|
m_stream << ' ' << replaceNonTabs(text.substr(0, static_cast<size_t>(_ref.startColumn)), ' ');
|
||||||
diagColored()
|
diagColored() << (
|
||||||
<< (locationLength == 0
|
locationLength == 0 ?
|
||||||
? "^"
|
"^" :
|
||||||
: replaceNonTabs(text.substr(static_cast<size_t>(_ref.startColumn), locationLength), '^'));
|
replaceNonTabs(text.substr(static_cast<size_t>(_ref.startColumn), locationLength), '^')
|
||||||
|
);
|
||||||
m_stream << '\n';
|
m_stream << '\n';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -195,8 +206,7 @@ void SourceReferenceFormatter::printExceptionInformation(SourceReferenceExtracto
|
|||||||
m_stream << '\n';
|
m_stream << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourceReferenceFormatter::printExceptionInformation(
|
void SourceReferenceFormatter::printExceptionInformation(util::Exception const& _exception, std::string const& _severity)
|
||||||
util::Exception const& _exception, std::string const& _severity)
|
|
||||||
{
|
{
|
||||||
printExceptionInformation(SourceReferenceExtractor::extract(m_charStreamProvider, _exception, _severity));
|
printExceptionInformation(SourceReferenceExtractor::extract(m_charStreamProvider, _exception, _severity));
|
||||||
}
|
}
|
||||||
@ -210,4 +220,4 @@ void SourceReferenceFormatter::printErrorInformation(ErrorList const& _errors)
|
|||||||
void SourceReferenceFormatter::printErrorInformation(Error const& _error)
|
void SourceReferenceFormatter::printErrorInformation(Error const& _error)
|
||||||
{
|
{
|
||||||
printExceptionInformation(SourceReferenceExtractor::extract(m_charStreamProvider, _error));
|
printExceptionInformation(SourceReferenceExtractor::extract(m_charStreamProvider, _error));
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user