Removed clang-formatting

This commit is contained in:
shikharvashistha 2021-09-24 04:29:28 +00:00 committed by Kamil Śliwak
parent 58851e751b
commit 830d740359
2 changed files with 45 additions and 40 deletions

View File

@ -23,44 +23,31 @@
#pragma once
#include <liblangutil/SourceLocation.h>
#include <libsolutil/Exceptions.h>
#include <libsolutil/Assertions.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/Exceptions.h>
#include <liblangutil/SourceLocation.h>
#include <boost/preprocessor/cat.hpp>
#include <boost/preprocessor/facilities/empty.hpp>
#include <boost/preprocessor/facilities/overload.hpp>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include <memory>
namespace solidity::langutil
{
class Error;
using ErrorList = std::vector<std::shared_ptr<Error const>>;
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)
{
@ -273,4 +267,5 @@ private:
Type m_type;
std::string m_typeName;
};
}

View File

@ -19,12 +19,12 @@
* 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/CharStreamProvider.h>
#include <liblangutil/Exceptions.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <libsolutil/UTF8.h>
#include <iomanip>
#include <string_view>
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<size_t>(_ref.startColumn)), ' ');
diagColored()
<< (locationLength == 0
? "^"
: replaceNonTabs(text.substr(static_cast<size_t>(_ref.startColumn), locationLength), '^'));
diagColored() << (
locationLength == 0 ?
"^" :
replaceNonTabs(text.substr(static_cast<size_t>(_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));
}