Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit 8a0a3ac

Browse files
author
Nathan Franke
committedJan 29, 2022
simplify formatting scripts, add a clang-tidy script, and run clang-tidy
1 parent 01f5d7c commit 8a0a3ac

36 files changed

+290
-246
lines changed
 

‎.clang-tidy

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
---
2-
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'
2+
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'
33
WarningsAsErrors: ''
4-
HeaderFilterRegex: '.*'
4+
HeaderFilterRegex: ''
55
AnalyzeTemporaryDtors: false
6-
FormatStyle: none
7-
CheckOptions:
6+
FormatStyle: none
87
CheckOptions:
98
- key: cert-dcl16-c.NewSuffixes
109
value: 'L;LL;LU;LLU'

‎core/input/input_event.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -1221,8 +1221,9 @@ String InputEventScreenDrag::to_string() {
12211221

12221222
bool InputEventScreenDrag::accumulate(const Ref<InputEvent> &p_event) {
12231223
Ref<InputEventScreenDrag> drag = p_event;
1224-
if (drag.is_null())
1224+
if (drag.is_null()) {
12251225
return false;
1226+
}
12261227

12271228
if (get_index() != drag->get_index()) {
12281229
return false;

‎core/object/object.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -700,8 +700,9 @@ class Object {
700700
static String get_category_static() { return String(); }
701701

702702
virtual String get_class() const {
703-
if (_extension)
703+
if (_extension) {
704704
return _extension->class_name.operator String();
705+
}
705706
return "Object";
706707
}
707708
virtual String get_save_class() const { return get_class(); } //class stored when saving

‎drivers/gles3/rasterizer_canvas_gles3.cpp

+10-9
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void RasterizerCanvasGLES3::canvas_render_items(RID p_to_render_target, Item *p_
184184
}
185185

186186
state.current_tex = RID();
187-
state.current_tex_ptr = NULL;
187+
state.current_tex_ptr = nullptr;
188188
state.current_normal = RID();
189189
state.current_specular = RID();
190190
state.canvas_texscreen_used = false;
@@ -233,13 +233,13 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
233233
}
234234

235235
if (material != prev_material) {
236-
RasterizerStorageGLES3::Shader *shader_ptr = NULL;
236+
RasterizerStorageGLES3::Shader *shader_ptr = nullptr;
237237

238238
if (material_ptr) {
239239
shader_ptr = material_ptr->shader;
240240

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

@@ -295,8 +295,9 @@ void RasterizerCanvasGLES3::_render_items(RID p_to_render_target, int p_item_cou
295295
t->detect_normal(t->detect_normal_ud);
296296
}
297297
#endif
298-
if (t->render_target)
298+
if (t->render_target) {
299299
t->render_target->used_in_frame = true;
300+
}
300301

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

584585
if (pb->index_buffer != 0) {
585-
glDrawElements(prim[polygon->primitive], pb->count, GL_UNSIGNED_INT, 0);
586+
glDrawElements(prim[polygon->primitive], pb->count, GL_UNSIGNED_INT, nullptr);
586587
} else {
587588
glDrawArrays(prim[polygon->primitive], 0, pb->count);
588589
}
@@ -946,7 +947,7 @@ void RasterizerCanvasGLES3::_bind_canvas_texture(RID p_texture, RS::CanvasItemTe
946947

947948
if (!texture) {
948949
state.current_tex = RID();
949-
state.current_tex_ptr = NULL;
950+
state.current_tex_ptr = nullptr;
950951
ct->size_cache = Size2i(1, 1);
951952

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

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

1316-
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * (16 + 16) * 2, NULL, GL_DYNAMIC_DRAW);
1317+
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * (16 + 16) * 2, nullptr, GL_DYNAMIC_DRAW);
13171318

13181319
glBindBuffer(GL_ARRAY_BUFFER, 0);
13191320

@@ -1443,7 +1444,7 @@ void fragment() {
14431444
default_canvas_texture = storage->canvas_texture_allocate();
14441445
storage->canvas_texture_initialize(default_canvas_texture);
14451446

1446-
state.using_light = NULL;
1447+
state.using_light = nullptr;
14471448
state.using_transparent_rt = false;
14481449
state.using_skeleton = false;
14491450
state.current_shader_version = state.canvas_shader_default_version;

‎drivers/gles3/rasterizer_gles3.cpp

+31-25
Original file line numberDiff line numberDiff line change
@@ -130,46 +130,51 @@ void RasterizerGLES3::end_frame(bool p_swap_buffers) {
130130

131131
#ifdef CAN_DEBUG
132132
static void GLAPIENTRY _gl_debug_print(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message, const GLvoid *userParam) {
133-
if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
133+
if (type == _EXT_DEBUG_TYPE_OTHER_ARB) {
134134
return;
135+
}
135136

136-
if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB)
137+
if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) {
137138
return; //these are ultimately annoying, so removing for now
139+
}
138140

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

141-
if (source == _EXT_DEBUG_SOURCE_API_ARB)
143+
if (source == _EXT_DEBUG_SOURCE_API_ARB) {
142144
strcpy(debSource, "OpenGL");
143-
else if (source == _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB)
145+
} else if (source == _EXT_DEBUG_SOURCE_WINDOW_SYSTEM_ARB) {
144146
strcpy(debSource, "Windows");
145-
else if (source == _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB)
147+
} else if (source == _EXT_DEBUG_SOURCE_SHADER_COMPILER_ARB) {
146148
strcpy(debSource, "Shader Compiler");
147-
else if (source == _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB)
149+
} else if (source == _EXT_DEBUG_SOURCE_THIRD_PARTY_ARB) {
148150
strcpy(debSource, "Third Party");
149-
else if (source == _EXT_DEBUG_SOURCE_APPLICATION_ARB)
151+
} else if (source == _EXT_DEBUG_SOURCE_APPLICATION_ARB) {
150152
strcpy(debSource, "Application");
151-
else if (source == _EXT_DEBUG_SOURCE_OTHER_ARB)
153+
} else if (source == _EXT_DEBUG_SOURCE_OTHER_ARB) {
152154
strcpy(debSource, "Other");
155+
}
153156

154-
if (type == _EXT_DEBUG_TYPE_ERROR_ARB)
157+
if (type == _EXT_DEBUG_TYPE_ERROR_ARB) {
155158
strcpy(debType, "Error");
156-
else if (type == _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB)
159+
} else if (type == _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB) {
157160
strcpy(debType, "Deprecated behavior");
158-
else if (type == _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB)
161+
} else if (type == _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB) {
159162
strcpy(debType, "Undefined behavior");
160-
else if (type == _EXT_DEBUG_TYPE_PORTABILITY_ARB)
163+
} else if (type == _EXT_DEBUG_TYPE_PORTABILITY_ARB) {
161164
strcpy(debType, "Portability");
162-
else if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB)
165+
} else if (type == _EXT_DEBUG_TYPE_PERFORMANCE_ARB) {
163166
strcpy(debType, "Performance");
164-
else if (type == _EXT_DEBUG_TYPE_OTHER_ARB)
167+
} else if (type == _EXT_DEBUG_TYPE_OTHER_ARB) {
165168
strcpy(debType, "Other");
169+
}
166170

167-
if (severity == _EXT_DEBUG_SEVERITY_HIGH_ARB)
171+
if (severity == _EXT_DEBUG_SEVERITY_HIGH_ARB) {
168172
strcpy(debSev, "High");
169-
else if (severity == _EXT_DEBUG_SEVERITY_MEDIUM_ARB)
173+
} else if (severity == _EXT_DEBUG_SEVERITY_MEDIUM_ARB) {
170174
strcpy(debSev, "Medium");
171-
else if (severity == _EXT_DEBUG_SEVERITY_LOW_ARB)
175+
} else if (severity == _EXT_DEBUG_SEVERITY_LOW_ARB) {
172176
strcpy(debSev, "Low");
177+
}
173178

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

@@ -203,7 +208,7 @@ void RasterizerGLES3::initialize() {
203208
if (OS::get_singleton()->is_stdout_verbose()) {
204209
if (GLAD_GL_ARB_debug_output) {
205210
glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
206-
glDebugMessageCallbackARB(_gl_debug_print, NULL);
211+
glDebugMessageCallbackARB(_gl_debug_print, nullptr);
207212
glEnable(_EXT_DEBUG_OUTPUT);
208213
} else {
209214
print_line("OpenGL debugging not supported!");
@@ -215,12 +220,12 @@ void RasterizerGLES3::initialize() {
215220
#ifdef CAN_DEBUG
216221
#ifdef GLES_OVER_GL
217222
if (OS::get_singleton()->is_stdout_verbose() && GLAD_GL_ARB_debug_output) {
218-
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
219-
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
220-
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
221-
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
222-
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
223-
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, NULL, GL_TRUE);
223+
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_ERROR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
224+
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
225+
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
226+
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PORTABILITY_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
227+
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_PERFORMANCE_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
228+
glDebugMessageControlARB(_EXT_DEBUG_SOURCE_API_ARB, _EXT_DEBUG_TYPE_OTHER_ARB, _EXT_DEBUG_SEVERITY_HIGH_ARB, 0, nullptr, GL_TRUE);
224229
// glDebugMessageInsertARB(
225230
// GL_DEBUG_SOURCE_API_ARB,
226231
// GL_DEBUG_TYPE_OTHER_ARB, 1,
@@ -299,8 +304,9 @@ void RasterizerGLES3::blit_render_targets_to_screen(DisplayServer::WindowID p_sc
299304
}
300305

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

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

0 commit comments

Comments
 (0)
This repository has been archived.