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

Reduce clang-tidy errors and warnings #448

Merged
merged 2 commits into from
Jun 5, 2021

Conversation

tusharpm
Copy link
Contributor

@tusharpm tusharpm commented Jun 5, 2021

Problem:

  • the following error is reported because clang-tidy doesn't include inline namespaces in the qualified name:
test/ut/ut.cpp:286:21: error: static_assert expression is not an integral constant expression [clang-diagnostic-error]
      static_assert("void"sv ==
                    ^
/Users/runner/work/ut/ut/build/../include/boost/ut.hpp:234:12: note: cannot refer to element 70 of array of 63 elements in a constant expression
  return {&__PRETTY_FUNCTION__[70], sizeof(__PRETTY_FUNCTION__) - 72};
  • clang-tidy reports the following warnings:
include/boost/ut.hpp:263:3: warning: multiple declarations in a single statement reduces readability [readability-isolate-declaration]

include/boost/ut.hpp:285:19: warning: do not declare C-style arrays, use std::array<> instead [modernize-avoid-c-arrays]

Solution:

  • Add preprocessor check for __clang_analyzer__ and reduce prefix length by 13 for the two inline namespaces (::ext, ::v1_1_8.
  • Replace C-style arrays with std::array. Refactor math::num and printer::color to remove array usage.
  • Separate multiple variable declarations to individual statements.

Issue: #423

Reviewers:
@krzysztof-jusiak

- modernize-avoid-c-arrays
- readability-isolate-declaration

!squash: add const back
clang-tidy doesn't include inline namespaces in the qualified name.
As a result __PRETTY_FUNCTION__ is shorter than clang's.
Check __clang_analyzer__ and reduce prefix length if defined.
@kris-jusiak kris-jusiak merged commit 241f340 into boost-ext:master Jun 5, 2021
@kris-jusiak
Copy link
Contributor

Thanks @tusharpm

@tusharpm tusharpm deleted the clang-tidy branch June 5, 2021 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants