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

Use override keyword were necessary #948

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

guitargeek
Copy link
Contributor

To avoid future mistakes when overriding functions, this commit suggests to use the override keyword as suggested by clang-tidy.

How this commit was produced:

  1. Compile with CMake, exporting the compile commands as described here: https://stackoverflow.com/questions/20059670/how-to-use-cmake-export-compile-commands

  2. Build

  3. Run this in the build directory: run-clang-tidy -header-filter="interface/.*" -config-file=../.clang-tidy -export-fixes fixes.yaml . -j20

  4. Copy the fixes.yaml back to the main repo and apply fixes with: clang-apply-replacements .

@guitargeek guitargeek changed the title User override keyword were necessary Use override keyword were necessary Apr 17, 2024
@guitargeek guitargeek force-pushed the override branch 2 times, most recently from 7e85616 to 667920e Compare April 17, 2024 19:56
@anigamova
Copy link
Collaborator

@guitargeek could you please update this PR with the latest main to include the new workflow added with this #946 ?

To avoid future mistakes when overriding functions, this commit suggests
to use the `override` keyword as suggested by clang-tidy.

How this commit was produced:

1. Compile with CMake, exporting the compile commands as described here:
   https://stackoverflow.com/questions/20059670/how-to-use-cmake-export-compile-commands

2. Build

3. Run this in the build directory:
   ```
   run-clang-tidy -header-filter="interface/.*" -config-file=../.clang-tidy -export-fixes
 fixes.yaml . -j20
   ```

4. Copy the `fixes.yaml` back to the main repo and apply fixes with:
   ```
   clang-apply-replacements .
   ```

5. Replace `ClassDef` macros with `ClassDefOverride` to be consistent.
Follows up on `91b791a`, making sure that only the right overload is
implemented.

Also, apply the same fix to the `CachingAddNLL` class.
@guitargeek
Copy link
Contributor Author

Sure! I updated the PR. Thanks so much for taking care of it, @anigamova!

@guitargeek
Copy link
Contributor Author

I have updated all my other PRs as well:
https://github.com/cms-analysis/HiggsAnalysis-CombinedLimit/pulls/guitargeek

All these PRs are only technical but necessary for ROOT compatibility, so it would be nice if you can have a look at the others too 👍


virtual ~RooSimultaneousOpt() ;
~RooSimultaneousOpt() override ;

virtual RooAbsReal* createNLL(RooAbsData& data, const RooLinkedList& cmdList) ;
Copy link
Collaborator

Choose a reason for hiding this comment

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

From the compilation output with ROOT 6.22 it looks like this method should also have an override.
I guess it was not automatically added because you ran clang-tidy with a ROOT version > 6.22. Could you please check?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed, but that depends on the root version. I will fix this in a separate commit/PR:
#949

You want me to add that commit also in this PR? Would that make things easier for you?

Copy link
Collaborator

Choose a reason for hiding this comment

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

for this particular method I think it is fine to add it in another PR.
But I just wonder how to make sure that we stay consistent and backward compatible with these override statements. For now it would be great if you could check with 6.22 and 6.26 if it is not difficult, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have combined the PRs after all in this one, that made it easier for me to validate.

I compiled this PR now with 6.22, 6.26, and 6.30 to check that there are no cases in which is get warnings related to overrides. And it is not the case!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants