Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-tidy: fix error in 'clang-tidy CMake build with Tiles and Sound' #34947

Merged
merged 1 commit into from Oct 23, 2019

Conversation

OrenAudeles
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

Fix an error causing testing build clang-tidy CMake build with Tiles and Sound to fail

error: Construction of 'tripoint' can be simplified using overloaded arithmetic operators. [cata-use-point-arithmetic,-warnings-as-errors]

Describe the solution

Because tripoint_zero is defined as tripoint( 0, 0, 0 ) it is entirely unnecessary to the calculation of the points generating the error and allows simplification of the calculation.
Also changed from const tripoint & to const tripoint. While not an compile error to use a const reference here it is unnecessary.

Additional context

Looks like the bug was introduced during #34866

fixes error: Construction of 'tripoint' can be simplified using
overloaded arithmetic operators.
[cata-use-point-arithmetic,-warnings-as-errors]

Suggested fix by error output is to use:
  const tripoint &pt = tripoint_zero + tripoint(
    delta_x * wall_size,
    delta_y * wall_size,
    delta_z );

tripoint_zero is defined as tripoint(0, 0, 0), so arithmetic operations
would simplify further to just:
  const tripoint &pt(
    delta_x * wall_size,
    delta_y * wall_size,
    delta_z );

Further, while it does not cause an error to use a const reference here
it is unnecessary.
@ZhilkinSerg ZhilkinSerg added Code: Build Issues regarding different builds and build environments [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style labels Oct 23, 2019
@ZhilkinSerg ZhilkinSerg merged commit 3ceb466 into CleverRaven:master Oct 23, 2019
@OrenAudeles OrenAudeles deleted the make_clang_happy branch October 23, 2019 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Build Issues regarding different builds and build environments Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants