Skip to content

HpMultiGrid.H: add default case to switch statements#1306

Closed
lucafedeli88 wants to merge 2 commits intoHi-PACE:developmentfrom
lucafedeli88:add_default_case_to_switch
Closed

HpMultiGrid.H: add default case to switch statements#1306
lucafedeli88 wants to merge 2 commits intoHi-PACE:developmentfrom
lucafedeli88:add_default_case_to_switch

Conversation

@lucafedeli88
Copy link
Contributor

This PR adds the default case to the two switch statements in HpMultiGrid.H, in order to respect the following clang-tidy rule:

With this PR, almost all the checks of the bugprone-* family in clang-tidy v20 would pass, except:

Of these, the first three are probably too annoying to enforce in HiPACE++, while I think that the last one can be useful.

  • Small enough (< few 100s of lines), otherwise it should probably be split into smaller PRs
  • Tested (describe the tests in the PR description)
  • Runs on GPU (basic: the code compiles and run well with the new module)
  • Contains an automated test (checksum and/or comparison with theory)
  • Documented: all elements (classes and their members, functions, namespaces, etc.) are documented
  • Constified (All that can be const is const)
  • Code is clean (no unwanted comments, )
  • Style and code conventions are respected at the bottom of https://github.com/Hi-PACE/hipace
  • Proper label and GitHub project, if applicable

@AlexanderSinn
Copy link
Member

Here, system_type is only supposed to be 1, 2 or 3 so an amrex::Abort() would be more appropriate. The return 0 is just to get rid of compiler warnings.

@lucafedeli88
Copy link
Contributor Author

lucafedeli88 commented Oct 29, 2025

Here, system_type is only supposed to be 1, 2 or 3 so an amrex::Abort() would be more appropriate. The return 0 is just to get rid of compiler warnings.

What about this solution?

    static constexpr int get_num_comps_acf (int system_type) {
        switch (system_type) {
            case 1:
                return 1;
            case 2:
                return 2;
            case 3:
                return 0;
            default:
                amrex::Abort(std::to_string(system_type) + " is not a valid system_type!");
        }
        return 0; //unreachable
    }

@lucafedeli88
Copy link
Contributor Author

The content of this PR has been included in #1303

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