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

Fix clang-tidy support for tests and extensibility #237

Merged
merged 10 commits into from
Feb 25, 2022
Merged

Conversation

mlxd
Copy link
Member

@mlxd mlxd commented Feb 14, 2022

Context: This closes #236 and #235

Description of the Change: Clang-tidy is enabled for CI tests in the formatter action, and subsequent clang-tidy suggestions are applied. Also, The return type for data is modified to become auto-definable at compile time.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit .github/CHANGELOG.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

@codecov
Copy link

codecov bot commented Feb 14, 2022

Codecov Report

Merging #237 (4ffa555) into master (86efa02) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #237   +/-   ##
=======================================
  Coverage   99.70%   99.70%           
=======================================
  Files           4        4           
  Lines         344      344           
=======================================
  Hits          343      343           
  Misses          1        1           
Impacted Files Coverage Δ
pennylane_lightning/_version.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 86efa02...4ffa555. Read the comment docs.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 14, 2022

Test Report (C++) on Ubuntu

       1 files  ±0         1 suites  ±0   0s ⏱️ ±0s
   555 tests ±0     555 ✔️ ±0  0 💤 ±0  0 ±0 
2 289 runs  ±0  2 289 ✔️ ±0  0 💤 ±0  0 ±0 

Results for commit 4ffa555. ± Comparison against base commit 86efa02.

♻️ This comment has been updated with latest results.

@chaeyeunpark
Copy link
Contributor

Hi @mlxd, it seems like the current error is due to several unused parameters/variables. In the previous version, I have just suppressed those warnings (only for tests codes) by -Wno-unused as there are too many places with this warning and I thought they are not much harmful (even though some variables are unused, they provide some information e.g. const auto num_qubits = 3;). See the lines below.

target_compile_options(lightning_tests_dependency INTERFACE "-Wall;-Wno-unused;")
target_sources(lightning_tests_dependency INTERFACE runner_main.cpp)

@mlxd
Copy link
Member Author

mlxd commented Feb 14, 2022

Hi @mlxd, it seems like the current error is due to several unused parameters/variables. In the previous version, I have just suppressed those warnings (only for tests codes) by -Wno-unused as there are too many places with this warning and I thought they are not much harmful (even though some variables are unused, they provide some information e.g. const auto num_qubits = 3;). See the lines below.

target_compile_options(lightning_tests_dependency INTERFACE "-Wall;-Wno-unused;")
target_sources(lightning_tests_dependency INTERFACE runner_main.cpp)

Thanks @chaeyeunpark . I have added the casts to get over the failures for now. As discussed, we can look at adapting this to another structure later on.

@mlxd mlxd requested a review from maliasadi February 14, 2022 21:47
Copy link
Member

@maliasadi maliasadi left a comment

Choose a reason for hiding this comment

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

Thanks @mlxd for fixing these issues.

Copy link
Contributor

@chaeyeunpark chaeyeunpark left a comment

Choose a reason for hiding this comment

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

Hi @mlxd, thanks for dealing with this problem. Could you just check one thing here? If clang-tidy still complains about it, let's just remove this whole function (it anyway does nothing now...).

gate_op>::value == nullptr) {
return false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you check clang-tidy still raises errors with these lines? Basically, this template function tests whether GateOpMemberFuncPtr is well defined (in a compile-time). If it is well-defined, as clang-tidy-11 says, it cannot be nullptr. Otherwise, it raises a compile-time error.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @chaeyeunpark

Ah, I understand your intention now. Yea, I was getting errors with these locally, and removed them based on the clang-tidy feedback. I'll re-add and retest with the act package, and if so we can leave them as deleted for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

Huh, seems to be passing now (weird, may have been a version issue locally). I'll re-add this in and push it back up. Sorry for the confusion.

Update: scratch that, fails locally on clang-tidy-13

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 will do some tests with different environments to see if this is an easy mitigation.

Copy link
Contributor

@chaeyeunpark chaeyeunpark Feb 15, 2022

Choose a reason for hiding this comment

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

As it cannot be nullptr anyway, I think replacing the internal if statement just to

static_cast<void>(GateOpToMemberFuncPtr<PrecisionT, ParamT, GateImplemenation, gate_op>::value);

will work (for clang-tidy-13).

Copy link
Member Author

Choose a reason for hiding this comment

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

Hey @chaeyeunpark sorry for taking so long to get back to this. That above suggestion does indeed fix the clang-tidy-13 complaint! Thanks for the suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Good!

Copy link
Contributor

@chaeyeunpark chaeyeunpark left a comment

Choose a reason for hiding this comment

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

Happy to approve this 👍

gate_op>::value == nullptr) {
return false;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Good!

@mlxd
Copy link
Member Author

mlxd commented Feb 25, 2022

Thanks @chaeyeunpark & @maliasadi

@mlxd mlxd merged commit 602352b into master Feb 25, 2022
@mlxd mlxd deleted the crtp_datatypes branch February 25, 2022 19:55
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.

Ensure test suite builds with clang-tidy
3 participants