more qualifying

This commit is contained in:
Tyler 2022-03-10 17:36:46 -05:00
parent 047034544e
commit 1653b6c5b7
3 changed files with 7 additions and 10 deletions

View File

@ -222,7 +222,7 @@ struct InlineAssemblyAnnotation: StatementAnnotation
/// True, if the assembly block was annotated to be memory-safe. /// True, if the assembly block was annotated to be memory-safe.
bool markedMemorySafe = false; bool markedMemorySafe = false;
/// True, if the assembly block involves any memory opcode or assigns to variables in memory. /// True, if the assembly block involves any memory opcode or assigns to variables in memory.
SetOnce<bool> hasMemoryEffects; util::SetOnce<bool> hasMemoryEffects;
}; };
struct BlockAnnotation: StatementAnnotation, ScopableAnnotation struct BlockAnnotation: StatementAnnotation, ScopableAnnotation

View File

@ -42,11 +42,10 @@ namespace
int parseUnsignedInteger(string::iterator& _it, string::iterator _end) int parseUnsignedInteger(string::iterator& _it, string::iterator _end)
{ {
auto isDigit = [](char _c) -> bool {return isdigit(_c, std::locale::classic());}; if (_it == _end || !util::isDigit(*_it))
if (_it == _end || !isDigit(*_it))
BOOST_THROW_EXCEPTION(runtime_error("Invalid test expectation. Source location expected.")); BOOST_THROW_EXCEPTION(runtime_error("Invalid test expectation. Source location expected."));
int result = 0; int result = 0;
while (_it != _end && isDigit(*_it)) while (_it != _end && util::isDigit(*_it))
{ {
result *= 10; result *= 10;
result += *_it - '0'; result += *_it - '0';
@ -195,7 +194,6 @@ string CommonSyntaxTest::errorMessage(Exception const& _e)
vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream) vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
{ {
auto isDigit = [](char _c) -> bool {return isdigit(_c, std::locale::classic());};
vector<SyntaxTestError> expectations; vector<SyntaxTestError> expectations;
string line; string line;
while (getline(_stream, line)) while (getline(_stream, line))
@ -215,7 +213,7 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
skipWhitespace(it, line.end()); skipWhitespace(it, line.end());
optional<ErrorId> errorId; optional<ErrorId> errorId;
if (it != line.end() && isDigit(*it)) if (it != line.end() && util::isDigit(*it))
errorId = ErrorId{static_cast<unsigned long long>(parseUnsignedInteger(it, line.end()))}; errorId = ErrorId{static_cast<unsigned long long>(parseUnsignedInteger(it, line.end()))};
expect(it, line.end(), ':'); expect(it, line.end(), ':');
@ -228,7 +226,7 @@ vector<SyntaxTestError> CommonSyntaxTest::parseExpectations(istream& _stream)
if (it != line.end() && *it == '(') if (it != line.end() && *it == '(')
{ {
++it; ++it;
if (it != line.end() && !isDigit(*it)) if (it != line.end() && !util::isDigit(*it))
{ {
auto sourceNameStart = it; auto sourceNameStart = it;
while (it != line.end() && *it != ':') while (it != line.end() && *it != ':')

View File

@ -763,12 +763,11 @@ string TestFileParser::Scanner::scanString()
char TestFileParser::Scanner::scanHexPart() char TestFileParser::Scanner::scanHexPart()
{ {
auto toLower = [](char _c) -> char { return tolower(_c, locale::classic()); }; auto toLower = [](char _c) -> char { return tolower(_c, locale::classic()); };
auto isDigit = [](char _c) -> bool { return isdigit(_c, locale::classic()); };
advance(); // skip 'x' advance(); // skip 'x'
int value{}; int value{};
if (isDigit(current())) if (util::isDigit(current()))
value = current() - '0'; value = current() - '0';
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f') else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
value = toLower(current()) - 'a' + 10; value = toLower(current()) - 'a' + 10;
@ -780,7 +779,7 @@ char TestFileParser::Scanner::scanHexPart()
return static_cast<char>(value); return static_cast<char>(value);
value <<= 4; value <<= 4;
if (isDigit(current())) if (util::isDigit(current()))
value |= current() - '0'; value |= current() - '0';
else if (toLower(current()) >= 'a' && toLower(current()) <= 'f') else if (toLower(current()) >= 'a' && toLower(current()) <= 'f')
value |= toLower(current()) - 'a' + 10; value |= toLower(current()) - 'a' + 10;