Cleanup: Clang-Tidy, modernize-use-using

Replace `typedef` with `using` in C++ code.

In the case of `typedef struct SomeName { ... } SomeName;` I removed the
`typedef` altogether, as this is unnecessary in C++. Such cases have been
rewritten to `struct SomeName { ... };`

No functional changes.
This commit is contained in:
Sybren A. Stüvel
2020-12-04 12:46:43 +01:00
parent 10a8286a26
commit 7f2d356a67
13 changed files with 36 additions and 37 deletions

View File

@@ -37,7 +37,6 @@ Checks: >
-modernize-avoid-c-arrays, -modernize-avoid-c-arrays,
-modernize-use-equals-default, -modernize-use-equals-default,
-modernize-use-nodiscard, -modernize-use-nodiscard,
-modernize-use-using,
-modernize-loop-convert, -modernize-loop-convert,
-modernize-pass-by-value, -modernize-pass-by-value,
-modernize-use-default-member-init, -modernize-use-default-member-init,

View File

@@ -132,13 +132,13 @@ static int num_threads_override = 0;
/* just a max for security reasons */ /* just a max for security reasons */
#define RE_MAX_THREAD BLENDER_MAX_THREADS #define RE_MAX_THREAD BLENDER_MAX_THREADS
typedef struct ThreadSlot { struct ThreadSlot {
struct ThreadSlot *next, *prev; struct ThreadSlot *next, *prev;
void *(*do_thread)(void *); void *(*do_thread)(void *);
void *callerdata; void *callerdata;
pthread_t pthread; pthread_t pthread;
int avail; int avail;
} ThreadSlot; };
void BLI_threadapi_init(void) void BLI_threadapi_init(void)
{ {

View File

@@ -32,11 +32,11 @@ static void print_mem_saved(const char *id, const BArrayStore *bs)
/* -------------------------------------------------------------------- */ /* -------------------------------------------------------------------- */
/* Test Chunks (building data from list of chunks) */ /* Test Chunks (building data from list of chunks) */
typedef struct TestChunk { struct TestChunk {
struct TestChunk *next, *prev; struct TestChunk *next, *prev;
const void *data; const void *data;
size_t data_len; size_t data_len;
} TestChunk; };
static TestChunk *testchunk_list_add(ListBase *lb, const void *data, size_t data_len) static TestChunk *testchunk_list_add(ListBase *lb, const void *data, size_t data_len)
{ {
@@ -111,14 +111,14 @@ static char *testchunk_as_data_array(TestChunk **tc_array, int tc_array_len, siz
/* Test Buffer */ /* Test Buffer */
/* API to handle local allocation of data so we can compare it with the data in the array_store */ /* API to handle local allocation of data so we can compare it with the data in the array_store */
typedef struct TestBuffer { struct TestBuffer {
struct TestBuffer *next, *prev; struct TestBuffer *next, *prev;
const void *data; const void *data;
size_t data_len; size_t data_len;
/* for reference */ /* for reference */
BArrayState *state; BArrayState *state;
} TestBuffer; };
static TestBuffer *testbuffer_list_add(ListBase *lb, const void *data, size_t data_len) static TestBuffer *testbuffer_list_add(ListBase *lb, const void *data, size_t data_len)
{ {

View File

@@ -597,7 +597,7 @@ void NodeOperationBuilder::add_complex_operation_buffers()
} }
} }
typedef std::set<NodeOperation *> Tags; using Tags = std::set<NodeOperation *>;
static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op) static void find_reachable_operations_recursive(Tags &reachable, NodeOperation *op)
{ {

View File

@@ -294,10 +294,10 @@ static void zbuf_add_to_span(ZSpan *zspan, const float v1[2], const float v2[2])
/* ******************** VECBLUR ACCUM BUF ************************* */ /* ******************** VECBLUR ACCUM BUF ************************* */
typedef struct DrawBufPixel { struct DrawBufPixel {
const float *colpoin; const float *colpoin;
float alpha; float alpha;
} DrawBufPixel; };
static void zbuf_fill_in_rgba( static void zbuf_fill_in_rgba(
ZSpan *zspan, DrawBufPixel *col, float *v1, float *v2, float *v3, float *v4) ZSpan *zspan, DrawBufPixel *col, float *v1, float *v2, float *v3, float *v4)

View File

@@ -49,7 +49,7 @@ namespace {
typedef deque<OperationNode *> TraversalQueue; typedef deque<OperationNode *> TraversalQueue;
typedef void (*DEGForeachOperation)(OperationNode *op_node, void *user_data); using DEGForeachOperation = void (*)(OperationNode *, void *);
bool deg_foreach_needs_visit(const OperationNode *op_node, const int flags) bool deg_foreach_needs_visit(const OperationNode *op_node, const int flags)
{ {

View File

@@ -2299,8 +2299,8 @@ struct less_SVertex2D {
} }
}; };
typedef Segment<FEdge *, Vec3r> segment; using segment = Segment<FEdge *, Vec3r>;
typedef Intersection<segment> intersection; using intersection = Intersection<segment>;
struct less_Intersection { struct less_Intersection {
segment *edge; segment *edge;

View File

@@ -39,15 +39,15 @@ using namespace blender::gpu;
#define MATRIX_STACK_DEPTH 32 #define MATRIX_STACK_DEPTH 32
typedef float Mat4[4][4]; using Mat4 = float[4][4];
typedef float Mat3[3][3]; using Mat3 = float[3][3];
typedef struct MatrixStack { struct MatrixStack {
Mat4 stack[MATRIX_STACK_DEPTH]; Mat4 stack[MATRIX_STACK_DEPTH];
uint top; uint top;
} MatrixStack; };
typedef struct GPUMatrixState { struct GPUMatrixState {
MatrixStack model_view_stack; MatrixStack model_view_stack;
MatrixStack projection_stack; MatrixStack projection_stack;
@@ -59,7 +59,7 @@ typedef struct GPUMatrixState {
* TODO: separate Model from View transform? Batches/objects have model, * TODO: separate Model from View transform? Batches/objects have model,
* camera/eye has view & projection * camera/eye has view & projection
*/ */
} GPUMatrixState; };
#define ModelViewStack Context::get()->matrix_state->model_view_stack #define ModelViewStack Context::get()->matrix_state->model_view_stack
#define ModelView ModelViewStack.stack[ModelViewStack.top] #define ModelView ModelViewStack.stack[ModelViewStack.top]

View File

@@ -47,7 +47,7 @@
using namespace blender; using namespace blender;
using namespace blender::gpu; using namespace blender::gpu;
typedef struct GPUSelectQueryState { struct GPUSelectQueryState {
/* Tracks whether a query has been issued so that gpu_load_id can end the previous one */ /* Tracks whether a query has been issued so that gpu_load_id can end the previous one */
bool query_issued; bool query_issued;
/* GPU queries abstraction. Contains an array of queries. */ /* GPU queries abstraction. Contains an array of queries. */
@@ -68,7 +68,7 @@ typedef struct GPUSelectQueryState {
int scissor[4]; int scissor[4];
eGPUWriteMask write_mask; eGPUWriteMask write_mask;
eGPUDepthTest depth_test; eGPUDepthTest depth_test;
} GPUSelectQueryState; };
static GPUSelectQueryState g_query_state = {false}; static GPUSelectQueryState g_query_state = {false};

View File

@@ -43,20 +43,20 @@
using namespace blender::gpu; using namespace blender::gpu;
typedef struct GLDrawCommand { struct GLDrawCommand {
GLuint v_count; GLuint v_count;
GLuint i_count; GLuint i_count;
GLuint v_first; GLuint v_first;
GLuint i_first; GLuint i_first;
} GLDrawCommand; };
typedef struct GLDrawCommandIndexed { struct GLDrawCommandIndexed {
GLuint v_count; GLuint v_count;
GLuint i_count; GLuint i_count;
GLuint v_first; GLuint v_first;
GLuint base_index; GLuint base_index;
GLuint i_first; GLuint i_first;
} GLDrawCommandIndexed; };
#define MDI_ENABLED (buffer_size_ != 0) #define MDI_ENABLED (buffer_size_ != 0)
#define MDI_DISABLED (buffer_size_ == 0) #define MDI_DISABLED (buffer_size_ == 0)

View File

@@ -73,8 +73,8 @@ struct IK_Data {
struct IK_Scene *first; struct IK_Scene *first;
}; };
typedef float Vector3[3]; using Vector3 = float[3];
typedef float Vector4[4]; using Vector4 = float[4];
struct IK_Target; struct IK_Target;
typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values, typedef void (*ErrorCallback)(const iTaSC::ConstraintValues *values,
unsigned int nvalues, unsigned int nvalues,

View File

@@ -620,7 +620,7 @@ bool imb_save_openexr(struct ImBuf *ibuf, const char *name, int flags)
static ListBase exrhandles = {nullptr, nullptr}; static ListBase exrhandles = {nullptr, nullptr};
typedef struct ExrHandle { struct ExrHandle {
struct ExrHandle *next, *prev; struct ExrHandle *next, *prev;
char name[FILE_MAX]; char name[FILE_MAX];
@@ -645,10 +645,10 @@ typedef struct ExrHandle {
ListBase layers; /* hierarchical, pointing in end to ExrChannel */ ListBase layers; /* hierarchical, pointing in end to ExrChannel */
int num_half_channels; /* used during filr save, allows faster temporary buffers allocation */ int num_half_channels; /* used during filr save, allows faster temporary buffers allocation */
} ExrHandle; };
/* flattened out channel */ /* flattened out channel */
typedef struct ExrChannel { struct ExrChannel {
struct ExrChannel *next, *prev; struct ExrChannel *next, *prev;
char name[EXR_TOT_MAXNAME + 1]; /* full name with everything */ char name[EXR_TOT_MAXNAME + 1]; /* full name with everything */
@@ -658,10 +658,10 @@ typedef struct ExrChannel {
char chan_id; /* quick lookup of channel char */ char chan_id; /* quick lookup of channel char */
int view_id; /* quick lookup of channel view */ int view_id; /* quick lookup of channel view */
bool use_half_float; /* when saving use half float for file storage */ bool use_half_float; /* when saving use half float for file storage */
} ExrChannel; };
/* hierarchical; layers -> passes -> channels[] */ /* hierarchical; layers -> passes -> channels[] */
typedef struct ExrPass { struct ExrPass {
struct ExrPass *next, *prev; struct ExrPass *next, *prev;
char name[EXR_PASS_MAXNAME]; char name[EXR_PASS_MAXNAME];
int totchan; int totchan;
@@ -672,13 +672,13 @@ typedef struct ExrPass {
char internal_name[EXR_PASS_MAXNAME]; /* name with no view */ char internal_name[EXR_PASS_MAXNAME]; /* name with no view */
char view[EXR_VIEW_MAXNAME]; char view[EXR_VIEW_MAXNAME];
int view_id; int view_id;
} ExrPass; };
typedef struct ExrLayer { struct ExrLayer {
struct ExrLayer *next, *prev; struct ExrLayer *next, *prev;
char name[EXR_LAY_MAXNAME + 1]; char name[EXR_LAY_MAXNAME + 1];
ListBase passes; ListBase passes;
} ExrLayer; };
/* ********************** */ /* ********************** */

View File

@@ -76,12 +76,12 @@ typedef struct HairGridVert {
float velocity_smooth[3]; float velocity_smooth[3];
} HairGridVert; } HairGridVert;
typedef struct HairGrid { struct HairGrid {
HairGridVert *verts; HairGridVert *verts;
int res[3]; int res[3];
float gmin[3], gmax[3]; float gmin[3], gmax[3];
float cellsize, inv_cellsize; float cellsize, inv_cellsize;
} HairGrid; };
#define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) \ #define HAIR_GRID_INDEX_AXIS(vec, res, gmin, scale, axis) \
(min_ii(max_ii((int)((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2)) (min_ii(max_ii((int)((vec[axis] - gmin[axis]) * scale), 0), res[axis] - 2))