You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a lot of workarounds for clang-format misbehavior. If anyone has free time, it would be very helpful to identify the top issues causing problems, prepare reduced test cases, and report them upstream. (Or fix them, if anyone wants to become a clang-format contributor.) Some issues may already be known: https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+label%3Aclang-format
We often use // clang-format off so that can be a good way to find examples - try removing it and see if something egregious happens. (However, not every occurrence of // clang-format off is working around misbehavior. Sometimes clang-format would do a reasonable job, but we have a particular cosmetic preference, or need to match the formatting of external code. xcharconv_ryu.h is an example of "match external code".) Another common workaround is an empty comment // at the end of a line to force line wrapping.
A non-exhaustive list of common problems:
clang-format sometimes handles concepts poorly, particularly requires expressions (and we have particular preferences for requires stuff versus requires(stuff) versus requires (stuff) depending on the code).
Especially see Toolset update: VS 2022 17.0 Preview 2 #2064: clang-format 12 has extreme trouble with complex non-parenthesized requires-clauses, even within // clang-format off - it gets confused about the level of indentation and damages the rest of the file. We need to add parentheses in order to avoid this.
Variable templates are commonly mishandled, and we love variable templates so this affects us everywhere.
In certain situations, clang-format doesn't respect our 120-column limit.
We love clang-format 😻 which is why we've formatted the entire STL since VS 2019 16.0 and have a validator that breaks the build when a file isn't clang-formatted. We just want it to be even better!
We have a lot of workarounds for clang-format misbehavior. If anyone has free time, it would be very helpful to identify the top issues causing problems, prepare reduced test cases, and report them upstream. (Or fix them, if anyone wants to become a clang-format contributor.) Some issues may already be known: https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+label%3Aclang-format
We often use
// clang-format offso that can be a good way to find examples - try removing it and see if something egregious happens. (However, not every occurrence of// clang-format offis working around misbehavior. Sometimes clang-format would do a reasonable job, but we have a particular cosmetic preference, or need to match the formatting of external code.xcharconv_ryu.his an example of "match external code".) Another common workaround is an empty comment//at the end of a line to force line wrapping.A non-exhaustive list of common problems:
requiresexpressions (and we have particular preferences forrequires stuffversusrequires(stuff)versusrequires (stuff)depending on the code).// clang-format off- it gets confused about the level of indentation and damages the rest of the file. We need to add parentheses in order to avoid this.SpacesInLineCommentPrefixis extremely damaged)We love clang-format 😻 which is why we've formatted the entire STL since VS 2019 16.0 and have a validator that breaks the build when a file isn't clang-formatted. We just want it to be even better!