Closed Bug 1559184 Opened 5 years ago Closed 5 years ago

clang-format totally screwed up the formatting in DOMMatrix.h

Categories

(Developer Infrastructure :: Lint and Formatting, defect)

defect
Not set
normal

Tracking

(firefox-esr60 wontfix, firefox67 wontfix, firefox68 fixed, firefox69 fixed)

RESOLVED FIXED
mozilla69
Tracking Status
firefox-esr60 --- wontfix
firefox67 --- wontfix
firefox68 --- fixed
firefox69 --- fixed

People

(Reporter: bzbarsky, Assigned: ehsan.akhgari)

References

(Blocks 1 open bug, Regression)

Details

(Keywords: regression)

Attachments

(1 file)

Relevant changeset: https://searchfox.org/mozilla-central/diff/265e6721798a455604328ed5262f430cfcc37c2f/dom/base/DOMMatrix.h#75

The new formatting is completely unreadable; it took me a bit to figure out what the heck happened and what the code is doing.

Can we fix this, please?

Flags: needinfo?(sledru)
Blocks: clang-format
Regressed by: clang-format

Also wondering whether there's any way to query for other instances of this...

Changing the macro calls so that they can be followed by a ;, and adding those ; should make clang-format behave better.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #0)

Relevant changeset: https://searchfox.org/mozilla-central/diff/265e6721798a455604328ed5262f430cfcc37c2f/dom/base/DOMMatrix.h#75

The new formatting is completely unreadable; it took me a bit to figure out what the heck happened and what the code is doing.

My apologies Boris, I spent a lot of time looking over the changes to find examples of unintended consequences like this but this one fell through the cracks. What confused clang-format's tokenizer here are all of these macros used with no semi-colon to be found anywhere, which makes a big block of code here look like a word salad to the tokenizer.

Can we fix this, please?

Patch coming up right away.

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #1)

Also wondering whether there's any way to query for other instances of this...

I've thought about it but haven't thought of a good way. Perhaps one could do so using clang-query but I can't say I've used that tool in the past. :-/

Flags: needinfo?(sledru)

The macro calls are declaring member functions. I guess we could put the { and } outside the macro and add begin/end macro stuff to allow the ;... or even not; if the line ends with } clang-format leaves it alone instead of pulling up stuff from the next line, looks like.

Ehsan, no need to apologize. I know you spent a lot of time dealing with these issues; there was just a very big haystack for all the needles to hide in.

This is overkill but StatementMacros might help for similar cases:
https://searchfox.org/mozilla-central/source/.clang-format#28

Assignee: nobody → ehsan
Type: task → defect
Pushed by eakhgari@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3e148406af28 Fix the damage caused by clang-format to DOMMatrix.h; r=bzbarsky

(In reply to Boris Zbarsky [:bzbarsky, bz on IRC] from comment #5)

The macro calls are declaring member functions. I guess we could put the { and } outside the macro and add begin/end macro stuff to allow the ;... or even not; if the line ends with } clang-format leaves it alone instead of pulling up stuff from the next line, looks like.

Yeah, clang-format has some imperfect heuristics around what determines when a line should end, things like ; or } signal that. If you think about the problem clang-format is trying to solve, when faced with code like we had in DOMMatrix.h, it wouldn't have a good way to tell where the line ending should be, so for all it could have said, everything was meant to have been on the same line!

(In reply to Sylvestre Ledru [:sylvestre] from comment #7)

This is overkill but StatementMacros might help for similar cases:
https://searchfox.org/mozilla-central/source/.clang-format#28

Indeed it would. To expand a bit, by default clang-format assumes macros are expanded to be expressions. This config option declares macros that are expanded to become full statements of their own. However IMHO for cases like this where there is a localized macro defined in just one file, turning formatting off locally is a better solution than to add more junk to the global config file (of course just an opinion!)

Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla69

This grafts cleanly to Beta. Should we uplift it there so ESR68 doesn't have to carry the old formatting over its lifespan?

Flags: needinfo?(ehsan)

However IMHO for cases like this where there is a localized macro defined in just one file, turning formatting off locally is a better solution than to
add more junk to the global config file (of course just an opinion!)

I do agree, I was explaining about this options for people who don't know that it exists :)

(In reply to Ryan VanderMeulen [:RyanVM] from comment #11)

This grafts cleanly to Beta. Should we uplift it there so ESR68 doesn't have to carry the old formatting over its lifespan?

Sounds like a good idea.

Flags: needinfo?(ehsan)

Comment on attachment 9071987 [details]
Bug 1559184 - Fix the damage caused by clang-format to DOMMatrix.h;

Beta/Release Uplift Approval Request

  • User impact if declined: Please see comment 12. This doesn't impact users but it will simplify the lives of our developers while creating uplifts for security fixes on ESR68.
  • Is this code covered by automated tests?: Yes
  • Has the fix been verified in Nightly?: Yes
  • Needs manual test from QE?: No
  • If yes, steps to reproduce:
  • List of other uplifts needed: None
  • Risk to taking this patch: Low
  • Why is the change risky/not risky? (and alternatives if risky): Whitespace only change
  • String changes made/needed: None
Attachment #9071987 - Flags: approval-mozilla-beta?

Comment on attachment 9071987 [details]
Bug 1559184 - Fix the damage caused by clang-format to DOMMatrix.h;

approved for 68.0b12

Attachment #9071987 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Has Regression Range: --- → yes
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: