🎨 cleanup

This commit is contained in:
Niels Lohmann 2019-03-19 09:17:14 +01:00
parent 37a72dac48
commit b224c52376
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
4 changed files with 153 additions and 169 deletions

View file

@ -442,7 +442,7 @@ fuzzing-stop:
# call cppcheck on the main header file
cppcheck:
cppcheck --enable=warning --inconclusive --force --std=c++11 $(SRCS) --error-exitcode=1
cppcheck --enable=warning --inline-suppr --inconclusive --force --std=c++11 $(SRCS) --error-exitcode=1
# compile and check with Clang Static Analyzer
clang_analyze:

View file

@ -262,15 +262,14 @@ class parser
m_lexer.get_token_string(),
out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'"));
}
else
{
if (JSON_UNLIKELY(not sax->number_float(res, m_lexer.get_string())))
{
return false;
}
break;
}
}
case token_type::literal_false:
{
@ -355,8 +354,7 @@ class parser
// empty stack: we reached the end of the hierarchy: done
return true;
}
else
{
if (states.back()) // array
{
// comma -> next value
@ -384,14 +382,12 @@ class parser
skip_to_state_evaluation = true;
continue;
}
else
{
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(),
exception_message(token_type::end_array, "array")));
}
}
else // object
{
// comma -> next value
@ -405,13 +401,11 @@ class parser
parse_error::create(101, m_lexer.get_position(),
exception_message(token_type::value_string, "object key")));
}
else
{
if (JSON_UNLIKELY(not sax->key(m_lexer.get_string())))
{
return false;
}
}
// parse separator (:)
if (JSON_UNLIKELY(get_token() != token_type::name_separator))
@ -444,8 +438,7 @@ class parser
skip_to_state_evaluation = true;
continue;
}
else
{
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(),
@ -453,8 +446,6 @@ class parser
}
}
}
}
}
/// get next token from lexer
token_type get_token()

View file

@ -4777,7 +4777,8 @@ class basic_json
// add element to array (move semantics)
m_value.array->push_back(std::move(val));
// invalidate object
// invalidate object: mark it null so we do not call the destructor
// cppcheck-suppress accessMoved
val.m_type = value_t::null;
}

View file

@ -7276,15 +7276,14 @@ class parser
m_lexer.get_token_string(),
out_of_range::create(406, "number overflow parsing '" + m_lexer.get_token_string() + "'"));
}
else
{
if (JSON_UNLIKELY(not sax->number_float(res, m_lexer.get_string())))
{
return false;
}
break;
}
}
case token_type::literal_false:
{
@ -7369,8 +7368,7 @@ class parser
// empty stack: we reached the end of the hierarchy: done
return true;
}
else
{
if (states.back()) // array
{
// comma -> next value
@ -7398,14 +7396,12 @@ class parser
skip_to_state_evaluation = true;
continue;
}
else
{
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(),
exception_message(token_type::end_array, "array")));
}
}
else // object
{
// comma -> next value
@ -7419,13 +7415,11 @@ class parser
parse_error::create(101, m_lexer.get_position(),
exception_message(token_type::value_string, "object key")));
}
else
{
if (JSON_UNLIKELY(not sax->key(m_lexer.get_string())))
{
return false;
}
}
// parse separator (:)
if (JSON_UNLIKELY(get_token() != token_type::name_separator))
@ -7458,8 +7452,7 @@ class parser
skip_to_state_evaluation = true;
continue;
}
else
{
return sax->parse_error(m_lexer.get_position(),
m_lexer.get_token_string(),
parse_error::create(101, m_lexer.get_position(),
@ -7467,8 +7460,6 @@ class parser
}
}
}
}
}
/// get next token from lexer
token_type get_token()
@ -17420,7 +17411,8 @@ class basic_json
// add element to array (move semantics)
m_value.array->push_back(std::move(val));
// invalidate object
// invalidate object: mark it null so we do not call the destructor
// cppcheck-suppress accessMoved
val.m_type = value_t::null;
}