Closed Bug 1508064 Opened 2 years ago Closed 2 years ago

FOR_EACH_* macros in js/ get mangled by clang-format

Categories

(Core :: JavaScript Engine, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla65
Tracking Status
firefox-esr60 --- fixed
firefox65 --- fixed

People

(Reporter: tcampbell, Assigned: tcampbell)

References

Details

Attachments

(4 files, 1 obsolete file)

We use this macro pattern a lot in js/ and should probably wrap them with // clang-format off/on blocks.

This seems like precedent for tabular data: https://hg.mozilla.org/mozilla-central/rev/7807742373e1

A question I still have is once 4-space tabs become 2-space tabs, will we change the formatting in this blocks? The reasonable compromise would be to leave it alone until the next time someone does something like reformat the width of a column.

This query is a good starting point. Some of these become crazy in under clang-format (eg JS_FOR_PROTOTYPES).
https://searchfox.org/mozilla-central/search?q=%23define.*FOR_EACH&case=true&regexp=true&path=js
FOR_EACH_SIZE in js/public/MemoryMetrics.h are particularly broken.
Assignee: nobody → tcampbell
Aha! If we use uppercase macro arguments for re-expansion in these lists, the formatting is actually sane.
Depends on: 1508180
Moved uppercasing to Bug 1508180 since it touches different components. This bug will instead focus on the cases that still need |clang-format off|.
Add JS_FOR_PROTOTYPES_ macro that takes REAL_IF_SAB, etc helpers to
handle conditional proto keys. This is easier to read and avoids macro
expansion issues confusing clang-format.
Protect tabular macros or struct initializers that can mangled by
clang-format.

Depends on D12238
Pushed by tcampbell@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a50839e59152
Simplify JS_FOR_PROTOTYPES. r=jandem
https://hg.mozilla.org/integration/autoland/rev/1963c82b5abf
Use clang-format off in parts of js/ r=jandem
https://hg.mozilla.org/mozilla-central/rev/a50839e59152
https://hg.mozilla.org/mozilla-central/rev/1963c82b5abf
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Attached patch ESR patch (part 1) (obsolete) — Splinter Review
[ESR Uplift Approval Request]

If this is not a sec:{high,crit} bug, please state case for ESR consideration: This is required for easier backporting of patches after the reformatting of ESR using clang-format.

User impact if declined: Declining this will negatively impact our developers' ability to easily backport their patches to ESR in the future.

Fix Landed on Version: 65

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): This is reworking a C++ macro, shouldn't be making a functional change.  The patch has also baked on trunk for a while.

String or UUID changes made by this patch: None
Attachment #9030756 - Flags: review?(jdemooij)
Attachment #9030756 - Flags: approval-mozilla-esr60?
Attachment #9030756 - Attachment is patch: true
Attachment #9030756 - Attachment mime type: application/octet-stream → text/plain
[ESR Uplift Approval Request]

If this is not a sec:{high,crit} bug, please state case for ESR consideration: This is required for easier backporting of patches after the reformatting of ESR using clang-format.

User impact if declined: Declining this will negatively impact our developers' ability to easily backport their patches to ESR in the future.

Fix Landed on Version: 65

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): comment only

String or UUID changes made by this patch: None
Attachment #9030759 - Flags: approval-mozilla-esr60?
[ESR Uplift Approval Request]

If this is not a sec:{high,crit} bug, please state case for ESR consideration: See comment 8 (attached the wrong file!)

User impact if declined: 

Fix Landed on Version: 

Risk to taking this patch: Low

Why is the change risky/not risky? (and alternatives if risky): 

String or UUID changes made by this patch:
Attachment #9030770 - Flags: review?(jdemooij)
Attachment #9030770 - Flags: approval-mozilla-esr60?
Attachment #9030756 - Attachment is obsolete: true
Attachment #9030756 - Flags: review?(jdemooij)
Attachment #9030756 - Flags: approval-mozilla-esr60?
Attachment #9030770 - Attachment is patch: true
Attachment #9030770 - Attachment mime type: application/octet-stream → text/plain
Comment on attachment 9030770 [details] [diff] [review]
ESR patch (part 1)

Review of attachment 9030770 [details] [diff] [review]:
-----------------------------------------------------------------

Same patch just with SIMD instead of BigInt AFAICT, LGTM.
Attachment #9030770 - Flags: review?(jdemooij) → review+
Comment on attachment 9030759 [details] [diff] [review]
ESR patch (part 2)

OK for uplift to ESR60 as part of the clang-format project.
Attachment #9030759 - Flags: approval-mozilla-esr60? → approval-mozilla-esr60+
Attachment #9030770 - Flags: approval-mozilla-esr60? → approval-mozilla-esr60+
You need to log in before you can comment on or make changes to this bug.