Skip to content

Commit 2450dee

Browse files
committed
Merge pull request #93401 from Repiteo/style/clang-tidy-fixes
Style: Apply `clang-tidy` fixes
2 parents 7d950c1 + 2dcfdde commit 2450dee

File tree

67 files changed

+166
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+166
-149
lines changed

.clang-tidy

+9-12
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
---
2-
Checks: >-
3-
-*,
4-
cppcoreguidelines-pro-type-member-init,
5-
modernize-redundant-void-arg,
6-
modernize-use-bool-literals,
7-
modernize-use-default-member-init,
8-
modernize-use-nullptr,
9-
readability-braces-around-statements,
10-
readability-redundant-member-init
11-
WarningsAsErrors: ''
1+
Checks:
2+
- -*
3+
- cppcoreguidelines-pro-type-member-init
4+
- modernize-redundant-void-arg
5+
- modernize-use-bool-literals
6+
- modernize-use-default-member-init
7+
- modernize-use-nullptr
8+
- readability-braces-around-statements
9+
- readability-redundant-member-init
1210
HeaderFileExtensions: ['', h, hh, hpp, hxx, inc, glsl]
1311
ImplementationFileExtensions: [c, cc, cpp, cxx, m, mm, java]
1412
HeaderFilterRegex: (core|doc|drivers|editor|main|modules|platform|scene|servers|tests)/
@@ -19,4 +17,3 @@ CheckOptions:
1917
modernize-use-bool-literals.IgnoreMacros: false
2018
modernize-use-default-member-init.IgnoreMacros: false
2119
modernize-use-default-member-init.UseAssignment: true
22-
...

.git-blame-ignore-revs

+3
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ b37fc1014abf7adda70dc30b0822d775b3a4433f
6060

6161
# Set clang-format `RemoveSemicolon` rule to `true`
6262
0d350e71086fffce0553811739aae9f6ad66136c
63+
64+
# Style: Apply clang-tidy fixes (superficial)
65+
bb5f390fb9b466be35a5df7651323d7e66afca31

core/input/input.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ void Input::action_release(const StringName &p_action) {
10341034

10351035
// Create or retrieve existing action.
10361036
ActionState &action_state = action_states[p_action];
1037-
action_state.cache.pressed = 0;
1037+
action_state.cache.pressed = false;
10381038
action_state.cache.strength = 0.0;
10391039
action_state.cache.raw_strength = 0.0;
10401040
// As input may come in part way through a physics tick, the earliest we can react to it is the next physics tick.

core/object/message_queue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class CallQueue {
153153
bool is_flushing() const;
154154
int get_max_buffer_usage() const;
155155

156-
CallQueue(Allocator *p_custom_allocator = 0, uint32_t p_max_pages = 8192, const String &p_error_text = String());
156+
CallQueue(Allocator *p_custom_allocator = nullptr, uint32_t p_max_pages = 8192, const String &p_error_text = String());
157157
virtual ~CallQueue();
158158
};
159159

core/typedefs.h

-2
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,4 @@ struct BuildIndexSequence<0, Is...> : IndexSequence<Is...> {};
315315
#define ___gd_is_defined(val) ____gd_is_defined(__GDARG_PLACEHOLDER_##val)
316316
#define GD_IS_DEFINED(x) ___gd_is_defined(x)
317317

318-
#define FORCE_SEMICOLON ;
319-
320318
#endif // TYPEDEFS_H

core/variant/variant.cpp

+4-8
Original file line numberDiff line numberDiff line change
@@ -2719,8 +2719,7 @@ Variant::Variant(const Vector<Plane> &p_array) :
27192719
}
27202720
}
27212721

