Bug #3233
clang-format incorrectly aligning altered function arguments
Description
In https://gerrit.gromacs.org/c/gromacs/+/14758, I changed
StatePropagatorData::StatePropagatorData(int numAtoms, FILE* fplog, const t_commrec* cr, t_state* globalState, int nstxout, int nstvout, int nstfout, int nstxout_compressed, bool useGPU, FreeEnergyPerturbationElement* freeEnergyPerturbationElement, const t_inputrec* inputrec, const t_mdatoms* mdatoms) :
to
StatePropagatorData::StatePropagatorData(int numAtoms, FILE* fplog, const t_commrec* cr, t_state* globalState, int nstxout, int nstvout, int nstfout, int nstxout_compressed, bool useGPU, FreeEnergyPerturbationElement* freeEnergyPerturbationElement, const TopologyHolder* topologyHolder, bool canMoleculesBeDistributedOverPBC, bool writeFinalConfiguration, int nfile, const t_filenm* filenm, const t_inputrec* inputrec, const t_mdatoms* mdatoms) :
clang-format does, however, insist to indent this as
StatePropagatorData::StatePropagatorData(int numAtoms, FILE* fplog, const t_commrec* cr, t_state* globalState, int nstxout, int nstvout, int nstfout, int nstxout_compressed, bool useGPU, FreeEnergyPerturbationElement* freeEnergyPerturbationElement, const TopologyHolder* topologyHolder, bool canMoleculesBeDistributedOverPBC, bool writeFinalConfiguration, int nfile, const t_filenm* filenm, const t_inputrec* inputrec, const t_mdatoms* mdatoms) :
History
#1 Updated by Eric Irrgang about 1 year ago
For clarification, is this a discrepancy between different versions of clang-format, or between clang-format and some other tool that you have used?
In this case, it looks like the long-line logic was allowed to override the alignment logic. It seems to me like clang-format made a reasonable choice, so before proposing solutions to this issue, can you clarify the behavior that you think we should target?
Would it be consistent with GROMACS style to have a line break before the fist function parameter and de-indent the parameter list to a standard +4?
Note that clang-format is advertised to function well with line-by-line usage, but that is obviously in conflict with alignment behaviors. It seems like heuristics in support of the two stylistic trends are not yet a solved problem.