Some code changed with Clang-Tidy

This commit is contained in:
qarmin 2019-06-26 15:08:25 +02:00
parent 5c66771e3e
commit 4e5310cc60
175 changed files with 467 additions and 674 deletions

View file

@ -69,7 +69,7 @@ Variant GDScriptNativeClass::_new() {
Object *o = instance();
if (!o) {
ERR_EXPLAIN("Class type: '" + String(name) + "' is not instantiable.");
ERR_FAIL_COND_V(!o, Variant());
ERR_FAIL_V(Variant());
}
Reference *ref = Object::cast_to<Reference>(o);

View file

@ -1073,7 +1073,7 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::
int set_index;
bool named = false;
if (static_cast<const GDScriptParser::OperatorNode *>(op)->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
if (op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) {
set_index = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name);
named = true;

View file

@ -1150,7 +1150,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (!expr) {
ERR_EXPLAIN("GDScriptParser bug, couldn't figure out what expression is...");
ERR_FAIL_COND_V(!expr, NULL);
ERR_FAIL_V(NULL);
}
/******************/
@ -1493,7 +1493,7 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s
if (next_op == -1) {
_set_error("Yet another parser bug....");
ERR_FAIL_COND_V(next_op == -1, NULL);
ERR_FAIL_V(NULL);
}
// OK! create operator..
@ -5944,11 +5944,8 @@ bool GDScriptParser::_is_type_compatible(const DataType &p_container, const Data
if (p_container.kind == DataType::BUILTIN && p_container.builtin_type == Variant::OBJECT) {
// Object built-in is a special case, it's compatible with any object and with null
if (p_expression.kind == DataType::BUILTIN && p_expression.builtin_type == Variant::NIL) {
return true;
}
if (p_expression.kind == DataType::BUILTIN) {
return false;
return p_expression.builtin_type == Variant::NIL;
}
// If it's not a built-in, must be an object
return true;

View file

@ -1189,7 +1189,7 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
int version = decode_uint32(&buf[4]);
if (version > BYTECODE_VERSION) {
ERR_EXPLAIN("Bytecode is too New! Please use a newer engine version.");
ERR_FAIL_COND_V(version > BYTECODE_VERSION, ERR_INVALID_DATA);
ERR_FAIL_V(ERR_INVALID_DATA);
}
int identifier_count = decode_uint32(&buf[8]);
int constant_count = decode_uint32(&buf[12]);
@ -1303,7 +1303,7 @@ Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code)
} break;
case TK_CONSTANT: {
Variant c = tt.get_token_constant();
const Variant &c = tt.get_token_constant();
if (!constant_map.has(c)) {
int idx = constant_map.size();
constant_map[c] = idx;