From 830d740359ac0d0187178b9c9abe1fd73fe3e73a Mon Sep 17 00:00:00 2001 From: shikharvashistha Date: Fri, 24 Sep 2021 04:29:28 +0000 Subject: [PATCH] Removed clang-formatting --- liblangutil/Exceptions.h | 49 +++++++++++------------- liblangutil/SourceReferenceFormatter.cpp | 36 ++++++++++------- 2 files changed, 45 insertions(+), 40 deletions(-) diff --git a/liblangutil/Exceptions.h b/liblangutil/Exceptions.h index a3e3adca3..f6833e587 100644 --- a/liblangutil/Exceptions.h +++ b/liblangutil/Exceptions.h @@ -23,44 +23,31 @@ #pragma once -#include +#include #include #include -#include +#include #include #include #include -#include -#include #include #include #include +#include namespace solidity::langutil { class Error; using ErrorList = std::vector>; -struct CompilerError: virtual util::Exception -{ -}; -struct StackTooDeepError: virtual CompilerError -{ -}; -struct InternalCompilerError: virtual util::Exception -{ -}; -struct FatalError: virtual util::Exception -{ -}; -struct UnimplementedFeatureError: virtual util::Exception -{ -}; -struct InvalidAstError: virtual util::Exception -{ -}; +struct CompilerError: virtual util::Exception {}; +struct StackTooDeepError: virtual CompilerError {}; +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. @@ -173,7 +160,7 @@ struct ErrorId bool operator!=(ErrorId const& _rhs) const { return !(*this == _rhs); } 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 { @@ -202,7 +189,8 @@ public: Type _type, std::string const& _description, SourceLocation const& _location = SourceLocation(), - SecondarySourceLocation const& _secondaryLocation = SecondarySourceLocation()); + SecondarySourceLocation const& _secondaryLocation = SecondarySourceLocation() + ); ErrorId errorId() const { return m_errorId; } Type type() const { return m_type; } @@ -226,9 +214,15 @@ public: 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) { @@ -248,7 +242,7 @@ public: return "Error"; } - static std::optional stringToSeverity(Severity _severity) + static std::optional stringToSeverity(Severity _severity) { return _severity ? std::optional{"Error, Warning, Info"} : std::nullopt; } @@ -273,4 +267,5 @@ private: Type m_type; std::string m_typeName; }; + } diff --git a/liblangutil/SourceReferenceFormatter.cpp b/liblangutil/SourceReferenceFormatter.cpp index 992a7c772..685f017f7 100644 --- a/liblangutil/SourceReferenceFormatter.cpp +++ b/liblangutil/SourceReferenceFormatter.cpp @@ -19,12 +19,12 @@ * Formatting functions for errors referencing positions and locations in the source. */ -#include +#include +#include #include #include -#include -#include #include +#include #include using namespace std; @@ -35,6 +35,7 @@ using namespace solidity::util::formatting; namespace { + std::string replaceNonTabs(std::string_view _utf8Input, char _filler) { 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) { - 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 { 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 { @@ -138,10 +148,11 @@ void SourceReferenceFormatter::printSourceLocation(SourceReference const& _ref) frameColored() << '|'; m_stream << ' ' << replaceNonTabs(text.substr(0, static_cast(_ref.startColumn)), ' '); - diagColored() - << (locationLength == 0 - ? "^" - : replaceNonTabs(text.substr(static_cast(_ref.startColumn), locationLength), '^')); + diagColored() << ( + locationLength == 0 ? + "^" : + replaceNonTabs(text.substr(static_cast(_ref.startColumn), locationLength), '^') + ); m_stream << '\n'; } else @@ -195,8 +206,7 @@ void SourceReferenceFormatter::printExceptionInformation(SourceReferenceExtracto m_stream << '\n'; } -void SourceReferenceFormatter::printExceptionInformation( - util::Exception const& _exception, std::string const& _severity) +void SourceReferenceFormatter::printExceptionInformation(util::Exception const& _exception, std::string const& _severity) { printExceptionInformation(SourceReferenceExtractor::extract(m_charStreamProvider, _exception, _severity)); } @@ -210,4 +220,4 @@ void SourceReferenceFormatter::printErrorInformation(ErrorList const& _errors) void SourceReferenceFormatter::printErrorInformation(Error const& _error) { printExceptionInformation(SourceReferenceExtractor::extract(m_charStreamProvider, _error)); -} +} \ No newline at end of file