Replace MOZ_MUST_USE with [[nodiscard]] in js/src/
Categories
(Core :: JavaScript Engine, task, P3)
Tracking
()
People
(Reporter: cpeterson, Assigned: cpeterson)
References
Details
Attachments
(3 files, 1 obsolete 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.
The [[nodiscard]]
attribute must precede a function declaration's declaration specifiers (like static, extern, inline, or virtual). The __attribute__((warn_unused_result))
attribute does not have this order restriction.
Assignee | ||
Comment 1•4 years ago
|
||
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.
Assignee | ||
Comment 2•4 years ago
|
||
The [[nodiscard]] attribute must precede a function declaration's declaration specifiers (like static, extern, inline, or virtual). The attribute((warn_unused_result)) attribute does not have this order restriction.
Depends on D100412
Assignee | ||
Comment 3•4 years ago
|
||
We don't need to #include Attributes.h now that we're using [[nodiscard]] instead of MOZ_MUST_USE.
Depends on D100413
Assignee | ||
Comment 4•4 years ago
|
||
V8_WARN_UNUSED_RESULT can't use [[nodiscard]] because [[nodiscard]] has more restrictions on function declaration specifiers than attribute((warn_unused_result)). The affected code is third-party code from V8's irregexp, so instead of changing upstream code, revert V8_WARN_UNUSED_RESULT to its upstream definition using attribute((warn_unused_result)).
Depends on D100414
Assignee | ||
Comment 5•4 years ago
|
||
Assignee | ||
Comment 6•4 years ago
|
||
Comment on attachment 9194590 [details]
Bug 1684092 - Part 4: Revert V8_WARN_UNUSED_RESULT to upstream definition using attribute((warn_unused_result)). r?jorendorff
Part 4 was obsoleted by bug 1688350 comment 1
Assignee | ||
Comment 7•4 years ago
|
||
I rebased these s/MOZ_MUST_USE
/[[nodiscard]]
/ find-and-replace patches. They bit rot quickly because they touch a lot of header files.
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Pushed by cpeterson@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bfaa95b5e04a Part 1: Replace MOZ_MUST_USE with [[nodiscard]] in js/src/. r=jandem https://hg.mozilla.org/integration/autoland/rev/331046f56c01 Part 2: Move [[nodiscard]] to the head of function declarations in js/src/. r=jandem https://hg.mozilla.org/integration/autoland/rev/1f385759e3f5 Part 3: Remove unnecessary #includes of Attributes.h for MOZ_MUST_USE in js/src/. r=jandem
Comment 9•4 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/bfaa95b5e04a
https://hg.mozilla.org/mozilla-central/rev/331046f56c01
https://hg.mozilla.org/mozilla-central/rev/1f385759e3f5
Updated•4 years ago
|
Description
•