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

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

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

@ -32,11 +32,11 @@ static void print_mem_saved(const char *id, const BArrayStore *bs)
/* -------------------------------------------------------------------- */
/* Test Chunks (building data from list of chunks) */
typedef struct TestChunk {
struct TestChunk {
struct TestChunk *next, *prev;
const void *data;
size_t data_len;
} TestChunk;
};
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 */
/* 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;
const void *data;
size_t data_len;
/* for reference */
BArrayState *state;
} TestBuffer;
};
static TestBuffer *testbuffer_list_add(ListBase *lb, const void *data, size_t data_len)
{

@ -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)
{

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

@ -49,7 +49,7 @@ namespace {
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)
{

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

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

@ -47,7 +47,7 @@
using namespace blender;
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 */
bool query_issued;
/* GPU queries abstraction. Contains an array of queries. */
@ -68,7 +68,7 @@ typedef struct GPUSelectQueryState {
int scissor[4];
eGPUWriteMask write_mask;
eGPUDepthTest depth_test;
} GPUSelectQueryState;
};
static GPUSelectQueryState g_query_state = {false};

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

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

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

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