My thoughts (as one of the people who pushed for this RFC) are that we have a few options:
I personally LIKE #1 in theory, but the ship has sailed, and it is at the expense of GOOD formatting options.
I personally HATE #2, I think it makes the tool unusable as a formatting tool.
I personally quite like #3, and believe it should be the policy going forward (which I believe is the RIGHT outcome of this RFC). I also believe the patch for left/right const already falls into this category, and thus would be generally acceptable to me (though, I think the include-reordering distinctly does NOT).
-Erich
_______________________________________________
cfe-dev mailing list
cfe...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Regarding the 3 possibilities Erich has listed below, my personal opinion here is that option 3 is incredibly dangerous. If the tool is forbidden to break code, then you can be confident that it doesn’t break code (barring bugs). If the tool is allowed to change code such that it potentially breaks code, then at least you know what you’re getting yourself in for. If the tool “almost never” breaks code, then it can lull you into a false sense of security. Unless the tool screams from the rooftops that it might break your code, it’s really easy to assume that it is in fact providing the “does not break code” guarantee. Even if it’s documented, people will make this assumption (just like people constantly add UB to c++ codebases). In practice, you really want to provide 1 or 3 regardless, because it would be nice if the tool didn’t go out of it’s way to break your code, but it shouldn’t advertise that it is 3.
I think that 1 should be the default. It should be documented that, by default, clang-format will not break your code, and if it does that it is a bug. Then, options can be enabled that potentially break code. In effect, it would be Erich’s option 3, but with the caveat that if you do not opt into potentially breaking options, you have option 1. Additionally, `BasedOnStyle` and similar options that turn several knobs at once should also be guaranteed to be non-breaking. Furthermore, we should turn off existing potentially-breaking settings such as include sorting by default. While this may result in clang-format doing something different between versions with the same config, that ship has also sailed, so I think that’s fine. In the documentation for options, it should clearly state if an option has the potential to break your code.
Thanks,
Christopher Tetreault
From: llvm-dev <llvm-dev...@lists.llvm.org> On Behalf Of
Keane, Erich via llvm-dev
Sent: Monday, August 9, 2021 12:46 PM
To: MyDeveloper Day <mydevel...@gmail.com>; llvm-dev <llvm...@lists.llvm.org>
Subject: Re: [llvm-dev] [cfe-dev] [RFC] Adding support for clang-format making further code modifying changes
WARNING: This email originated from outside of Qualcomm. Please be wary of any links or attachments, and do not enable macros.
Commit:
https://github.com/llvm/llvm-project/commit/d89ae9d3accb4cb8b7357932c3dfba8f4ae383c4
Patch discussion:
https://reviews.llvm.org/D11240
It doesn't look like there was any explicit discussion about the
potential for breaking code (but maybe I missed some, and maybe some
discussion happened in a different thread I've not yet found).
~Aaron
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
On Mon, Aug 9, 2021 at 3:55 PM David Blaikie via cfe-dev
<cfe...@lists.llvm.org> wrote:
>
> +some of the folks involved in the early development of clang-format who might have more context on those design principles/choices made back then (& perhaps on the include reordering change/tradeoff/choices made there)
>
> Anyone got a link to the include reordering change/design discussion for it? Might be informative to see if there was precedent/philosophy clearly stated about how that was acceptable and what principles were applied & could be reapplied to more recent proposals.
Commit:
https://github.com/llvm/llvm-project/commit/d89ae9d3accb4cb8b7357932c3dfba8f4ae383c4
Patch discussion:
https://reviews.llvm.org/D11240
It doesn't look like there was any explicit discussion about the
potential for breaking code (but maybe I missed some, and maybe some
discussion happened in a different thread I've not yet found).
I'd just offer a few thoughts:- Whether or not to adopt clang-format for a project is already quite controversial in some places. I think if we made it so that it also made more extensive non-whitespace changes, I think it would reduce its adoption, even if they were off by default.
- Non-whitespace changes are very dangerous. A bug in clang-format could more easily create bugs in the code it formats (at least that is the perception). For some risk-averse projects, this would be an unacceptable risk.- Perhaps an alternative idea would be to create a new program called clang-reshape or something, that shared a common underlying framework with clang-format, but clang-reshape contains the options for both the non-whitespace changes and whitespace-changes, whereas clang-format only has the whitespace changes. That way folks could adopt clang-format and ban clang-reshape if they only wanted whitespace changes.
HTH. -Andrew
_______________________________________________
cfe-dev mailing list
cfe...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
I'm cautiously +1 on const reordering, having previously opposed it and been convinced.I think anyone who's worked on a large shared codebase both before and after clang-format can understand the value here, so I'll focus mostly on the risks and why I think they're acceptable.Risk: clang-format will become a grab-bag of features with no clear line - just anything implemented on top of its pseudo-AST.Clang-format's brand is low-level formatting details and I think it's important to preserve this. Const order fits here in users' minds. (So does brace addition/removal).
Risk: The feature will break code and clang-format will no longer be (seen as) reliable. This can make it harder socially or technically to deploy, and cause real damage.I think we need to work hard on mitigating this:- the feature needs careful design and extra scrutiny, like security-critical code- it should be clearly and temporarily marked as experimental, with opt-in required- it should be clearly and permanently marked as "makes assumptions about coding style", with opt-in required.- bugs need to be thoughtfully addressedFrom what I can see MyDeveloperDay is serious about doing all of this.
Risk: clang-format will be overtaken by the complexity of such features, which will outweigh the benefits (if few use them), hurting maintenance, causing bugs etc.However this isn't different from other optional features. Editing tokens tends to be done as a separate pass which is relatively easy to isolate (compared to something like supporting a new language). With complexity isolated, this is mostly just about how maintainers prioritize their time/attention, which must be left up to them.
Regarding include-ordering: I think this is a valuable feature if you follow a coding style that allows it to be correct, and it fits well in clang-format's brand. However it wasn't clearly labeled to emphasize its caveats, and in hindsight it shouldn't have been made part of the Google style without further opt-in required.
Kind regards,
Björn (HazardyKnusperkeks).
Am 10.08.2021 um 10:32 schrieb MyDeveloper Day via cfe-dev:
> Thanks for the response Sam,
>
> Here is how I see we mitigate the risk:
>
> On Mon, Aug 9, 2021 at 11:23 PM Sam McCall <samm...@google.com
> <mailto:samm...@google.com>> wrote:
>
> I'm cautiously +1 on const reordering, having previously opposed it and been
> convinced.
> I think anyone who's worked on a large shared codebase both before and after
> clang-format can understand the value here, so I'll focus mostly on the
> risks and why I think they're acceptable.
>
> *Risk: *clang-format will become a grab-bag of features with no clear line -
> just anything implemented on top of its pseudo-AST.
> Clang-format's brand is low-level formatting details and I think it's
> important to preserve this. Const order fits here in users' minds. (So does
> brace addition/removal).
>
>
> I doubt we wouldn't continue to apply the same level of scrutiny on the code
> reviews and expect them to follow best practices and guidelines, I am expecting
> us to still be quite circumspect as to what we'd consider.
>
> To be honest clang-format I think already runs at quite a high review rejection
> rate, people ask for all sorts of things and we do try to push back pretty hard,
> landing something can sometimes be pretty torturous to get through review,
> I'm not expecting that to change.
>
>
> *Risk*: The feature will break code and clang-format will no longer be (seen
> as) reliable. This can make it harder socially or technically to deploy, and
> cause real damage.
> I think we need to work hard on mitigating this:
> - the feature needs careful design and extra scrutiny, like
> security-critical code
> - it should be clearly and temporarily marked as experimental, with opt-in
> required
> - it should be clearly and permanently marked as "makes assumptions about
> coding style", with opt-in required.
> - bugs need to be thoughtfully addressed
> From what I can see MyDeveloperDay is serious about doing all of this.
>
>
> I am, I also think that we shouldn't plough on with individual changes if we see
> them as potentially ambiguous, I would rather ignore a change if in doubt, I
> don't feel such features need to be 100% catch all (like how sometimes clang
> doesn't always tell you about all missing overrides, just as it can rationalize
> them), This may require more specific options to ensure we know what an
> tok::identifier actually is in order to avoid ambiguities caused by macros (a
> little like StatementMacros)
>
>
> *Risk*: clang-format will be overtaken by the complexity of such features,
> _______________________________________________
> cfe-dev mailing list
> cfe...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
_______________________________________________
I feel this is something that clang-format could be made to easily handle. This RFC is about gaining a general consensus to let us try. We feel we can add even more value.Anyone who knows me, knows I'm very much pro "clang-format all the things"
cheers,--renato
The problem I've seen is that the opinion of code formatted with 3 lines
of context can differ from 5 lines of context which can be still
different again given the entire file. The only reliable way we've
gotten it to work is to format the whole file every time. But we require
well-formatted code via CI processes, so that's fine (if one can afford
the "rewrite the world" every time the tool gets updated…hence why some
projects are still on version 3.8(!), others 6, some even made it to 9).
--Ben
On Tue, Aug 10, 2021 at 13:13:09 +0200, Manuel Klimek via cfe-dev wrote:
> clang-format is designed to run on changed lines, not to have all code be
> compliant. You can use it for the latter, but I think it's a pretty
> fundamental difference in development goals.
The problem I've seen is that the opinion of code formatted with 3 lines
of context can differ from 5 lines of context which can be still
different again given the entire file. The only reliable way we've
gotten it to work is to format the whole file every time. But we require
well-formatted code via CI processes, so that's fine (if one can afford
the "rewrite the world" every time the tool gets updated…hence why some
projects are still on version 3.8(!), others 6, some even made it to 9).
IIRC, Phab deals with "patches" that have infinite context, but that's
not the norm out there. Maybe that's where this assumption comes from?
Anyways, the main issue I've seen is that developers have versions X, Y,
and Z laying around locally depending on their distro or whatever. So
developers' machines "fight" with CI and each other over the preferred
setup. This is why I don't use any formatting-on-save features myself
with any tool: it's CI's job to enforce it, so why am I wasting my time
on pre-commit hooks that aren't even necessarily accurate? It also makes
teasing out my change with `git add -p` that much harder. So instead, I
just say "ignore formatting if you don't have the exact right version
laying around; CI will handle it". The tool we use can rewrite the
entire topic to ensure it is well-formatted at each step on demand. In
fact, we update `clang-format` versions using this mechanism: tell it to
use a new version, update the config as necessary, and then tell it to
format the entire tree using the new setup.
I come down on the side of not wanting my code formatting tool to be
opinionated about the input source code I feed it. For my personal
needs, I need to be able to trust my formatting tool won't modify the
meaning of my code. If it modifies the meaning in a way that gets
compile errors, that's bad (it means I'm having to work around a
helper tool in order to pass my CI pipeline, which is highly
frustrating). I know that clang-format already happily breaks code
with include sorting, and I think it was a mistake to add that
functionality, especially given the lack of discussion about breaking
code during the original review of the feature. Changes that can
*silently* change the meaning of my code are an even worse concern
because of the increased risk of not noticing the semantic change.
(Keep in mind that some workflows will format an entire file when
saving the file, so there may not even be direct user interaction
involved in the formatting.)
Putting potentially breaking changes behind configuration flags is a
solution, but not one that I'm all that excited by. There are already
*a lot* of configuration options for clang-format, and having to
remember which ones may destroy my input source is a burden. We could
use a naming convention to clearly identify all of these options, but
the first time we have a configuration option that doesn't follow the
naming convention, we're back to the "I can't know which options are
high-risk" problem. Also, the fact that configuration options can be
impacted by non-local configuration files elsewhere in the file system
hierarchy can cause surprising configuration option behavior (I know
we've run into the situation before where an inherited config option
caused a bit of head-scratching as to where the option was set).
I think the idea of a separate tool that's built on top of
clang-format (consuming clang-format as a library with additional
formatting features) has the most appeal to me. Then we no longer have
to worry about the config options being the gate -- the tool is the
deciding factor as to whether you want to opt into danger mode or not.
One of the architectural benefits of designing a series of composable
libraries is the ability to compose them into more powerful tools, I
think we should take advantage of that. This also provides a migration
path for more experimental functionality -- it can be implemented in
the more dangerous tool, shake out the bugs from there, and then be
shuffled into the safer tool if/when the issues have been worked out.
Experience has taught me that just about the worst thing a tool can do
is break user trust, and once you break that trust, you almost never
get it back again. clang-format is a fantastic tool, but the more
opinionated it becomes about source input, the less people are able to
use it (by definition).
~Aaron
> _______________________________________________
> cfe-dev mailing list
> cfe...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
On Tue, Aug 10, 2021 at 13:13:09 +0200, Manuel Klimek via cfe-dev wrote:
> clang-format is designed to run on changed lines, not to have all code be
> compliant. You can use it for the latter, but I think it's a pretty
> fundamental difference in development goals.
The problem I've seen is that the opinion of code formatted with 3 lines
of context can differ from 5 lines of context which can be still
different again given the entire file. The only reliable way we've
gotten it to work is to format the whole file every time. But we require
well-formatted code via CI processes, so that's fine (if one can afford
the "rewrite the world" every time the tool gets updated…hence why some
projects are still on version 3.8(!), others 6, some even made it to 9).
--Ben
_______________________________________________
FWIW, I've never had the impression that this was the status quo for
the tool. I've looked through the mailing list archives and some old
reviews and I don't see any supporting evidence one way or the other
(obviously I could have missed something though!).
~Aaron
FWIW, I run a multi million line project, we run the bleeding edge, last released version, each release of Clang-Format I have maybe 10-20 files to change. If I left it 5 or so releases I'm sure the impact would seem greater.
On Tue, Aug 10, 2021 at 7:37 AM Manuel Klimek via llvm-dev
<llvm...@lists.llvm.org> wrote:
>
> Fwiw, I think "clang-format can make breaking changes to code when we consider the benefit to be worth it" has been the policy on clang-format for a very long time, so accepting that as the official policy is IMO not a change. If somebody wants to write it down to prevent future revisiting, that seems fine with me.
FWIW, I've never had the impression that this was the status quo for
the tool. I've looked through the mailing list archives and some old
reviews and I don't see any supporting evidence one way or the other
(obviously I could have missed something though!).
I agree that that was probably not obvious or stated very clearly anywhere - clang-format for years was basically developed by a small team without much interest in input by the rest of the world, for a very specific use case.At the time we did not do a great job at spreading our thoughts with the world, as a lot of discussions were in person.
On Tue, 10 Aug 2021 at 15:55, Manuel Klimek via llvm-dev <llvm...@lists.llvm.org> wrote:I agree that that was probably not obvious or stated very clearly anywhere - clang-format for years was basically developed by a small team without much interest in input by the rest of the world, for a very specific use case.At the time we did not do a great job at spreading our thoughts with the world, as a lot of discussions were in person.I think there's more to that than what was created by the people who created it.After being used extensively by people around the world, clang-format has perhaps grown to something that the original team did not envision.However, as a public clang tool, and as part of the LLVM "family", it's no longer "a tool used by the team that created it", and not even "a tool used by LLVM developers". It is truly a public tool maintained by the LLVM community.As such, I think we shouldn't restrict the design goals to the original design, or to what a small sub-group uses it for. Clang-format is an official tool like other visible stuff and should have the same community oversight as everything else.There is a high demand for a formatting tool that can do so much more than the original design and people have been using it, albeit precariously, for that purpose already.
So I believe the original policy that "breaking changes are a benefit" can still be valid in a number of places, but it does not (and should not) need to be the only valid case. Definitely not the default, either.I think we need to take a step back and ask users what they expect, rather than push forward a policy that people never really wanted but coped with it anyway because there's nothing better.FWIW, borrowing suggestions from others in this thread, I propose we change the policy to:* Breaking changes off by default, override behaviour with configuration files* All behaviour must be controlled by a configuration flag with options explicit on doc/config* Make explicit some options are breaking (comment/naming)* Backwards compatibility is pursued, but can be broken in case of clear bugs
An easy way to manage the configuration in this case is to have a dump function (`clang-format --dump --config foo.cfg`) that reads a config file and dumps all missing parameters and their current values.Inline comments would be nice but make configuration management hard, so there could be a webpage that describes all options and the URL is dumped on the config file.cheers,--renato
Mixed feelings - we don't necessarily have to let users dictate the feature set, if they aren't contributing to it. Like users using -Weverything, that is ill advised and we are/should be more than happy to break them at any turn. We do get to make choices about what uses we are developing the tools for.
I think that's more-or-less what MyDeveloperDay has been saying? I think that sounds reasonable to me (we could potentially rename the existing features that do change more than whitespace, like include sorting - to match the naming convention of "this changes the token sequence/can have an effect on how/whether code compiles" - while keeping it on by default for backwards compatibility).
On Tue, 10 Aug 2021 at 17:43, David Blaikie <dbla...@gmail.com> wrote:Mixed feelings - we don't necessarily have to let users dictate the feature set, if they aren't contributing to it. Like users using -Weverything, that is ill advised and we are/should be more than happy to break them at any turn. We do get to make choices about what uses we are developing the tools for.Ah, that's not what I meant. I agree with you.I meant there is a lot of potential for things that we (LLVM developers) are saying we want (in this thread) and we should pursue it without having to be bound by the "original design".
I think the idea of a separate tool that's built on top of
clang-format (consuming clang-format as a library with additional
formatting features) has the most appeal to me.
First of all, thank you so much for writing up this clear and mostly balanced summary of the situation, the concerns, and the decision point ahead here.I think there is a something fundamental problem to the nature of this discussion: we can all make semi-informed guesses about how well a particular format will work in practice, but we can’t know until there is usage experience. Furthermore, clang-format has multiple different communities with different tradeoffs, and imposing a new format on an existing codebase has concerns.Clang format is already highly parameterized to support this, are you saying that there is pushback on adding new off-by-default capabilities to clang-format, or is the pushback about adding these capabilities to existing language modes (llvm style, google style, etc)? I don’t see an obvious problem with introducing off-by-default capabilities.I can see a reasonable concern about introducing “const moving” or other new things into existing formats by default - that could be disruptive, and depends a lot about how well the algorithm and implementation works in practice. Two thoughts on how to make progress here:1) You could implement these things in an off-by-default setting, ship it out to lots of people, then gain data somehow (e.g. ask for feedback).2) We could introduce a new top level “changing my code is allowed” mode to clang-format and put these checks into that. You could even conceptually move namespace commenting and include sorting to that mode, making clang-format more consistent.
Fair - though I think it's insightful to know where things started/what the goals were (& some of those are still relevant, since that original use case is still a major use case), though it sounds like the direction we're discussing is pretty compatible with that original vision - Google style can continue to opt in to things consistent with that original vision of "more than whitespace changes when they're worth it" while keeping them off by default for unconfigured clang-format to make it safer-by-default. (LLVM will probably opt into some too, I imagine - like brace addition/removal, etc) Given both Google and LLVM are specific styles anyway, opting them into some of these more-than-whitespace features while having them otherwise off by default seems quite fine to me.
On Tue, 10 Aug 2021 at 15:55, Manuel Klimek via llvm-dev <llvm...@lists.llvm.org> wrote:I agree that that was probably not obvious or stated very clearly anywhere - clang-format for years was basically developed by a small team without much interest in input by the rest of the world, for a very specific use case.At the time we did not do a great job at spreading our thoughts with the world, as a lot of discussions were in person.I think there's more to that than what was created by the people who created it.After being used extensively by people around the world, clang-format has perhaps grown to something that the original team did not envision.However, as a public clang tool, and as part of the LLVM "family", it's no longer "a tool used by the team that created it", and not even "a tool used by LLVM developers". It is truly a public tool maintained by the LLVM community.As such, I think we shouldn't restrict the design goals to the original design, or to what a small sub-group uses it for. Clang-format is an official tool like other visible stuff and should have the same community oversight as everything else.There is a high demand for a formatting tool that can do so much more than the original design and people have been using it, albeit precariously, for that purpose already.So I believe the original policy that "breaking changes are a benefit" can still be valid in a number of places, but it does not (and should not) need to be the only valid case. Definitely not the default, either.I think we need to take a step back and ask users what they expect, rather than push forward a policy that people never really wanted but coped with it anyway because there's nothing better.FWIW, borrowing suggestions from others in this thread, I propose we change the policy to:* Breaking changes off by default, override behaviour with configuration files* All behaviour must be controlled by a configuration flag with options explicit on doc/config* Make explicit some options are breaking (comment/naming)* Backwards compatibility is pursued, but can be broken in case of clear bugs
An easy way to manage the configuration in this case is to have a dump function (`clang-format --dump --config foo.cfg`) that reads a config file and dumps all missing parameters and their current values.Inline comments would be nice but make configuration management hard, so there could be a webpage that describes all options and the URL is dumped on the config file.cheers,--renato
* Breaking changes off by default, override behaviour with configuration files
* All behaviour must be controlled by a configuration flag with
options explicit on doc/config
* Make explicit some options are breaking (comment/naming)
* Backwards compatibility is pursued, but can be broken in case of clear bugs
Unless there is strong opposition to this, then I'd say MyDeveloperDay
has an answer to their RFC. Any disagreement?
~Aaron
On Wed, Aug 11, 2021 at 4:37 AM Mehdi AMINI via cfe-dev
Thanks to everyone who participated in the discussion, and especially
to MyDeveloperDay for getting this started. Now that discussion on
this RFC seems to have died down, I think it's worth circling back to
see if we have consensus to move forward. From reading the threads, I
think Renato summarized the consensus position nicely:
* Breaking changes off by default, override behaviour with configuration files
* All behaviour must be controlled by a configuration flag with
options explicit on doc/config
* Make explicit some options are breaking (comment/naming)
* Backwards compatibility is pursued, but can be broken in case of clear bugs
* Backwards compatibility is pursued, but can be broken in case of clear bugsWhich I think is also tangential to the current RFC, and IMO should be treated in a separate discussion if necessary (this is a fundamental problem with how clang-format is designed).
Thank you for the feedback! I'm personally fine dropping that last
bullet if it's contentious. I think consensus on the first three
bullets are what's necessary to unblock MyDeveloperDay's review.
~Aaron
It's the algorithm - clang-format is a numerical optimizer of "beauty" - any small changes can lead to the numerical outputs changing slightly, which then leads to slight diffs in how code is formatted where two options were previously considered very "similarly beautiful". It's not happening super often, but it does happen.I agree that we shouldn't introduce changes to formatting without good reasons, but we can't restrict changes only to bug fixes - new features can introduce changes, too.
To me, the crux of my concern isn't nonwhitespace changes, but changes
that can make code which used to compile no longer do so. It just so
happens that nonwhitespace changes are where that risk is highest, but
whitespace changes can impact syntactic validity (such as reformatting
preprocessor directives which terminate with an end of line) and
nonwhitespace changes can (in theory) be written to not break code
(such as inserting parentheses in expressions such that they match the
current order of operations used by the expression). So I prefer
"breaking changes" because it captures the concern better, but I'd
reword it to "potentially breaking changes" to improve clarity. It's
not that we expect the option to break significant code (that'd be
bad), it's that we anticipate that it *could* break code and that's
why it's treated with greater caution.
~Aaron
On Sat, Aug 28, 2021 at 3:48 AM David Blaikie <dbla...@gmail.com> wrote:
>
> +1 to what Manuel's said here.
>
> One slight change I'd suggest is changing the term "breaking changes" to "non-whitespace changes", perhaps? (they aren't necessarily breaking anything) At least I assume that's the intent, but I might be wrong in which case I'd love to better understand what's being proposed.
To me, the crux of my concern isn't nonwhitespace changes, but changes
that can make code which used to compile no longer do so. It just so
happens that nonwhitespace changes are where that risk is highest
On Sat, Aug 28, 2021 at 3:48 AM David Blaikie <dbla...@gmail.com> wrote:
>
> +1 to what Manuel's said here.
>
> One slight change I'd suggest is changing the term "breaking changes" to "non-whitespace changes", perhaps? (they aren't necessarily breaking anything) At least I assume that's the intent, but I might be wrong in which case I'd love to better understand what's being proposed.
To me, the crux of my concern isn't nonwhitespace changes, but changes
that can make code which used to compile no longer do so. It just so
happens that nonwhitespace changes are where that risk is highest, but
whitespace changes can impact syntactic validity (such as reformatting
preprocessor directives which terminate with an end of line) and
nonwhitespace changes can (in theory) be written to not break code
(such as inserting parentheses in expressions such that they match the
current order of operations used by the expression). So I prefer
"breaking changes" because it captures the concern better, but I'd
reword it to "potentially breaking changes" to improve clarity. It's
not that we expect the option to break significant code (that'd be
bad), it's that we anticipate that it *could* break code and that's
why it's treated with greater caution.
But because it (has the potential to) change the token sequence, it is qualitatively more dangerous than a formatter that merely reformats the existing token sequence.
Sort of? My thinking is: if someone comes up with a test case that the
clang-format developers do not consider to be a bug (and thus don't
intend to "fix" the behavior), then we absolutely should document it
as described. (Also, I think it should be an explicit test case
showing the behavior with a comment about it being expected behavior
-- that helps with communication if someone files a bug about it.) If
no one can come up with a test case that would break, I'd be fine if
we still classified it as a potentially breaking change based on
whitespace vs not whitespace or some other metric, but my bigger point
is that if someone can demonstrate a test case that break that isn't
sufficiently compelling to change the tool to handle better, that
definitely meets the bar for being opt-in.
> Perhaps we'll end up with easy idioms/obvious proofs that apply to whole classes (perhaps, for instance, there's an easy/obvious/reusable proof that applies to most cases of token reordering similar to what Arthur showed?) of changes & that'll keep the burden of proof fairly low?
That seems plausible.
> In any case, I see the language is intentional, and if the folks working on this are comfortable with it, I'll leave it to you folks - thanks for explaining!
Any time, thanks for the discussion!
~Aaron
Ah, I see where your concerns come in now. Thank you! I was
envisioning that once we moved an option from on-by-default to
off-by-default, it would most likely never move again. My assumption
is: if the breaking change could be fixed, it would have been fixed or
confirmed as a bug rather than switching to off-by-default. So we
could have some on-by-default checks that DO change code for a while,
but there's a grace period of sorts where clang-format can work on the
fix to the bug. If the bug turns out to not be fixable or no one shows
an interest in fixing it by the time there's a second reporter, then
we switch it to off-by-default at that point and it stays there,
barring extenuating circumstances. Because of the inexact nature of
how clang-format works, I guess my feeling is that once a
transformation has been demonstrated to break code in a way that's
difficult enough we needed to turn the feature off by default, it's
reasonable to assume it's going to break other code we've not
considered yet and so the bar is raised much higher to try to switch
it back to on-by-default, so these flip flops should be vanishingly
rare.
> If that's unlikely - if most of the time the answers are clear, that the breakage is /super/ expensive to avoid such that no one's likely to ever revisit the decision/have a different cost/benefit tradeoff - and the breakages are obvious/easy to demonstrate (like I said, if there's common types of breakage and so simple breakage patterns that can be used in most cases to demonstrate breakage, etc) then we might avoid these sort of flip/flop cases most of the time.
Yeah, I would hope to avoid flip flopping like that.
~Aaron