Skip to content

Commit

Permalink
Merge pull request godotengine#55785 from nathanfranke/clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Jan 29, 2022
2 parents 9467350 + 8a0a3ac commit 2f57a11
Show file tree
Hide file tree
Showing 36 changed files with 290 additions and 246 deletions.
7 changes: 3 additions & 4 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-nullptr,readability-braces-around-statements'
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,modernize-redundant-void-arg,modernize-use-bool-literals,modernize-use-default-member-init,modernize-use-nullptr,readability-braces-around-statements'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
Expand Down
3 changes: 2 additions & 1 deletion core/input/input_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,8 +1221,9 @@ String InputEventScreenDrag::to_string() {

bool InputEventScreenDrag::accumulate(const Ref<InputEvent> &p_event) {
Ref<InputEventScreenDrag> drag = p_event;
if (drag.is_null())
if (drag.is_null()) {
return false;
}

if (get_index() != drag->get_index()) {
return false;
Expand Down
3 changes: 2 additions & 1 deletion core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,8 +700,9 @@ class Object {
static String get_category_static() { return String(); }

virtual String get_class() const {
if (_extension)
if (_extension) {
return _extension->class_name.operator String();
}
return "Object";
}
virtual String get_save_class() const { return get_class(); } //class stored when saving
Expand Down
19 changes: 10 additions & 9 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
}

state.current_tex = RID();
state.current_tex_ptr = NULL;
state.current_tex_ptr = nullptr;
state.current_normal = RID();
state.current_specular = RID();
state.canvas_texscreen_used = false;
Expand Down Expand Up @@ -233,13 +233,13 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
}

if (material != prev_material) {
RasterizerStorageGLES3::Shader *shader_ptr = NULL;
RasterizerStorageGLES3::Shader *shader_ptr = nullptr;

if (material_ptr) {
shader_ptr = material_ptr->shader;

if (shader_ptr && shader_ptr->mode != RS::SHADER_CANVAS_ITEM) {
shader_ptr = NULL; // not a canvas item shader, don't use.
shader_ptr = nullptr; // not a canvas item shader, don't use.
}
}

Expand Down Expand Up @@ -295,8 +295,9 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
t->detect_normal(t->detect_normal_ud);
}
#endif
if (t->render_target)
if (t->render_target) {
t->render_target->used_in_frame = true;
}

glBindTexture(t->target, t->tex_id);
}
Expand Down Expand Up @@ -582,7 +583,7 @@ void RasterizerCanvasGLES3::_render_item(RID p_render_target, const Item *p_item
static const GLenum prim[5] = { GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES, GL_TRIANGLE_STRIP };

if (pb->index_buffer != 0) {
glDrawElements(prim[polygon->primitive], pb->count, GL_UNSIGNED_INT, 0);
glDrawElements(prim[polygon->primitive], pb->count, GL_UNSIGNED_INT, nullptr);
} else {
glDrawArrays(prim[polygon->primitive], 0, pb->count);
}
Expand Down Expand Up @@ -946,7 +947,7 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe

if (!texture) {
state.current_tex = RID();
state.current_tex_ptr = NULL;
state.current_tex_ptr = nullptr;
ct->size_cache = Size2i(1, 1);

glActiveTexture(GL_TEXTURE0);
Expand Down Expand Up @@ -1096,7 +1097,7 @@ RendererCanvasRender::PolygonID RasterizerCanvasGLES3::request_polygon(const Vec
{
// Always uses vertex positions
glEnableVertexAttribArray(RS::ARRAY_VERTEX);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), NULL);
glVertexAttribPointer(RS::ARRAY_VERTEX, 2, GL_FLOAT, GL_FALSE, stride * sizeof(float), nullptr);
const Vector2 *points_ptr = p_points.ptr();

for (uint32_t i = 0; i < vertex_count; i++) {
Expand Down Expand Up @@ -1313,7 +1314,7 @@ void RasterizerCanvasGLES3::initialize() {
glGenBuffers(1, &data.ninepatch_vertices);
glBindBuffer(GL_ARRAY_BUFFER, data.ninepatch_vertices);

glBufferData(GL_ARRAY_BUFFER, sizeof(float) * (16 + 16) * 2, NULL, GL_DYNAMIC_DRAW);
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * (16 + 16) * 2, nullptr, GL_DYNAMIC_DRAW);

glBindBuffer(GL_ARRAY_BUFFER, 0);

Expand Down Expand Up @@ -1443,7 +1444,7 @@ void fragment() {
default_canvas_texture = storage->canvas_texture_allocate();
storage->canvas_texture_initialize(default_canvas_texture);

state.using_light = NULL;
state.using_light = nullptr;
state.using_transparent_rt = false;
state.using_skeleton = false;
state.current_shader_version = state.canvas_shader_default_version;
Expand Down
56 changes: 31 additions & 25 deletions drivers/gles3/rasterizer_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,46 +130,51 @@ void RasterizerGLES3::end_frame(bool p_swap_buffers) {

#ifdef CAN_DEBUG
static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam) {
if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
if (type == _EXT_DEBUG_TYPE_OTHER_ARB) {
return;
}

if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB)
if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) {
return; //these are ultimately annoying, so removing for now
}

char debSource[256], debType[256], debSev[256];

if (source == _EXT_DEBUG_SOURCE_API_ARB)
if (source == _EXT_DEBUG_SOURCE_API_ARB) {
strcpy(debSource, "OpenGL");
else if (source == _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB)
} else if (source == _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) {
strcpy(debSource, "Windows");
else if (source == _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB)
} else if (source == _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB) {
strcpy(debSource, "Shader Compiler");
else if (source == _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB)
} else if (source == _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB) {
strcpy(debSource, "Third Party");
else if (source == _EXT_DEBUG_SOURCE_APPLICATION_ARB)
} else if (source == _EXT_DEBUG_SOURCE_APPLICATION_ARB) {
strcpy(debSource, "Application");
else if (source == _EXT_DEBUG_SOURCE_OTHER_ARB)
} else if (source == _EXT_DEBUG_SOURCE_OTHER_ARB) {
strcpy(debSource, "Other");
}

if (type == _EXT_DEBUG_TYPE_ERROR_ARB)
if (type == _EXT_DEBUG_TYPE_ERROR_ARB) {
strcpy(debType, "Error");
else if (type == _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB)
} else if (type == _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) {
strcpy(debType, "Deprecated behavior");
else if (type == _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB)
} else if (type == _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) {
strcpy(debType, "Undefined behavior");
else if (type == _EXT_DEBUG_TYPE_PORTABILITY_ARB)
} else if (type == _EXT_DEBUG_TYPE_PORTABILITY_ARB) {
strcpy(debType, "Portability");
else if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB)
} else if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) {
strcpy(debType, "Performance");
else if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
} else if (type == _EXT_DEBUG_TYPE_OTHER_ARB) {
strcpy(debType, "Other");
}

if (severity == _EXT_DEBUG_SEVERITY_HIGH_ARB)
if (severity == _EXT_DEBUG_SEVERITY_HIGH_ARB) {
strcpy(debSev, "High");
else if (severity == _EXT_DEBUG_SEVERITY_MEDIUM_ARB)
} else if (severity == _EXT_DEBUG_SEVERITY_MEDIUM_ARB) {
strcpy(debSev, "Medium");
else if (severity == _EXT_DEBUG_SEVERITY_LOW_ARB)
} else if (severity == _EXT_DEBUG_SEVERITY_LOW_ARB) {
strcpy(debSev, "Low");
}

String output = String() + "GL ERROR: Source: " + debSource + "\tType: " + debType + "\tID: " + itos(id) + "\tSeverity: " + debSev + "\tMessage: " + message;

Expand Down Expand Up @@ -203,7 +208,7 @@ void RasterizerGLES3::initialize() {
if (OS::get_singleton()->is_stdout_verbose()) {
if (GLAD_GL_ARB_debug_output) {
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
glDebugMessageCallbackARB(_gl_debug_print, NULL);
glDebugMessageCallbackARB(_gl_debug_print, nullptr);
glEnable(_EXT_DEBUG_OUTPUT);
} else {
print_line("OpenGL debugging not supported!");
Expand All @@ -215,12 +220,12 @@ void RasterizerGLES3::initialize() {
#ifdef CAN_DEBUG
#ifdef GLES_OVER_GL
if (OS::get_singleton()->is_stdout_verbose() && GLAD_GL_ARB_debug_output) {
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
// glDebugMessageInsertARB(
// GL_DEBUG_SOURCE_API_ARB,
// GL_DEBUG_TYPE_OTHER_ARB, 1,
Expand Down Expand Up @@ -299,8 +304,9 @@ void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_sc
}

void RasterizerGLES3::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale, bool p_use_filter) {
if (p_image.is_null() || p_image->is_empty())
if (p_image.is_null() || p_image->is_empty()) {
return;
}

Size2i win_size = DisplayServer::get_singleton()->screen_get_size();

Expand Down
Loading

0 comments on commit 2f57a11

Please sign in to comment.