Closed Bug 1624776 Opened 5 years ago Closed 5 years ago

Replace MOZ_MUST_USE with [[nodiscard]] in xpcom

Categories

(Core :: XPCOM, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla76
Tracking Status
firefox76 --- fixed

People

(Reporter: cpeterson, Assigned: cpeterson)

References

Details

Attachments

(1 file)

The MOZ_MUST_USE macro is defined as clang's and gcc's nonstandard attribute((warn_unused_result)). Now that we compile as C++17 by default (bug 1560664), we can replace MOZ_MUST_USE with C++17's standard [[nodiscard]] attribute.

Also move MOZ_MUST_USE before function declarations' specifiers and return type. While clang and gcc's __attribute__((warn_unused_result)) can appear before, between, or after function specifiers and return types, the [[nodiscard]] attribute must precede the function specifiers.

Also remove MOZ_MUST_USE from nsIMemoryReporter's function pointer typedefs. [[nodiscard]] is an attribute of a function's declaration, not the function's type, and thus can't be applied to function pointers or lambdas.

Also move MOZ_MUST_USE before function declarations' specifiers and return type. While clang and gcc's attribute((warn_unused_result)) can appear before, between, or after function specifiers and return types, the [[nodiscard]] attribute must precede the function specifiers.

Also remove MOZ_MUST_USE from nsIMemoryReporter's function pointer typedefs. [[nodiscard]] is an attribute of a function's declaration, not the function's type, and thus can't be applied to function pointers or lambdas.

Attachment #9135588 - Attachment description: Bug 1624776 - Replace MOZ_MUST_USE with [[nodiscard]] in xpcom. r?#xpcom-reviewers → Bug 1624776 - Replace MOZ_MUST_USE with [[nodiscard]] in xpcom. r?KrisWright

I revised my patch to fix the indentation defects reported by reviewbot.

Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/d87c15bc2a08 Replace MOZ_MUST_USE with [[nodiscard]] in xpcom. r=xpcom-reviewers,KrisWright
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla76
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: