Skip to content

Commit

Permalink
Style: Begin integrating simple .clangd fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Repiteo committed Feb 20, 2025
1 parent e567f49 commit 6d3f545
Show file tree
Hide file tree
Showing 65 changed files with 48 additions and 115 deletions.
1 change: 0 additions & 1 deletion .clangd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
Diagnostics:
Includes:
IgnoreHeader:
- core/typedefs\.h # Our "main" header, featuring transitive includes; allow everywhere.
- \.compat\.inc
---
# Header-specific conditions.
Expand Down
1 change: 1 addition & 0 deletions core/error/error_macros.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "error_macros.h"

#include "core/io/logger.h"
#include "core/object/object_id.h"
#include "core/os/os.h"
#include "core/string/ustring.h"

Expand Down
4 changes: 2 additions & 2 deletions core/error/error_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
#ifndef ERROR_MACROS_H
#define ERROR_MACROS_H

#include "core/object/object_id.h"
#include "core/typedefs.h"

#include <atomic> // We'd normally use safe_refcount.h, but that would cause circular includes.
#include <atomic> // IWYU pragma: keep // We'd normally use `safe_refcount.h`, but that would cause circular includes.

class String;
class ObjectID;

enum ErrorHandlerType {
ERR_HANDLER_ERROR,
Expand Down
8 changes: 4 additions & 4 deletions core/extension/gdextension_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
* Together with the JSON file, you should be able to generate any binder.
*/

#ifdef __cplusplus
extern "C" {
#endif

#include <stddef.h>
#include <stdint.h>

Expand All @@ -43,10 +47,6 @@ typedef uint32_t char32_t;
typedef uint16_t char16_t;
#endif

#ifdef __cplusplus
extern "C" {
#endif

/* VARIANT TYPES */

typedef enum {
Expand Down
1 change: 0 additions & 1 deletion core/io/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "image.h"

#include "core/config/project_settings.h"
#include "core/error/error_list.h"
#include "core/error/error_macros.h"
#include "core/io/image_loader.h"
#include "core/io/resource_loader.h"
Expand Down
2 changes: 2 additions & 0 deletions core/math/bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
// and pairable_mask is either 0 if static, or set to all if non static

#include "bvh_tree.h"

#include "core/math/geometry_3d.h"
#include "core/os/mutex.h"

#define BVHTREE_CLASS BVH_Tree<T, NUM_TREES, 2, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>
Expand Down
2 changes: 2 additions & 0 deletions core/math/bvh_abb.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#ifndef BVH_ABB_H
#define BVH_ABB_H

#include "core/math/aabb.h"

// special optimized version of axis aligned bounding box
template <typename BOUNDS = AABB, typename POINT = Vector3>
struct BVH_ABB {
Expand Down
1 change: 0 additions & 1 deletion core/math/bvh_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

#include "core/math/aabb.h"
#include "core/math/bvh_abb.h"
#include "core/math/geometry_3d.h"
#include "core/math/vector3.h"
#include "core/templates/local_vector.h"
#include "core/templates/pooled_list.h"
Expand Down
2 changes: 2 additions & 0 deletions core/math/color_names.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
// the old way leaked memory
// this is not used as often as for more performance to make sense

#include "core/math/color.h"

struct NamedColor {
const char *name;
Color color;
Expand Down
3 changes: 1 addition & 2 deletions core/math/delaunay_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@
#ifndef DELAUNAY_3D_H
#define DELAUNAY_3D_H

#include "core/io/file_access.h"
#include "core/math/aabb.h"
#include "core/math/projection.h"
#include "core/math/vector3.h"
#include "core/templates/list.h"
#include "core/templates/local_vector.h"
#include "core/templates/oa_hash_map.h"
#include "core/templates/vector.h"
#include "core/variant/variant.h"

#include "thirdparty/misc/r128.h"

Expand Down
2 changes: 1 addition & 1 deletion core/math/disjoint_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#ifndef DISJOINT_SET_H
#define DISJOINT_SET_H

#include "core/templates/rb_map.h"
#include "core/templates/hash_map.h"
#include "core/templates/vector.h"

/* This DisjointSet class uses Find with path compression and Union by rank */
Expand Down
2 changes: 2 additions & 0 deletions core/math/geometry_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include "geometry_3d.h"

#include "core/templates/hash_map.h"

void Geometry3D::get_closest_points_between_segments(const Vector3 &p_p0, const Vector3 &p_p1, const Vector3 &p_q0, const Vector3 &p_q1, Vector3 &r_ps, Vector3 &r_qt) {
// Based on David Eberly's Computation of Distance Between Line Segments algorithm.

Expand Down
1 change: 0 additions & 1 deletion core/math/geometry_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

#include "core/math/delaunay_3d.h"
#include "core/math/face3.h"
#include "core/object/object.h"
#include "core/templates/local_vector.h"
#include "core/templates/vector.h"

Expand Down
2 changes: 0 additions & 2 deletions core/math/math_funcs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
#include "core/math/random_pcg.h"
#include "core/typedefs.h"

#include "thirdparty/misc/pcg.h"

#include <float.h>
#include <math.h>

Expand Down
3 changes: 3 additions & 0 deletions core/math/quick_hull.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@

#include "quick_hull.h"

#include "core/templates/hash_map.h"
#include "core/templates/hash_set.h"

uint32_t QuickHull::debug_stop_after = 0xFFFFFFFF;

Error QuickHull::build(const Vector<Vector3> &p_points, Geometry3D::MeshData &r_mesh) {
Expand Down
12 changes: 1 addition & 11 deletions core/math/static_raycaster.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,14 @@

#include "core/object/ref_counted.h"

#if !defined(__aligned)

#if defined(_WIN32) && defined(_MSC_VER)
#define __aligned(...) __declspec(align(__VA_ARGS__))
#else
#define __aligned(...) __attribute__((aligned(__VA_ARGS__)))
#endif

#endif

class StaticRaycaster : public RefCounted {
GDCLASS(StaticRaycaster, RefCounted)
protected:
static StaticRaycaster *(*create_function)();

public:
// Compatible with embree4 rays.
struct __aligned(16) Ray {
struct alignas(16) Ray {
const static unsigned int INVALID_GEOMETRY_ID = ((unsigned int)-1); // from rtcore_common.h

/*! Default construction does nothing. */
Expand Down
2 changes: 0 additions & 2 deletions core/object/make_virtuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,6 @@ def run(target, source, env):
#include "core/object/script_instance.h"
#include <utility>
#ifdef TOOLS_ENABLED
#define _GDVIRTUAL_TRACK(m_virtual, m_initialized)\\
if (_get_extension()->reloadable) {\\
Expand Down
3 changes: 1 addition & 2 deletions core/os/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
#include "core/error/error_macros.h"
#include "core/templates/safe_refcount.h"

#include <stddef.h>
#include <new>
#include <new> // IWYU pragma: keep // `new` operators.
#include <type_traits>

class Memory {
Expand Down
3 changes: 0 additions & 3 deletions core/os/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
#ifndef SEMAPHORE_H
#define SEMAPHORE_H

#include <cstdint>

#ifdef THREADS_ENABLED

#include "core/error/error_list.h"
#include "core/typedefs.h"
#ifdef DEBUG_ENABLED
#include "core/error/error_macros.h"
Expand Down
2 changes: 1 addition & 1 deletion core/string/translation_po.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

#include "translation_po.h"

#ifdef DEBUG_TRANSLATION_PO
#include "core/io/file_access.h"

#ifdef DEBUG_TRANSLATION_PO
void TranslationPO::print_translation_map() {
Error err;
Ref<FileAccess> file = FileAccess::open("translation_map_print_test.txt", FileAccess::WRITE, &err);
Expand Down
2 changes: 1 addition & 1 deletion core/string/ustring.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

// Note: _GODOT suffix added to header guard to avoid conflict with ICU header.

#include "core/string/char_utils.h"
#include "core/string/char_utils.h" // IWYU pragma: export
#include "core/templates/cowdata.h"
#include "core/templates/vector.h"
#include "core/typedefs.h"
Expand Down
1 change: 0 additions & 1 deletion core/templates/cowdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
#include <string.h>
#include <initializer_list>
#include <type_traits>
#include <utility>

template <typename T>
class Vector;
Expand Down
3 changes: 0 additions & 3 deletions core/templates/hash_set.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,8 @@
#ifndef HASH_SET_H
#define HASH_SET_H

#include "core/math/math_funcs.h"
#include "core/os/memory.h"
#include "core/templates/hash_map.h"
#include "core/templates/hashfuncs.h"
#include "core/templates/paged_allocator.h"

/**
* Implementation of Set using a bidi indexed hash map.
Expand Down
2 changes: 1 addition & 1 deletion core/templates/local_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class LocalVector {
}

void sort() {
sort_custom<_DefaultComparator<T>>();
sort_custom<Comparator<T>>();
}

void ordered_insert(T p_val) {
Expand Down
1 change: 0 additions & 1 deletion core/templates/lru.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#ifndef LRU_H
#define LRU_H

#include "core/math/math_funcs.h"
#include "hash_map.h"
#include "list.h"

Expand Down
1 change: 0 additions & 1 deletion core/templates/oa_hash_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#ifndef OA_HASH_MAP_H
#define OA_HASH_MAP_H

#include "core/math/math_funcs.h"
#include "core/os/memory.h"
#include "core/templates/hashfuncs.h"
#include "core/templates/pair.h"
Expand Down
2 changes: 1 addition & 1 deletion core/templates/paged_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include "core/typedefs.h"

#include <type_traits>
#include <typeinfo>
#include <typeinfo> // IWYU pragma: keep // Used in macro.

template <typename T, bool thread_safe = false, uint32_t DEFAULT_PAGE_SIZE = 4096>
class PagedAllocator {
Expand Down
2 changes: 1 addition & 1 deletion core/templates/rid_owner.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "core/templates/safe_refcount.h"

#include <stdio.h>
#include <typeinfo>
#include <typeinfo> // IWYU pragma: keep // Used in macro.

#ifdef SANITIZERS_ENABLED
#ifdef __has_feature
Expand Down
1 change: 0 additions & 1 deletion core/templates/safe_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <atomic>
#include <functional>
#include <initializer_list>
#include <type_traits>

// Design goals for these classes:
// - Accessing this list with an iterator will never result in a use-after free,
Expand Down
2 changes: 1 addition & 1 deletion core/templates/safe_refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#endif

#include <atomic>
#include <type_traits>
#include <type_traits> // IWYU pragma: keep // Used in macros.

// Design goals for these classes:
// - No automatic conversions or arithmetic operators,
Expand Down
4 changes: 2 additions & 2 deletions core/templates/search_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
#ifndef SEARCH_ARRAY_H
#define SEARCH_ARRAY_H

#include <core/templates/sort_array.h>
#include "core/typedefs.h"

template <typename T, typename Comparator = _DefaultComparator<T>>
template <typename T, typename Comparator = Comparator<T>>
class SearchArray {
public:
Comparator compare;
Expand Down
7 changes: 1 addition & 6 deletions core/templates/sort_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,13 @@
break; \
}

template <typename T>
struct _DefaultComparator {
_FORCE_INLINE_ bool operator()(const T &a, const T &b) const { return (a < b); }
};

#ifdef DEBUG_ENABLED
#define SORT_ARRAY_VALIDATE_ENABLED true
#else
#define SORT_ARRAY_VALIDATE_ENABLED false
#endif

template <typename T, typename Comparator = _DefaultComparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
template <typename T, typename Comparator = Comparator<T>, bool Validate = SORT_ARRAY_VALIDATE_ENABLED>
class SortArray {
enum {
INTROSORT_THRESHOLD = 16
Expand Down
7 changes: 2 additions & 5 deletions core/templates/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@
*/

#include "core/error/error_macros.h"
#include "core/os/memory.h"
#include "core/templates/cowdata.h"
#include "core/templates/search_array.h"
#include "core/templates/sort_array.h"

#include <climits>
#include <initializer_list>
#include <utility>

template <typename T>
class VectorWriteProxy {
Expand Down Expand Up @@ -112,7 +109,7 @@ class Vector {
_FORCE_INLINE_ bool has(const T &p_val) const { return find(p_val) != -1; }

void sort() {
sort_custom<_DefaultComparator<T>>();
sort_custom<Comparator<T>>();
}

template <typename Comparator, bool Validate = SORT_ARRAY_VALIDATE_ENABLED, typename... Args>
Expand All @@ -128,7 +125,7 @@ class Vector {
}

Size bsearch(const T &p_value, bool p_before) {
return bsearch_custom<_DefaultComparator<T>>(p_value, p_before);
return bsearch_custom<Comparator<T>>(p_value, p_before);
}

template <typename Comparator, typename Value, typename... Args>
Expand Down
Loading

0 comments on commit 6d3f545

Please sign in to comment.