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

feature: Add make style target and refactor RAJA with clang-format #1767

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

johnbowen42
Copy link
Contributor

This PR applies clang-format to the include and src directories of develop

@johnbowen42
Copy link
Contributor Author

johnbowen42 commented Nov 13, 2024

@rhornung67 and I worked on the settings this morning. Here is what we settled on:

  • RAJA/.clang-format

    Lines 12 to 16 in c5bee85

    # Alignment of consecutive declarations, assignments etc
    AlignConsecutiveAssignments : true
    AlignConsecutiveDeclarations : false
    AlignConsecutiveMacros : true
    AlignTrailingComments : true
    • example:
    • RAJA_INLINE constexpr IndexValue() = default;
      constexpr RAJA_INLINE IndexValue(IndexValue const&) = default;
      constexpr RAJA_INLINE IndexValue(IndexValue&&) = default;
      RAJA_INLINE IndexValue& operator=(IndexValue const&) = default;
      RAJA_INLINE IndexValue& operator=(IndexValue&&) = default;
  • RAJA/.clang-format

    Lines 20 to 37 in c5bee85

    BraceWrapping:
    AfterCaseLabel: true
    AfterClass: true
    AfterControlStatement: true
    AfterEnum: true
    AfterFunction: true
    AfterNamespace: true
    AfterObjCDeclaration: false
    AfterStruct: true
    AfterUnion: true
    AfterExternBlock: false
    BeforeCatch: true
    BeforeElse: true
    BeforeLambdaBody: false
    IndentBraces: false
    SplitEmptyFunction: false
    SplitEmptyRecord: false
    SplitEmptyNamespace: false
    • This transparently controls whether a curly brace will occur on the next line following anything requiring a curly brace. Basically the only time we don't enforce curly brace on next line is for lambda body definitions and empty function definitions. Another notable exception is single line lambdas:
      AllowShortLambdasOnASingleLine : None
  • BinPackArguments : true
  • BinPackParameters : false
    • This doesn't enforce the same packing for parameters in function declarations
  • AlignAfterOpenBracket: Align
  • LambdaBodyIndentation : Signature
    • disallow single line lambdas, and indent the body one indent level relative to the indent level of the signature, e.g.
      {
      CONTAINER_T tcon;
      forall<seq_exec>(seg, [&](typename CONTAINER_T::value_type idx) {
      if (conditional(idx)) tcon.push_back(idx);
      });
      con = tcon;
  • SeparateDefinitionBlocks : Always
    • enforce spacing between functions and other blocks, e.g.
      {
      return (value >= x.value);
      }
      RAJA_HOST_DEVICE RAJA_INLINE bool operator==(value_type x) const
      {
      return (value == x);
      }
      RAJA_HOST_DEVICE RAJA_INLINE bool operator==(TYPE x) const

@johnbowen42 johnbowen42 force-pushed the feature/bowen/add-clang-format-v2 branch from c11bf7c to 9a33df6 Compare November 14, 2024 23:33
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