1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +00:00

Everywhere: Rename ASSERT => VERIFY

(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
This commit is contained in:
Andreas Kling 2021-02-23 20:42:32 +01:00
parent b33a6a443e
commit 5d180d1f99
725 changed files with 3448 additions and 3448 deletions

View file

@ -42,7 +42,7 @@ const char* OpCode::name(OpCodeId opcode_id)
ENUMERATE_OPCODES
#undef __ENUMERATE_OPCODE
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return "<Unknown>";
}
}
@ -61,7 +61,7 @@ const char* execution_result_name(ExecutionResult result)
ENUMERATE_EXECUTION_RESULTS
#undef __ENUMERATE_EXECUTION_RESULT
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return "<Unknown>";
}
}
@ -75,7 +75,7 @@ const char* boundary_check_type_name(BoundaryCheckType ty)
ENUMERATE_BOUNDARY_CHECK_TYPES
#undef __ENUMERATE_BOUNDARY_CHECK_TYPE
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return "<Unknown>";
}
}
@ -89,7 +89,7 @@ const char* character_compare_type_name(CharacterCompareType ch_compare_type)
ENUMERATE_CHARACTER_COMPARE_TYPES
#undef __ENUMERATE_CHARACTER_COMPARE_TYPE
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return "<Unknown>";
}
}
@ -103,7 +103,7 @@ static const char* character_class_name(CharClass ch_class)
ENUMERATE_CHARACTER_CLASSES
#undef __ENUMERATE_CHARACTER_CLASS
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return "<Unknown>";
}
}
@ -222,7 +222,7 @@ ALWAYS_INLINE ExecutionResult OpCode_GoBack::execute(const MatchInput&, MatchSta
ALWAYS_INLINE ExecutionResult OpCode_FailForks::execute(const MatchInput& input, MatchState&, MatchOutput&) const
{
ASSERT(count() > 0);
VERIFY(count() > 0);
input.fail_counter += count() - 1;
return ExecutionResult::Failed_ExecuteLowPrioForks;
@ -291,7 +291,7 @@ ALWAYS_INLINE ExecutionResult OpCode_CheckBoundary::execute(const MatchInput& in
return ExecutionResult::Failed_ExecuteLowPrioForks;
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
ALWAYS_INLINE ExecutionResult OpCode_CheckEnd::execute(const MatchInput& input, MatchState& state, MatchOutput&) const
@ -335,7 +335,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightCaptureGroup::execute(const MatchI
if (start_position < match.column)
return ExecutionResult::Continue;
ASSERT(start_position + length <= input.view.length());
VERIFY(start_position + length <= input.view.length());
auto view = input.view.substring_view(start_position, length);
@ -371,11 +371,11 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightNamedCaptureGroup::execute(const M
auto& map = output.named_capture_group_matches.at(input.match_index);
if constexpr (REGEX_DEBUG) {
ASSERT(start_position + length <= input.view.length());
VERIFY(start_position + length <= input.view.length());
dbgln("Save named capture group with name={} and content='{}'", capture_group_name, input.view.substring_view(start_position, length));
}
ASSERT(start_position + length <= input.view.length());
VERIFY(start_position + length <= input.view.length());
auto view = input.view.substring_view(start_position, length);
if (input.regex_options & AllFlags::StringCopyMatches) {
map.set(capture_group_name, { view.to_string(), input.line, start_position, input.global_offset + start_position }); // create a copy of the original string
@ -420,7 +420,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(const MatchInput& input, M
else if (compare_type == CharacterCompareType::TemporaryInverse) {
// If "TemporaryInverse" is given, negate the current inversion state only for the next opcode.
// it follows that this cannot be the last compare element.
ASSERT(i != arguments_count() - 1);
VERIFY(i != arguments_count() - 1);
temporary_inverse = true;
reset_temp_inverse = false;
@ -439,11 +439,11 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(const MatchInput& input, M
if (input.view.length() - state.string_position < 1)
return ExecutionResult::Failed_ExecuteLowPrioForks;
ASSERT(!current_inversion_state());
VERIFY(!current_inversion_state());
++state.string_position;
} else if (compare_type == CharacterCompareType::String) {
ASSERT(!current_inversion_state());
VERIFY(!current_inversion_state());
const auto& length = m_bytecode->at(offset++);
StringBuilder str_builder;
@ -511,7 +511,7 @@ ALWAYS_INLINE ExecutionResult OpCode_Compare::execute(const MatchInput& input, M
} else {
fprintf(stderr, "Undefined comparison: %i\n", (int)compare_type);
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
break;
}
}

View file

@ -161,10 +161,10 @@ public:
ByteCode arguments;
for (auto& value : pairs) {
ASSERT(value.type != CharacterCompareType::RangeExpressionDummy);
ASSERT(value.type != CharacterCompareType::Undefined);
ASSERT(value.type != CharacterCompareType::String);
ASSERT(value.type != CharacterCompareType::NamedReference);
VERIFY(value.type != CharacterCompareType::RangeExpressionDummy);
VERIFY(value.type != CharacterCompareType::Undefined);
VERIFY(value.type != CharacterCompareType::String);
VERIFY(value.type != CharacterCompareType::NamedReference);
arguments.append((ByteCodeValueType)value.type);
if (value.type != CharacterCompareType::Inverse && value.type != CharacterCompareType::AnyChar && value.type != CharacterCompareType::TemporaryInverse)
@ -327,7 +327,7 @@ public:
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
void insert_bytecode_alternation(ByteCode&& left, ByteCode&& right)
@ -503,7 +503,7 @@ public:
ALWAYS_INLINE ByteCodeValueType argument(size_t offset) const
{
ASSERT(state().instruction_position + offset <= m_bytecode->size());
VERIFY(state().instruction_position + offset <= m_bytecode->size());
return m_bytecode->at(state().instruction_position + 1 + offset);
}
@ -526,7 +526,7 @@ public:
ALWAYS_INLINE const MatchState& state() const
{
ASSERT(m_state.has_value());
VERIFY(m_state.has_value());
return *m_state.value();
}
@ -809,28 +809,28 @@ ALWAYS_INLINE bool is<OpCode_Compare>(const OpCode& opcode)
template<typename T>
ALWAYS_INLINE const T& to(const OpCode& opcode)
{
ASSERT(is<T>(opcode));
VERIFY(is<T>(opcode));
return static_cast<const T&>(opcode);
}
template<typename T>
ALWAYS_INLINE T* to(OpCode* opcode)
{
ASSERT(is<T>(opcode));
VERIFY(is<T>(opcode));
return static_cast<T*>(opcode);
}
template<typename T>
ALWAYS_INLINE const T* to(const OpCode* opcode)
{
ASSERT(is<T>(opcode));
VERIFY(is<T>(opcode));
return static_cast<const T*>(opcode);
}
template<typename T>
ALWAYS_INLINE T& to(OpCode& opcode)
{
ASSERT(is<T>(opcode));
VERIFY(is<T>(opcode));
return static_cast<T&>(opcode);
}

View file

@ -41,7 +41,7 @@ const char* Token::name(const TokenType type)
ENUMERATE_REGEX_TOKENS
#undef __ENUMERATE_REGEX_TOKEN
default:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
return "<Unknown>";
}
}
@ -68,7 +68,7 @@ void Lexer::back(size_t offset)
if (offset == m_position + 1)
offset = m_position; // 'position == 0' occurs twice.
ASSERT(offset <= m_position);
VERIFY(offset <= m_position);
if (!offset)
return;
m_position -= offset;
@ -122,7 +122,7 @@ Token Lexer::next()
};
auto commit_token = [&](auto type) -> Token& {
ASSERT(token_start_position + m_previous_position - token_start_position + 1 <= m_source.length());
VERIFY(token_start_position + m_previous_position - token_start_position + 1 <= m_source.length());
auto substring = m_source.substring_view(token_start_position, m_previous_position - token_start_position + 1);
m_current_token = Token(type, token_start_position, substring);
return m_current_token;

View file

@ -64,13 +64,13 @@ public:
const StringView& u8view() const
{
ASSERT(m_u8view.has_value());
VERIFY(m_u8view.has_value());
return m_u8view.value();
};
const Utf32View& u32view() const
{
ASSERT(m_u32view.has_value());
VERIFY(m_u32view.has_value());
return m_u32view.value();
};

View file

@ -104,7 +104,7 @@ RegexResult Matcher<Parser>::match(const Vector<RegexStringView> views, Optional
output.operations = 0;
if (input.regex_options.has_flag_set(AllFlags::Internal_Stateful))
ASSERT(views.size() == 1);
VERIFY(views.size() == 1);
if (c_match_preallocation_count) {
output.matches.ensure_capacity(c_match_preallocation_count);
@ -130,7 +130,7 @@ RegexResult Matcher<Parser>::match(const Vector<RegexStringView> views, Optional
if (output.matches.size() == input.match_index)
output.matches.empend();
ASSERT(start_position + state.string_position - start_position <= input.view.length());
VERIFY(start_position + state.string_position - start_position <= input.view.length());
if (input.regex_options.has_flag_set(AllFlags::StringCopyMatches)) {
output.matches.at(input.match_index) = { input.view.substring_view(start_position, state.string_position - start_position).to_string(), input.line, start_position, input.global_offset + start_position };
} else { // let the view point to the original string ...
@ -360,7 +360,7 @@ Optional<bool> Matcher<Parser>::execute(const MatchInput& input, MatchState& sta
}
}
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
template<class Parser>

View file

@ -313,7 +313,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_bracket_expression(ByteCode& stack
// FIXME: Parse collating element, this is needed when we have locale support
// This could have impact on length parameter, I guess.
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
consume(TokenType::Period, Error::InvalidCollationElement);
consume(TokenType::RightBracket, Error::MismatchingBracket);
@ -322,7 +322,7 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_bracket_expression(ByteCode& stack
consume();
// FIXME: Parse collating element, this is needed when we have locale support
// This could have impact on length parameter, I guess.
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
consume(TokenType::EqualSign, Error::InvalidCollationElement);
consume(TokenType::RightBracket, Error::MismatchingBracket);
@ -529,16 +529,16 @@ ALWAYS_INLINE bool PosixExtendedParser::parse_sub_expression(ByteCode& stack, si
} else if (match(TokenType::EqualSign)) { // positive lookahead
consume();
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
} else if (consume("!")) { // negative lookahead
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
} else if (consume("<")) {
if (match(TokenType::EqualSign)) { // positive lookbehind
consume();
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
if (consume("!")) // negative lookbehind
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
} else {
return set_error(Error::InvalidRepetitionMarker);
}
@ -926,7 +926,7 @@ bool ECMA262Parser::parse_quantifier(ByteCode& stack, size_t& match_length_minim
match_length_minimum *= repeat_min.value();
break;
case Repetition::None:
ASSERT_NOT_REACHED();
VERIFY_NOT_REACHED();
}
return true;
@ -1370,8 +1370,8 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
return false;
}
ASSERT(!first_atom.value().is_negated);
ASSERT(!second_atom.value().is_negated);
VERIFY(!first_atom.value().is_negated);
VERIFY(!second_atom.value().is_negated);
ranges.empend(CompareTypeAndValuePair { CharacterCompareType::CharRange, CharRange { first_atom.value().code_point, second_atom.value().code_point } });
continue;
@ -1386,7 +1386,7 @@ bool ECMA262Parser::parse_nonempty_class_ranges(Vector<CompareTypeAndValuePair>&
ranges.empend(CompareTypeAndValuePair { CharacterCompareType::TemporaryInverse, 0 });
ranges.empend(CompareTypeAndValuePair { CharacterCompareType::CharClass, (ByteCodeValueType)first_atom.value().character_class });
} else {
ASSERT(!atom.is_negated);
VERIFY(!atom.is_negated);
ranges.empend(CompareTypeAndValuePair { CharacterCompareType::Char, first_atom.value().code_point });
}
}

View file

@ -24,7 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/TestSuite.h> // import first, to prevent warning of ASSERT* redefinition
#include <AK/TestSuite.h> // import first, to prevent warning of VERIFY* redefinition
#include <LibRegex/Regex.h>
#include <stdio.h>

View file

@ -24,7 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/TestSuite.h> // import first, to prevent warning of ASSERT* redefinition
#include <AK/TestSuite.h> // import first, to prevent warning of VERIFY* redefinition
#include <AK/StringBuilder.h>
#include <LibRegex/Regex.h>