2722-
Variant::Variant(const Vector<Face3> &p_face_array) :
2723-
type(NIL) {
2722+
Variant::Variant(const Vector<Face3> &p_face_array) {
27242723
PackedVector3Array vertices;
27252724
int face_count = p_face_array.size();
27262725
vertices.resize(face_count * 3);
@@ -2739,8 +2738,7 @@ Variant::Variant(const Vector<Face3> &p_face_array) :
27392738
*this = vertices;
27402739
}
27412740

2742-
Variant::Variant(const Vector<Variant> &p_array) :
2743-
type(NIL) {
2741+
Variant::Variant(const Vector<Variant> &p_array) {
27442742
Array arr;
27452743
arr.resize(p_array.size());
27462744
for (int i = 0; i < p_array.size(); i++) {
@@ -2749,8 +2747,7 @@ Variant::Variant(const Vector<Variant> &p_array) :
27492747
*this = arr;
27502748
}
27512749

2752-
Variant::Variant(const Vector<StringName> &p_array) :
2753-
type(NIL) {
2750+
Variant::Variant(const Vector<StringName> &p_array) {
27542751
PackedStringArray v;
27552752
int len = p_array.size();
27562753
v.resize(len);
@@ -2908,8 +2905,7 @@ Variant::Variant(const IPAddress &p_address) :
29082905
memnew_placement(_data._mem, String(p_address));
29092906
}
29102907

2911-
Variant::Variant(const Variant &p_variant) :
2912-
type(NIL) {
2908+
Variant::Variant(const Variant &p_variant) {
29132909
reference(p_variant);
29142910
}
29152911

core/variant/variant.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -814,8 +814,7 @@ class Variant {
814814
static void unregister_types();
815815

816816
Variant(const Variant &p_variant);
817-
_FORCE_INLINE_ Variant() :
818-
type(NIL) {}
817+
_FORCE_INLINE_ Variant() {}
819818
_FORCE_INLINE_ ~Variant() {
820819
clear();
821820
}

drivers/gles3/storage/particles_storage.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ class ParticlesStorage : public RendererParticlesStorage {
396396

397397
_FORCE_INLINE_ bool particles_has_collision(RID p_particles) {
398398
Particles *particles = particles_owner.get_or_null(p_particles);
399-
ERR_FAIL_NULL_V(particles, 0);
399+
ERR_FAIL_NULL_V(particles, false);
400400

401401
return particles->has_collision_cache;
402402
}

drivers/vulkan/rendering_device_driver_vulkan.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,7 @@ RDD::BufferID RenderingDeviceDriverVulkan::buffer_create(uint64_t p_size, BitFie
15191519
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't create buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
15201520
err = vmaAllocateMemoryForBuffer(allocator, vk_buffer, &alloc_create_info, &allocation, &alloc_info);
15211521
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't allocate memory for buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
1522-
err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, NULL);
1522+
err = vmaBindBufferMemory2(allocator, allocation, 0, vk_buffer, nullptr);
15231523
ERR_FAIL_COND_V_MSG(err, BufferID(), "Can't bind memory to buffer of size: " + itos(p_size) + ", error " + itos(err) + ".");
15241524

15251525
// Bookkeep.
@@ -1745,7 +1745,7 @@ RDD::TextureID RenderingDeviceDriverVulkan::texture_create(const TextureFormat &
17451745
ERR_FAIL_COND_V_MSG(err, TextureID(), "vkCreateImage failed with error " + itos(err) + ".");
17461746
err = vmaAllocateMemoryForImage(allocator, vk_image, &alloc_create_info, &allocation, &alloc_info);
17471747
ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't allocate memory for image, error: " + itos(err) + ".");
1748-
err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, NULL);
1748+
err = vmaBindImageMemory2(allocator, allocation, 0, vk_image, nullptr);
17491749
ERR_FAIL_COND_V_MSG(err, TextureID(), "Can't bind memory to image, error: " + itos(err) + ".");
17501750

17511751
// Create view.
@@ -4042,7 +4042,7 @@ RDD::UniformSetID RenderingDeviceDriverVulkan::uniform_set_create(VectorView<Bou
40424042
}
40434043

40444044
// Need a descriptor pool.
4045-
DescriptorSetPools::Iterator pool_sets_it = {};
4045+
DescriptorSetPools::Iterator pool_sets_it;
40464046
VkDescriptorPool vk_pool = _descriptor_set_pool_find_or_create(pool_key, &pool_sets_it);
40474047
DEV_ASSERT(vk_pool);
40484048
pool_sets_it->value[vk_pool]++;

drivers/vulkan/rendering_device_driver_vulkan.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ class RenderingDeviceDriverVulkan : public RenderingDeviceDriver {
489489
struct UniformSetInfo {
490490
VkDescriptorSet vk_descriptor_set = VK_NULL_HANDLE;
491491
VkDescriptorPool vk_descriptor_pool = VK_NULL_HANDLE;
492-
DescriptorSetPools::Iterator pool_sets_it = {};
492+
DescriptorSetPools::Iterator pool_sets_it;
493493
};
494494

495495
public:

drivers/windows/dir_access_windows.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ Error DirAccessWindows::rename(String p_path, String p_new_path) {
282282
uint64_t id = OS::get_singleton()->get_ticks_usec();
283283
while (true) {
284284
tmpfile_utf16 = (path + itos(id++) + ".tmp").utf16();
285-
HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
285+
HANDLE handle = CreateFileW((LPCWSTR)tmpfile_utf16.get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
286286
if (handle != INVALID_HANDLE_VALUE) {
287287
CloseHandle(handle);
288288
break;

drivers/windows/file_access_windows.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Error FileAccessWindows::open_internal(const String &p_path, int p_mode_flags) {
193193
uint64_t id = OS::get_singleton()->get_ticks_usec();
194194
while (true) {
195195
tmpfile = path + itos(id++) + ".tmp";
196-
HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
196+
HANDLE handle = CreateFileW((LPCWSTR)tmpfile.utf16().get_data(), GENERIC_WRITE, 0, nullptr, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, nullptr);
197197
if (handle != INVALID_HANDLE_VALUE) {
198198
CloseHandle(handle);
199199
break;

drivers/windows/file_access_windows_pipe.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Error FileAccessWindowsPipe::open_existing(HANDLE p_rfd, HANDLE p_wfd, bool p_bl
4040
_close();
4141

4242
path_src = String();
43-
ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
43+
ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use.");
4444
fd[0] = p_rfd;
4545
fd[1] = p_wfd;
4646

@@ -58,18 +58,18 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag
5858
_close();
5959

6060
path_src = p_path;
61-
ERR_FAIL_COND_V_MSG(fd[0] != 0 || fd[1] != 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
61+
ERR_FAIL_COND_V_MSG(fd[0] != nullptr || fd[1] != nullptr, ERR_ALREADY_IN_USE, "Pipe is already in use.");
6262

6363
path = String("\\\\.\\pipe\\LOCAL\\") + p_path.replace("pipe://", "").replace("/", "_");
6464

65-
HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
65+
HANDLE h = CreateFileW((LPCWSTR)path.utf16().get_data(), GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
6666
if (h == INVALID_HANDLE_VALUE) {
6767
h = CreateNamedPipeW((LPCWSTR)path.utf16().get_data(), PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_NOWAIT, 1, 4096, 4096, 0, nullptr);
6868
if (h == INVALID_HANDLE_VALUE) {
6969
last_error = ERR_FILE_CANT_OPEN;
7070
return last_error;
7171
}
72-
ConnectNamedPipe(h, NULL);
72+
ConnectNamedPipe(h, nullptr);
7373
}
7474
fd[0] = h;
7575
fd[1] = h;
@@ -79,19 +79,19 @@ Error FileAccessWindowsPipe::open_internal(const String &p_path, int p_mode_flag
7979
}
8080

8181
void FileAccessWindowsPipe::_close() {
82-
if (fd[0] == 0) {
82+
if (fd[0] == nullptr) {
8383
return;
8484
}
8585
if (fd[1] != fd[0]) {
8686
CloseHandle(fd[1]);
8787
}
8888
CloseHandle(fd[0]);
89-
fd[0] = 0;
90-
fd[1] = 0;
89+
fd[0] = nullptr;
90+
fd[1] = nullptr;
9191
}
9292

9393
bool FileAccessWindowsPipe::is_open() const {
94-
return (fd[0] != 0 || fd[1] != 0);
94+
return (fd[0] != nullptr || fd[1] != nullptr);
9595
}
9696

9797
String FileAccessWindowsPipe::get_path() const {
@@ -103,7 +103,7 @@ String FileAccessWindowsPipe::get_path_absolute() const {
103103
}
104104

105105
uint64_t FileAccessWindowsPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
106-
ERR_FAIL_COND_V_MSG(fd[0] == 0, -1, "Pipe must be opened before use.");
106+
ERR_FAIL_COND_V_MSG(fd[0] == nullptr, -1, "Pipe must be opened before use.");
107107
ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
108108

109109
DWORD read = 0;
@@ -120,7 +120,7 @@ Error FileAccessWindowsPipe::get_error() const {
120120
}
121121

122122
void FileAccessWindowsPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) {
123-
ERR_FAIL_COND_MSG(fd[1] == 0, "Pipe must be opened before use.");
123+
ERR_FAIL_COND_MSG(fd[1] == nullptr, "Pipe must be opened before use.");
124124
ERR_FAIL_COND(!p_src && p_length > 0);
125125

126126
DWORD read = -1;

drivers/windows/file_access_windows_pipe.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#define WIN32_LEAN_AND_MEAN
4040
#include <windows.h>
4141
class FileAccessWindowsPipe : public FileAccess {
42-
HANDLE fd[2] = { 0, 0 };
42+
HANDLE fd[2] = { nullptr, nullptr };
4343

4444
mutable Error last_error = OK;
4545

editor/animation_track_editor.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -6337,8 +6337,9 @@ bool AnimationTrackEditor::_is_track_compatible(int p_target_track_idx, Variant:
63376337
}
63386338

63396339
if (path_valid) {
6340-
if (is_source_bezier)
6340+
if (is_source_bezier) {
63416341
p_source_value_type = Variant::FLOAT;
6342+
}
63426343
return property_type == p_source_value_type;
63436344
} else {
63446345
if (animation->track_get_key_count(p_target_track_idx) > 0) {

editor/editor_node.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ class EditorNode : public Node {
789789

790790
struct AdditiveNodeEntry {
791791
Node *node = nullptr;
792-
NodePath parent = NodePath();
792+
NodePath parent;
793793
Node *owner = nullptr;
794794
int index = 0;
795795
// Used if the original parent node is lost

editor/gui/editor_quick_open_dialog.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,9 @@ QuickOpenDisplayMode QuickOpenResultContainer::get_adaptive_display_mode(const V
649649

650650
for (const StringName &type : grid_preferred_types) {
651651
for (const StringName &base_type : p_base_types) {
652-
if (base_type == type || ClassDB::is_parent_class(base_type, type))
652+
if (base_type == type || ClassDB::is_parent_class(base_type, type)) {
653653
return QuickOpenDisplayMode::GRID;
654+
}
654655
}
655656
}
656657

editor/plugins/bone_map_editor_plugin.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ void BoneMapper::auto_mapping_process(Ref<BoneMap> &p_bone_map) {
859859

860860
// 4-1. Guess Finger
861861
int tips_index = -1;
862-
bool thumb_tips_size = 0;
862+
bool thumb_tips_size = false;
863863
bool named_finger_is_found = false;
864864
LocalVector<String> fingers;
865865
fingers.push_back("thumb|pollex");
@@ -994,7 +994,7 @@ void BoneMapper::auto_mapping_process(Ref<BoneMap> &p_bone_map) {
994994
}
995995

996996
tips_index = -1;
997-
thumb_tips_size = 0;
997+
thumb_tips_size = false;
998998
named_finger_is_found = false;
999999
if (right_hand_or_palm != -1) {
10001000
LocalVector<LocalVector<String>> right_fingers_map;

editor/plugins/font_config_plugin.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ void EditorPropertyOTVariation::update_property() {
470470
Vector3i range = supported.get_value_at_index(i);
471471

472472
EditorPropertyInteger *prop = memnew(EditorPropertyInteger);
473-
prop->setup(range.x, range.y, false, 1, false, false);
473+
prop->setup(range.x, range.y, false, true, false, false);
474474
prop->set_object_and_property(object.ptr(), "keys/" + itos(name_tag));
475475

476476
String name = TS->tag_to_name(name_tag);

editor/plugins/tiles/tile_map_layer_editor.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,7 @@ int TileMapLayerEditorTilesPlugin::_get_transformed_alternative(int p_alternativ
15501550
case TRANSFORM_ROTATE_RIGHT: {
15511551
// A matrix with every possible flip/transpose combination, sorted by what comes next when you rotate.
15521552
const LocalVector<bool> rotation_matrix = {
1553+
// NOLINTBEGIN(modernize-use-bool-literals)
15531554
0, 0, 0,
15541555
0, 1, 1,
15551556
1, 1, 0,
@@ -1558,6 +1559,7 @@ int TileMapLayerEditorTilesPlugin::_get_transformed_alternative(int p_alternativ
15581559
0, 0, 1,
15591560
0, 1, 0,
15601561
1, 1, 1
1562+
// NOLINTEND(modernize-use-bool-literals)
15611563
};
15621564

15631565
for (int i = 0; i < 8; i++) {

editor/plugins/tiles/tile_set_atlas_source_editor.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class TileSetAtlasSourceEditor : public HSplitContainer {
9191
TileSetAtlasSourceEditor *tiles_set_atlas_source_editor = nullptr;
9292

9393
Ref<TileSetAtlasSource> tile_set_atlas_source;
94-
RBSet<TileSelection> tiles = RBSet<TileSelection>();
94+
RBSet<TileSelection> tiles;
9595

9696
protected:
9797
bool _set(const StringName &p_name, const Variant &p_value);

editor/project_converter_3_to_4.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -716,8 +716,9 @@ Vector<String> ProjectConverter3To4::check_for_files() {
716716
directories_to_check.append(current_dir.path_join(file_name) + "/");
717717
} else {
718718
bool proper_extension = false;
719-
if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".gdshader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj") || file_name.ends_with(".import"))
719+
if (file_name.ends_with(".gd") || file_name.ends_with(".shader") || file_name.ends_with(".gdshader") || file_name.ends_with(".tscn") || file_name.ends_with(".tres") || file_name.ends_with(".godot") || file_name.ends_with(".cs") || file_name.ends_with(".csproj") || file_name.ends_with(".import")) {
720720
proper_extension = true;
721+
}
721722

722723
if (proper_extension) {
723724
collected_files.append(current_dir.path_join(file_name));
@@ -1321,8 +1322,9 @@ Vector<String> ProjectConverter3To4::parse_arguments(const String &line) {
13211322
break;
13221323
};
13231324
case '"': {
1324-
if (previous_character != '\\')
1325+
if (previous_character != '\\') {
13251326
is_inside_string = !is_inside_string;
1327+
}
13261328
}
13271329
}
13281330
previous_character = character;

modules/betsy/image_compress_betsy.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ class BetsyCompressor : public Object {
9191
RenderingDevice *compress_rd = nullptr;
9292
RenderingContextDriver *compress_rcd = nullptr;
9393
HashMap<String, BetsyShader> cached_shaders;
94-
RID src_sampler = RID();
94+
RID src_sampler;
9595

9696
// Format-specific resources.
97-
RID dxt1_encoding_table_buffer = RID();
97+
RID dxt1_encoding_table_buffer;
9898

9999
void _init();
100100
void _assign_mt_ids(WorkerThreadPool::TaskID p_pump_task_id);

modules/camera/camera_feed_linux.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ bool CameraFeedLinux::_request_buffers() {
145145
}
146146

147147
buffers[i].length = buffer.length;
148-
buffers[i].start = mmap(NULL, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, buffer.m.offset);
148+
buffers[i].start = mmap(nullptr, buffer.length, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, buffer.m.offset);
149149

150150
if (buffers[i].start == MAP_FAILED) {
151151
for (unsigned int b = 0; b < i; b++) {

0 commit comments

Comments
 (0)