libCEED icon indicating copy to clipboard operation
libCEED copied to clipboard

clang-format

Open jedbrown opened this issue 3 years ago • 5 comments

Ratel and PETSc have both moved to clang-format and I'm starting to feel envious when working on libCEED. Shall we do it? And if so, what config should we use? For reference:

  • https://gitlab.com/micromorph/ratel/-/blob/main/.clang-format
  • https://gitlab.com/petsc/petsc/-/blob/main/.clang-format

jedbrown avatar Aug 23 '22 18:08 jedbrown

I'm +1 to converting to Clang format. I'm personally biased a bit towards the Ratel format. I tried to keep it pretty lightweight and close to the defaults. However, I'm just happy to move to a better formatting tool.

jeremylt avatar Aug 23 '22 18:08 jeremylt

The not perfectly automated step to doing this will be to switch from ierr = f(); CeedChk(ierr); to CeedChk(f()); style.

jedbrown avatar Aug 23 '22 18:08 jedbrown

Yeah, that took some fiddling with a find and replace followed by a lot of manual edits in Ratel. Boring but time consuming if there's somebody who would benefit from a tour of the codebase?

jeremylt avatar Aug 23 '22 18:08 jeremylt

I'm happy with Ratel style. I think @Jacobfaib may have more robust automation for that conversion (CHKERRQ to PetscCall).

jedbrown avatar Aug 23 '22 18:08 jedbrown

Yeah, see share/petsc/chkerrconvert.py. Note however that its' pretty PETSc-focused, that is it converts CHKERR<T> to PetscCall<T>. You'd have to modify the script to get it to do what you want here

Jacobfaib avatar Aug 23 '22 18:08 Jacobfaib