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

Addresses some odds and ends #1253

Merged
merged 10 commits into from
Jan 8, 2024
Merged

Conversation

kennyweiss
Copy link
Member

Summary

  • This PR resolves some minor issues/warnings and applies clang-tidy rules to the code
  • Resolves Warning in ArrayBase with XL compiler #1223
  • Resolves clang-tidy warning w/ clang@16.0.6 #1248
    • I couldn't reproduce the issue exactly, but I think the change should resolve it based on the description
  • It also (partially) applies the following clang-tidy rules. In some cases, I had to revert clang-tidy changes, e.g. when it modified the auto-generated shroud files:
    • readability-braces-around-statements
    • modernize-use-using
    • readability-static-definition-in-anonymous-namespace
    • modernize-use-nullptr

@kennyweiss kennyweiss added the maintenance Issues related to code maintenance label Jan 5, 2024
@kennyweiss kennyweiss self-assigned this Jan 5, 2024
@@ -730,22 +730,22 @@ class Array : public ArrayBase<T, DIM, Array<T, DIM, SPACE>>
"Cannot call Array<T>::resize() when T is non-trivially-"
"constructible. Use Array<T>::reserve() and emplace_back()"
"instead.");
const StackArray<IndexType, DIM> dims {static_cast<IndexType>(args)...};
const StackArray<IndexType, DIM> dims {{static_cast<IndexType>(args)...}};
Copy link
Member

@rhornung67 rhornung67 Jan 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

here and throughout

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we don't apply the args with the integral type that is given?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this allows users to supply signed/unsigned integral input and convert it to the represented axom::IndexType (and avoid warnings/compilation errors due to the templated types)

@publixsubfan might have some additional context.

Copy link
Member

@rhornung67 rhornung67 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I just have a variety of minor questions.

@@ -730,22 +730,22 @@ class Array : public ArrayBase<T, DIM, Array<T, DIM, SPACE>>
"Cannot call Array<T>::resize() when T is non-trivially-"
"constructible. Use Array<T>::reserve() and emplace_back()"
"instead.");
const StackArray<IndexType, DIM> dims {static_cast<IndexType>(args)...};
const StackArray<IndexType, DIM> dims {{static_cast<IndexType>(args)...}};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we don't apply the args with the integral type that is given?

src/axom/mint/examples/mint_heat_equation.cpp Outdated Show resolved Hide resolved
@@ -499,7 +499,7 @@ class FiniteElement
/// \name Reference Element Attributes
/// @{

typedef void (*ShapeFunctionPtr)(const double* lc, double* phi);
using ShapeFunctionPtr = void (*)(const double* lc, double* phi);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

here and throughout

@@ -657,9 +657,13 @@ double winding_number(const Point<T, 3>& query,
// Find the direction of a ray perpendicular to that
Vector<T, 3> v1;
if(axom::utilities::isNearlyEqual(v0[0], v0[1], EPS))
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better. this is a clang-tidy change, correct?

typedef double CoordType;
typedef primal::Point<CoordType, DIM> QPoint;
typedef primal::Octahedron<CoordType, DIM> QOct;
using CoordType = double;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it possible to have a chang-tidy rule to catch this sort of thing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These typedef -> using changes were from the modernize-use-using rule

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was actually the impetus for revisiting clang-tidy in this PR -- I had been manually updating the typedefs when I updated old primal test files (e.g. in #1251) and thought clang-tidy would have a modernize-* rule to automate it.

static const std::string C2C_CIRCLE_FILENAME = "test_circle.contour";
static const std::string C2C_SQUARE_FILENAME = "test_square.contour";
static const std::string C2C_SPLINE_FILENAME = "test_spline.contour";
const std::string C2C_LINE_FILENAME = "test_line.contour";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constexpr for these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:) I tried that too and got an error about constexpr and strings.

Looks like we'll have to wait for std::string_view in C++17 -- https://stackoverflow.com/questions/27123306/is-it-possible-to-use-stdstring-in-a-constant-expression

@@ -25,11 +25,11 @@ enum DType
_UnknownType_
};

typedef struct
using AA_extent = struct
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can clang-tidy catch these?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes! (see comment above)

static const SetElement upperIndex = static_cast<SetElement>(.7 * MAX_SIZE);
static const SetElement range = upperIndex - lowerIndex;
constexpr SetPosition MAX_SIZE = 20;
constexpr SetElement lowerIndex = static_cast<SetElement>(.3 * MAX_SIZE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
constexpr SetElement lowerIndex = static_cast<SetElement>(.3 * MAX_SIZE);
constexpr SetElement lowerIndex(.3 * MAX_SIZE);

Does this do the same thing? If so, it is less verbose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it probably makes sense to keep the static_cast here do explicitly highlight the cast from double

Copy link
Member

@BradWhitlock BradWhitlock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let there be "using"!

@kennyweiss kennyweiss merged commit 65dfc3a into develop Jan 8, 2024
12 checks passed
@kennyweiss kennyweiss deleted the feature/kweiss/odds-and-ends branch January 8, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Issues related to code maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clang-tidy warning w/ clang@16.0.6 Warning in ArrayBase with XL compiler
3 participants