Use #pragma once header guards in SpiderMonkey

RESOLVED WONTFIX

Status

()

RESOLVED WONTFIX
3 years ago
3 years ago

People

(Reporter: terrence, Assigned: terrence)

Tracking

(Depends on: 1 bug)

Trunk

Firefox Tracking Flags

(firefox46 affected)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
Created attachment 8711193 [details] [diff] [review]
pragma_once-v0.diff

The internet says that #pragma once has been safe to use basically forever in every compiler that I've even heard of. So let's try it out. Stuff builds locally, let's see what try has to say:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=986d05d5eb77

You may not want to review every single line; turns out we have lots of headers. Like, way more headers than I would have thought possible:
 436 files changed, 437 insertions(+), 1746 deletions(-)

The script I used to make the change is:
'''bash
#!/bin/bash
FILES=`find . -name "*.h" | grep -v irreg | grep -v libffi | grep -v vixl | grep -v editline | grep -v vtune | grep -v style | grep -v llvm-compiler-rt | grep -v js-conf`

for FILE in $FILES; do
    GUARDNAME=`sed -n "s/#ifndef \(.*_h\)$/\1/p" ${FILE}`
    if [ -z $GUARDNAME ]; then
        exit 1
    fi

    grep -q "#endif....${GUARDNAME}" ${FILE} || exit 2

    sed -i "s/#ifndef ${GUARDNAME}$/#pragma once/" ${FILE}
    sed -i "/#define ${GUARDNAME}/d" ${FILE}
    sed -i "/#endif....${GUARDNAME}/d" ${FILE}
    sed -i -e :a -e '/^\n*$/{$d;N;ba' -e '}' ${FILE}
done
'''

One edit was required in CommonPropertyNames.h: g++ did not like EOF terminating the macro after I stripped the trailing whitespace.
There was a proposal to do this for Gecko back in 2012:
  https://groups.google.com/forum/#!topic/mozilla.dev.platform/PgDjWw3xp8k

I'm not sure if the objections there still apply or not, but it is at least worth reading over.
This comment still applies.
https://groups.google.com/d/msg/mozilla.dev.platform/PgDjWw3xp8k/PLYQc5xoWmsJ
Status: ASSIGNED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → WONTFIX
(Assignee)

Updated

3 years ago
Component: JavaScript: GC → JavaScript Engine
(Assignee)

Comment 4

3 years ago
(In reply to Mike Hommey [:glandium] from comment #2)
> This comment still applies.
> https://groups.google.com/d/msg/mozilla.dev.platform/PgDjWw3xp8k/PLYQc5xoWmsJ

Well, drat!
You need to log in before you can comment on or make changes to this bug.