Compare commits

...
Author SHA1 Message Date
Moonchild 610e44320c Issue #2342: Remove MOZ_MUST_USE macro 2023-11-05 12:38:11 +01:00
Moonchild 10476e27da Issue #2342: Use [[nodiscard]] in /mfbt 2023-11-05 12:37:04 +01:00
Moonchild a4777b1c21 Issue #2342: Use [[nodiscard]] in /xpcom and xpidl parser 2023-11-05 10:41:52 +01:00
Moonchild 9f6e448f78 Issue #2342: Use [[nodiscard]] in /uriloader /widget
Also a few misc low-volume places.
2023-11-05 00:59:31 +01:00
Moonchild 19a21bac1b Issue #2342: Use [[nodiscard]] in /netwerk 2023-11-04 23:42:53 +01:00
Moonchild c7867ce130 Issue #2342: Use [[nodiscard]] in /memory and remove Sun Studio hack 2023-11-04 22:57:30 +01:00
Moonchild 34c068e611 Issue #2342: Use [[nodiscard]] in /media 2023-11-04 22:28:58 +01:00
Moonchild a48e621048 Issue #2342: Use [[nodiscard]] in /js 2023-11-04 20:06:50 +01:00
Moonchild de5d3b1034 Issue #2342: Use [[nodiscard]] in IPDL generation and fix warnings
DOM plugin code had two warning in IPC caught by [[nodiscard]], these
were fixed in one go.
2023-11-04 01:24:20 +01:00
Moonchild f8737bbf4f Issue #2342: Use [[nodiscard]] in /ipc 2023-11-04 01:22:37 +01:00
Moonchild d9c70eaba2 Issue #2342: Use [[nodiscard]] in /hal /image and /intl 2023-11-04 01:21:57 +01:00
Moonchild 9308c63ce6 Issue #2281 - Remove the use of non-standard namespace std::tr1 in
Google's WebRTC gtest code
2023-11-04 00:13:32 +01:00
Moonchild 6314e01691 Issue #2342: Use [[nodiscard]] in /accessible and /caps 2023-11-03 12:17:29 +01:00
Moonchild b7b2f1de84 Issue #2342: Use [[nodiscard]] in /gfx and /layout 2023-11-03 00:34:37 +01:00
Moonchild b838d6634c Issue #2342: Use [[nodiscard]] in /dom 2023-11-03 00:17:31 +01:00
Moonchild dc4ea7f680 Merge branch 'master' into c++17-work 2023-11-02 12:20:37 +01:00
Moonchild 0e427867e3 Issue #2281 - Force clobber
Without a clobber, mozconfigure doesn't properly pick up the /std:c++17
or -std=gnu++17 compiler switches needed to put them into C++17 mode.
2023-10-18 14:40:16 +02:00
Moonchild 8137a4e122 Issue #2281 - Add some deduction guides for class template arguments.
This is necessary if we want to start using Span() constructors
instead of the MakeSpan() kludge.
2023-10-18 14:35:59 +02:00
Moonchild 46138995f6 Issue #2281 - Default to C++17 when building.
Configure the toolchain to default to C++17 language standard with
optional gnu extensions (if on GCC)
2023-10-15 15:12:23 +02:00
Moonchild aeb9de40a5 Issue #2281 - Avoid class-static constexpr in TypedArrayObject 2023-10-15 01:54:25 +02:00
Moonchild 3d693801f9 Issue #2281 - Build LZ4 as C instead of including it as C++. 2023-10-15 00:19:13 +02:00
Moonchild 14fa712b8c Issue #2281 - The 'register' storage class is no longer a thing in c++17 2023-10-13 23:12:37 +02:00
Moonchild 7d93034fd0 Issue #2281 - Mark mozalloc new() as noexcept to aligh with what the VC
runtime expects.

Currently spams warnings but may actually error out if not fixed, or
result in undefined behaviour if mismatching signatures are treated as
redeclarations with different exception specifications.
2023-10-13 23:12:00 +02:00
Moonchild 1769e74839 Issue #2281 - Replace std::iterator inheritance with iterator traits
definitions (as required by C++17).
2023-10-13 23:07:22 +02:00
358 changed files with 3750 additions and 3793 deletions

No files matched your search

+1 -1
View File
@@ -22,4 +22,4 @@
# changes to stick? As of bug 928195, this shouldn't be necessary! Please # changes to stick? As of bug 928195, this shouldn't be necessary! Please
# don't change CLOBBER for WebIDL changes any more. # don't change CLOBBER for WebIDL changes any more.
Removal of SIMD.js and associated scalar types requires CLOBBER. (Issue #2307) Switching to C++17 requires CLOBBER to pick up compiler conf. (Issue #2281)
+1 -1
View File
@@ -176,7 +176,7 @@ private:
uint32_t AddSubtree(ProxyAccessible* aParent, uint32_t AddSubtree(ProxyAccessible* aParent,
const nsTArray<AccessibleData>& aNewTree, uint32_t aIdx, const nsTArray<AccessibleData>& aNewTree, uint32_t aIdx,
uint32_t aIdxInParent); uint32_t aIdxInParent);
MOZ_MUST_USE bool CheckDocTree() const; [[nodiscard]] bool CheckDocTree() const;
xpcAccessibleGeneric* GetXPCAccessible(ProxyAccessible* aProxy); xpcAccessibleGeneric* GetXPCAccessible(ProxyAccessible* aProxy);
nsTArray<DocAccessibleParent*> mChildDocs; nsTArray<DocAccessibleParent*> mChildDocs;
+2 -2
View File
@@ -173,7 +173,7 @@ public: // construction, destruction
/** /**
* Find an accessible by the given child ID in cached documents. * Find an accessible by the given child ID in cached documents.
*/ */
MOZ_MUST_USE already_AddRefed<IAccessible> [[nodiscard]] already_AddRefed<IAccessible>
GetIAccessibleFor(const VARIANT& aVarChild, bool* aIsDefunct); GetIAccessibleFor(const VARIANT& aVarChild, bool* aIsDefunct);
virtual void GetNativeInterface(void **aOutAccessible) override; virtual void GetNativeInterface(void **aOutAccessible) override;
@@ -198,7 +198,7 @@ protected:
/** /**
* Find a remote accessible by the given child ID. * Find a remote accessible by the given child ID.
*/ */
MOZ_MUST_USE already_AddRefed<IAccessible> [[nodiscard]] already_AddRefed<IAccessible>
GetRemoteIAccessibleFor(const VARIANT& aVarChild); GetRemoteIAccessibleFor(const VARIANT& aVarChild);
/** /**
+9 -10
View File
@@ -340,17 +340,16 @@ def check_compiler(compiler, language, target):
if info.type in ('clang-cl', 'clang', 'gcc'): if info.type in ('clang-cl', 'clang', 'gcc'):
append_flag('-std=gnu99') append_flag('-std=gnu99')
# Note: this is a strict version check because we used to always add cxx17_version = 201703
# -std=gnu++14.
cxx14_version = 201402
if info.language == 'C++': if info.language == 'C++':
if info.type in ('clang', 'gcc') and info.language_version != cxx14_version: if info.language_version != cxx17_version:
append_flag('-std=gnu++14') # Compiler doesn't default to C++17, so add the appropriate flag.
# MSVC 2015 headers include C++14 features, but don't guard them if info.type in ('clang', 'gcc'):
# with appropriate checks. # We're on Clang or GCC, enable C++17 and add GNU extensions.
if info.type == 'clang-cl' and info.language_version != cxx14_version: append_flag('-std=gnu++17')
append_flag('-std=c++14') else:
# MSVC from 2015 on defaults to C++14. # We're on MSVC; enable C++17 language mode.
append_flag('-std:c++17')
# We force clang-cl to emulate Visual C++ 2015 Update 3 with fallback to # We force clang-cl to emulate Visual C++ 2015 Update 3 with fallback to
# cl.exe. # cl.exe.
+1 -1
View File
@@ -52,7 +52,7 @@ check_and_add_gcc_warning('-Wclass-varargs')
check_and_add_gcc_warning('-Wloop-analysis') check_and_add_gcc_warning('-Wloop-analysis')
# catches C++ version forward-compat issues # catches C++ version forward-compat issues
check_and_add_gcc_warning('-Wc++1z-compat', cxx_compiler) # check_and_add_gcc_warning('-Wc++2a-compat', cxx_compiler)
# catches unintentional switch case fallthroughs # catches unintentional switch case fallthroughs
check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler) check_and_add_gcc_warning('-Wimplicit-fallthrough', cxx_compiler)
+3 -3
View File
@@ -51,12 +51,12 @@ public:
// Don't use this method for anything else than debugging! // Don't use this method for anything else than debugging!
void CreateAnonymizedSuffix(nsACString& aStr) const; void CreateAnonymizedSuffix(nsACString& aStr) const;
MOZ_MUST_USE bool PopulateFromSuffix(const nsACString& aStr); [[nodiscard]] bool PopulateFromSuffix(const nsACString& aStr);
// Populates the attributes from a string like // Populates the attributes from a string like
// |uri!key1=value1&key2=value2| and returns the uri without the suffix. // |uri!key1=value1&key2=value2| and returns the uri without the suffix.
MOZ_MUST_USE bool PopulateFromOrigin(const nsACString& aOrigin, [[nodiscard]] bool PopulateFromOrigin(const nsACString& aOrigin,
nsACString& aOriginNoSuffix); nsACString& aOriginNoSuffix);
// Helper function to match mIsPrivateBrowsing to existing private browsing // Helper function to match mIsPrivateBrowsing to existing private browsing
// flags. Once all other flags are removed, this can be removed too. // flags. Once all other flags are removed, this can be removed too.
+1 -2
View File
@@ -147,8 +147,7 @@ public:
virtual bool TextIsOnlyWhitespace() override; virtual bool TextIsOnlyWhitespace() override;
virtual bool HasTextForTranslation() override; virtual bool HasTextForTranslation() override;
virtual void AppendTextTo(nsAString& aResult) override; virtual void AppendTextTo(nsAString& aResult) override;
MOZ_MUST_USE [[nodiscard]] virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) override;
virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) override;
virtual nsIContent *GetBindingParent() const override; virtual nsIContent *GetBindingParent() const override;
virtual nsXBLBinding *GetXBLBinding() const override; virtual nsXBLBinding *GetXBLBinding() const override;
virtual void SetXBLBinding(nsXBLBinding* aBinding, virtual void SetXBLBinding(nsXBLBinding* aBinding,
+1 -1
View File
@@ -84,7 +84,7 @@ private:
nsIContent **outImageOrLinkNode, nsIContent **outImageOrLinkNode,
bool* outDragSelectedText); bool* outDragSelectedText);
static already_AddRefed<nsIContent> FindParentLinkNode(nsIContent* inNode); static already_AddRefed<nsIContent> FindParentLinkNode(nsIContent* inNode);
static MOZ_MUST_USE nsresult static [[nodiscard]] nsresult
GetAnchorURL(nsIContent* inNode, nsAString& outURL); GetAnchorURL(nsIContent* inNode, nsAString& outURL);
static void GetNodeString(nsIContent* inNode, nsAString & outNodeString); static void GetNodeString(nsIContent* inNode, nsAString & outNodeString);
static void CreateLinkText(const nsAString& inURL, const nsAString & inText, static void CreateLinkText(const nsAString& inURL, const nsAString & inText,
+20 -19
View File
@@ -1508,9 +1508,10 @@ public:
* @param aResult the result. Out param. * @param aResult the result. Out param.
* @return false on out of memory errors, true otherwise. * @return false on out of memory errors, true otherwise.
*/ */
MOZ_MUST_USE [[nodiscard]] static bool GetNodeTextContent(nsINode* aNode,
static bool GetNodeTextContent(nsINode* aNode, bool aDeep, bool aDeep,
nsAString& aResult, const mozilla::fallible_t&); nsAString& aResult,
const mozilla::fallible_t&);
static void GetNodeTextContent(nsINode* aNode, bool aDeep, static void GetNodeTextContent(nsINode* aNode, bool aDeep,
nsAString& aResult); nsAString& aResult);
@@ -1869,28 +1870,29 @@ public:
*/ */
static bool CanAccessNativeAnon(); static bool CanAccessNativeAnon();
MOZ_MUST_USE [[nodiscard]] static nsresult WrapNative(JSContext* cx,
static nsresult WrapNative(JSContext *cx, nsISupports *native, nsISupports* native,
const nsIID* aIID, JS::MutableHandle<JS::Value> vp, const nsIID* aIID,
bool aAllowWrapping = true) JS::MutableHandle<JS::Value> vp,
bool aAllowWrapping = true)
{ {
return WrapNative(cx, native, nullptr, aIID, vp, aAllowWrapping); return WrapNative(cx, native, nullptr, aIID, vp, aAllowWrapping);
} }
// Same as the WrapNative above, but use this one if aIID is nsISupports' IID. // Same as the WrapNative above, but use this one if aIID is nsISupports' IID.
MOZ_MUST_USE [[nodiscard]] static nsresult WrapNative(JSContext* cx,
static nsresult WrapNative(JSContext *cx, nsISupports *native, nsISupports* native,
JS::MutableHandle<JS::Value> vp, JS::MutableHandle<JS::Value> vp,
bool aAllowWrapping = true) bool aAllowWrapping = true)
{ {
return WrapNative(cx, native, nullptr, nullptr, vp, aAllowWrapping); return WrapNative(cx, native, nullptr, nullptr, vp, aAllowWrapping);
} }
MOZ_MUST_USE [[nodiscard]] static nsresult WrapNative(JSContext* cx,
static nsresult WrapNative(JSContext *cx, nsISupports *native, nsISupports* native,
nsWrapperCache *cache, nsWrapperCache* cache,
JS::MutableHandle<JS::Value> vp, JS::MutableHandle<JS::Value> vp,
bool aAllowWrapping = true) bool aAllowWrapping = true)
{ {
return WrapNative(cx, native, cache, nullptr, vp, aAllowWrapping); return WrapNative(cx, native, cache, nullptr, vp, aAllowWrapping);
} }
@@ -1914,9 +1916,8 @@ public:
* @param aString the string to convert the newlines inside [in/out] * @param aString the string to convert the newlines inside [in/out]
*/ */
static void PlatformToDOMLineBreaks(nsString &aString); static void PlatformToDOMLineBreaks(nsString &aString);
MOZ_MUST_USE [[nodiscard]] static bool PlatformToDOMLineBreaks(nsString &aString,
static bool PlatformToDOMLineBreaks(nsString &aString, const mozilla::fallible_t&);
const mozilla::fallible_t&);
/** /**
* Populates aResultString with the contents of the string-buffer aBuf, up * Populates aResultString with the contents of the string-buffer aBuf, up
+2 -3
View File
@@ -144,9 +144,8 @@ public:
virtual bool TextIsOnlyWhitespace() override; virtual bool TextIsOnlyWhitespace() override;
virtual bool HasTextForTranslation() override; virtual bool HasTextForTranslation() override;
virtual void AppendTextTo(nsAString& aResult) override; virtual void AppendTextTo(nsAString& aResult) override;
MOZ_MUST_USE [[nodiscard]] virtual bool AppendTextTo(nsAString& aResult,
virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) override;
const mozilla::fallible_t&) override;
virtual void SaveSubtreeState() override; virtual void SaveSubtreeState() override;
#ifdef DEBUG #ifdef DEBUG
+9 -11
View File
@@ -37,18 +37,16 @@ class nsHTMLContentSerializer final : public nsXHTMLContentSerializer {
nsAString& aStr) override; nsAString& aStr) override;
protected: protected:
MOZ_MUST_USE [[nodiscard]] virtual bool SerializeHTMLAttributes(nsIContent* aContent,
virtual bool SerializeHTMLAttributes(nsIContent* aContent, nsIContent* aOriginalElement,
nsIContent *aOriginalElement, nsAString& aTagPrefix,
nsAString& aTagPrefix, const nsAString& aTagNamespaceURI,
const nsAString& aTagNamespaceURI, nsIAtom* aTagName,
nsIAtom* aTagName, int32_t aNamespace,
int32_t aNamespace, nsAString& aStr);
nsAString& aStr);
MOZ_MUST_USE [[nodiscard]] virtual bool AppendAndTranslateEntities(const nsAString& aStr,
virtual bool AppendAndTranslateEntities(const nsAString& aStr, nsAString& aOutputStr) override;
nsAString& aOutputStr) override;
}; };
+1 -2
View File
@@ -576,8 +576,7 @@ public:
* Append the text content to aResult. * Append the text content to aResult.
* NOTE: This asserts and returns for elements * NOTE: This asserts and returns for elements
*/ */
MOZ_MUST_USE [[nodiscard]] virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) = 0;
virtual bool AppendTextTo(nsAString& aResult, const mozilla::fallible_t&) = 0;
/** /**
* Check if this content is focusable and in the current tab order. * Check if this content is focusable and in the current tab order.
+2 -2
View File
@@ -2513,8 +2513,8 @@ public:
mozilla::ErrorResult& rv); mozilla::ErrorResult& rv);
virtual mozilla::dom::DOMImplementation* virtual mozilla::dom::DOMImplementation*
GetImplementation(mozilla::ErrorResult& rv) = 0; GetImplementation(mozilla::ErrorResult& rv) = 0;
MOZ_MUST_USE nsresult GetURL(nsString& retval) const; [[nodiscard]] nsresult GetURL(nsString& retval) const;
MOZ_MUST_USE nsresult GetDocumentURI(nsString& retval) const; [[nodiscard]] nsresult GetDocumentURI(nsString& retval) const;
// Return the URI for the document. // Return the URI for the document.
// The returned value may differ if the document is loaded via XHR, and // The returned value may differ if the document is loaded via XHR, and
// when accessed from chrome privileged script and // when accessed from chrome privileged script and
+1 -1
View File
@@ -1873,7 +1873,7 @@ public:
aNodeName.SetStringBuffer(nsStringBuffer::FromString(nodeName), aNodeName.SetStringBuffer(nsStringBuffer::FromString(nodeName),
nodeName.Length()); nodeName.Length());
} }
MOZ_MUST_USE nsresult GetBaseURI(nsAString& aBaseURI) const; [[nodiscard]] nsresult GetBaseURI(nsAString& aBaseURI) const;
// Return the base URI for the document. // Return the base URI for the document.
// The returned value may differ if the document is loaded via XHR, and // The returned value may differ if the document is loaded via XHR, and
// when accessed from chrome privileged script and // when accessed from chrome privileged script and
+4 -4
View File
@@ -143,7 +143,7 @@ public:
// After getting a notification that an off-thread compilation terminated, // After getting a notification that an off-thread compilation terminated,
// this function will take the result of the parser and move it to the main // this function will take the result of the parser and move it to the main
// thread. // thread.
MOZ_MUST_USE nsresult JoinCompile(void** aOffThreadToken); [[nodiscard]] nsresult JoinCompile(void** aOffThreadToken);
// Compile a script contained in a SourceText. // Compile a script contained in a SourceText.
nsresult Compile(JS::CompileOptions& aCompileOptions, nsresult Compile(JS::CompileOptions& aCompileOptions,
@@ -167,7 +167,7 @@ public:
JSScript* GetScript(); JSScript* GetScript();
// Execute the compiled script and ignore the return value. // Execute the compiled script and ignore the return value.
MOZ_MUST_USE nsresult ExecScript(); [[nodiscard]] nsresult ExecScript();
// Execute the compiled script a get the return value. // Execute the compiled script a get the return value.
// //
@@ -180,10 +180,10 @@ public:
// compartment given as argument to the ExecutionContext constructor. If the // compartment given as argument to the ExecutionContext constructor. If the
// caller is in a different compartment, then the out-param value should be // caller is in a different compartment, then the out-param value should be
// wrapped by calling |JS_WrapValue|. // wrapped by calling |JS_WrapValue|.
MOZ_MUST_USE nsresult [[nodiscard]] nsresult
ExtractReturnValue(JS::MutableHandle<JS::Value> aRetValue); ExtractReturnValue(JS::MutableHandle<JS::Value> aRetValue);
MOZ_MUST_USE nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue); [[nodiscard]] nsresult ExecScript(JS::MutableHandle<JS::Value> aRetValue);
}; };
static nsresult CompileModule(JSContext* aCx, static nsresult CompileModule(JSContext* aCx,
+1 -1
View File
@@ -382,7 +382,7 @@ class nsObjectLoadingContent : public nsImageLoadingContent
void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters, void GetNestedParams(nsTArray<mozilla::dom::MozPluginParameter>& aParameters,
bool aIgnoreCodebase); bool aIgnoreCodebase);
MOZ_MUST_USE nsresult BuildParametersArray(); [[nodiscard]] nsresult BuildParametersArray();
/** /**
* Loads fallback content with the specified FallbackType * Loads fallback content with the specified FallbackType
+2 -2
View File
@@ -136,7 +136,7 @@ public:
* Append the contents of this string fragment to aString * Append the contents of this string fragment to aString
* @return false if an out of memory condition is detected, true otherwise * @return false if an out of memory condition is detected, true otherwise
*/ */
MOZ_MUST_USE [[nodiscard]]
bool AppendTo(nsAString& aString, bool AppendTo(nsAString& aString,
const mozilla::fallible_t& aFallible) const { const mozilla::fallible_t& aFallible) const {
if (mState.mIs2b) { if (mState.mIs2b) {
@@ -170,7 +170,7 @@ public:
* @param aLength the length of the substring * @param aLength the length of the substring
* @return false if an out of memory condition is detected, true otherwise * @return false if an out of memory condition is detected, true otherwise
*/ */
MOZ_MUST_USE [[nodiscard]]
bool AppendTo(nsAString& aString, int32_t aOffset, int32_t aLength, bool AppendTo(nsAString& aString, int32_t aOffset, int32_t aLength,
const mozilla::fallible_t& aFallible) const const mozilla::fallible_t& aFallible) const
{ {
+4 -4
View File
@@ -46,7 +46,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
nsAString& aStr, nsAString& aStr,
nsresult& aResult) override; nsresult& aResult) override;
MOZ_MUST_USE [[nodiscard]]
virtual bool AfterElementStart(nsIContent* aContent, virtual bool AfterElementStart(nsIContent* aContent,
nsIContent* aOriginalElement, nsIContent* aOriginalElement,
nsAString& aStr) override; nsAString& aStr) override;
@@ -70,7 +70,7 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
virtual void MaybeEnterInPreContent(nsIContent* aNode) override; virtual void MaybeEnterInPreContent(nsIContent* aNode) override;
virtual void MaybeLeaveFromPreContent(nsIContent* aNode) override; virtual void MaybeLeaveFromPreContent(nsIContent* aNode) override;
MOZ_MUST_USE [[nodiscard]]
virtual bool SerializeAttributes(nsIContent* aContent, virtual bool SerializeAttributes(nsIContent* aContent,
nsIContent *aOriginalElement, nsIContent *aOriginalElement,
nsAString& aTagPrefix, nsAString& aTagPrefix,
@@ -82,13 +82,13 @@ class nsXHTMLContentSerializer : public nsXMLContentSerializer {
bool IsFirstChildOfOL(nsIContent* aElement); bool IsFirstChildOfOL(nsIContent* aElement);
MOZ_MUST_USE [[nodiscard]]
bool SerializeLIValueAttribute(nsIContent* aElement, bool SerializeLIValueAttribute(nsIContent* aElement,
nsAString& aStr); nsAString& aStr);
bool IsShorthandAttr(const nsIAtom* aAttrName, bool IsShorthandAttr(const nsIAtom* aAttrName,
const nsIAtom* aElementName); const nsIAtom* aElementName);
MOZ_MUST_USE [[nodiscard]]
virtual bool AppendAndTranslateEntities(const nsAString& aStr, virtual bool AppendAndTranslateEntities(const nsAString& aStr,
nsAString& aOutputStr) override; nsAString& aOutputStr) override;
+19 -24
View File
@@ -72,23 +72,21 @@ class nsXMLContentSerializer : public nsIContentSerializer {
/** /**
* Appends a char16_t character and increments the column position * Appends a char16_t character and increments the column position
*/ */
MOZ_MUST_USE [[nodiscard]] bool AppendToString(const char16_t aChar,
bool AppendToString(const char16_t aChar, nsAString& aOutputStr);
nsAString& aOutputStr);
/** /**
* Appends a nsAString string and increments the column position * Appends a nsAString string and increments the column position
*/ */
MOZ_MUST_USE [[nodiscard]] bool AppendToString(const nsAString& aStr,
bool AppendToString(const nsAString& aStr, nsAString& aOutputStr);
nsAString& aOutputStr);
/** /**
* Appends a string by replacing all line-endings * Appends a string by replacing all line-endings
* by mLineBreak, except in the case of raw output. * by mLineBreak, except in the case of raw output.
* It increments the column position. * It increments the column position.
*/ */
MOZ_MUST_USE [[nodiscard]]
bool AppendToStringConvertLF(const nsAString& aStr, bool AppendToStringConvertLF(const nsAString& aStr,
nsAString& aOutputStr); nsAString& aOutputStr);
@@ -96,7 +94,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* Appends a string by wrapping it when necessary. * Appends a string by wrapping it when necessary.
* It updates the column position. * It updates the column position.
*/ */
MOZ_MUST_USE [[nodiscard]]
bool AppendToStringWrapped(const nsASingleFragmentString& aStr, bool AppendToStringWrapped(const nsASingleFragmentString& aStr,
nsAString& aOutputStr); nsAString& aOutputStr);
@@ -104,12 +102,12 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* Appends a string by formating and wrapping it when necessary * Appends a string by formating and wrapping it when necessary
* It updates the column position. * It updates the column position.
*/ */
MOZ_MUST_USE [[nodiscard]]
bool AppendToStringFormatedWrapped(const nsASingleFragmentString& aStr, bool AppendToStringFormatedWrapped(const nsASingleFragmentString& aStr,
nsAString& aOutputStr); nsAString& aOutputStr);
// used by AppendToStringWrapped // used by AppendToStringWrapped
MOZ_MUST_USE [[nodiscard]]
bool AppendWrapped_WhitespaceSequence( bool AppendWrapped_WhitespaceSequence(
nsASingleFragmentString::const_char_iterator &aPos, nsASingleFragmentString::const_char_iterator &aPos,
const nsASingleFragmentString::const_char_iterator aEnd, const nsASingleFragmentString::const_char_iterator aEnd,
@@ -117,7 +115,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
nsAString &aOutputStr); nsAString &aOutputStr);
// used by AppendToStringFormatedWrapped // used by AppendToStringFormatedWrapped
MOZ_MUST_USE [[nodiscard]]
bool AppendFormatedWrapped_WhitespaceSequence( bool AppendFormatedWrapped_WhitespaceSequence(
nsASingleFragmentString::const_char_iterator &aPos, nsASingleFragmentString::const_char_iterator &aPos,
const nsASingleFragmentString::const_char_iterator aEnd, const nsASingleFragmentString::const_char_iterator aEnd,
@@ -126,7 +124,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
nsAString &aOutputStr); nsAString &aOutputStr);
// used by AppendToStringWrapped and AppendToStringFormatedWrapped // used by AppendToStringWrapped and AppendToStringFormatedWrapped
MOZ_MUST_USE [[nodiscard]]
bool AppendWrapped_NonWhitespaceSequence( bool AppendWrapped_NonWhitespaceSequence(
nsASingleFragmentString::const_char_iterator &aPos, nsASingleFragmentString::const_char_iterator &aPos,
const nsASingleFragmentString::const_char_iterator aEnd, const nsASingleFragmentString::const_char_iterator aEnd,
@@ -139,7 +137,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* add mLineBreak to the string * add mLineBreak to the string
* It updates the column position and other flags. * It updates the column position and other flags.
*/ */
MOZ_MUST_USE [[nodiscard]]
bool AppendNewLineToString(nsAString& aOutputStr); bool AppendNewLineToString(nsAString& aOutputStr);
@@ -147,7 +145,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* Appends a string by translating entities * Appends a string by translating entities
* It doesn't increment the column position * It doesn't increment the column position
*/ */
MOZ_MUST_USE [[nodiscard]]
virtual bool AppendAndTranslateEntities(const nsAString& aStr, virtual bool AppendAndTranslateEntities(const nsAString& aStr,
nsAString& aOutputStr); nsAString& aOutputStr);
@@ -197,7 +195,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
nsIContent *aOriginalElement, nsIContent *aOriginalElement,
const nsAString& aTagNamespaceURI); const nsAString& aTagNamespaceURI);
MOZ_MUST_USE [[nodiscard]]
virtual bool SerializeAttributes(nsIContent* aContent, virtual bool SerializeAttributes(nsIContent* aContent,
nsIContent *aOriginalElement, nsIContent *aOriginalElement,
nsAString& aTagPrefix, nsAString& aTagPrefix,
@@ -207,7 +205,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
uint32_t aSkipAttr, uint32_t aSkipAttr,
bool aAddNSAttr); bool aAddNSAttr);
MOZ_MUST_USE [[nodiscard]]
bool SerializeAttr(const nsAString& aPrefix, bool SerializeAttr(const nsAString& aPrefix,
const nsAString& aName, const nsAString& aName,
const nsAString& aValue, const nsAString& aValue,
@@ -239,7 +237,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* aElement and aOriginalElement are the same as the corresponding arguments * aElement and aOriginalElement are the same as the corresponding arguments
* to AppendElementStart. * to AppendElementStart.
*/ */
MOZ_MUST_USE [[nodiscard]]
bool AppendEndOfElementStart(mozilla::dom::Element* aEleemnt, bool AppendEndOfElementStart(mozilla::dom::Element* aEleemnt,
mozilla::dom::Element* aOriginalElement, mozilla::dom::Element* aOriginalElement,
nsAString& aStr); nsAString& aStr);
@@ -249,7 +247,7 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* after the serialization ot the start tag. * after the serialization ot the start tag.
* (called at the end of AppendElementStart) * (called at the end of AppendElementStart)
*/ */
MOZ_MUST_USE [[nodiscard]]
virtual bool AfterElementStart(nsIContent* aContent, virtual bool AfterElementStart(nsIContent* aContent,
nsIContent* aOriginalElement, nsIContent* aOriginalElement,
nsAString& aStr) { return true; }; nsAString& aStr) { return true; };
@@ -299,17 +297,14 @@ class nsXMLContentSerializer : public nsIContentSerializer {
* add intendation. Call only in the case of formating and if the current * add intendation. Call only in the case of formating and if the current
* position is at 0. It updates the column position. * position is at 0. It updates the column position.
*/ */
MOZ_MUST_USE [[nodiscard]] bool AppendIndentation(nsAString& aStr);
bool AppendIndentation(nsAString& aStr);
MOZ_MUST_USE [[nodiscard]] bool IncrIndentation(nsIAtom* aName);
bool IncrIndentation(nsIAtom* aName);
void DecrIndentation(nsIAtom* aName); void DecrIndentation(nsIAtom* aName);
// Functions to check for newlines that needs to be added between nodes in // Functions to check for newlines that needs to be added between nodes in
// the root of a document. See mAddNewlineForRootNode // the root of a document. See mAddNewlineForRootNode
MOZ_MUST_USE [[nodiscard]] bool MaybeAddNewlineForRootNode(nsAString& aStr);
bool MaybeAddNewlineForRootNode(nsAString& aStr);
void MaybeFlagNewlineForRootNode(nsINode* aNode); void MaybeFlagNewlineForRootNode(nsINode* aNode);
// Functions to check if we enter in or leave from a preformated content // Functions to check if we enter in or leave from a preformated content
+23 -23
View File
@@ -24,7 +24,7 @@ class Promise;
// JSContext. // JSContext.
// Accept strings. // Accept strings.
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const nsAString& aArgument, const nsAString& aArgument,
JS::MutableHandle<JS::Value> aValue); JS::MutableHandle<JS::Value> aValue);
@@ -35,7 +35,7 @@ ToJSValue(JSContext* aCx,
// desirable. So make this a template that only gets used if the argument type // desirable. So make this a template that only gets used if the argument type
// is actually boolean // is actually boolean
template<typename T> template<typename T>
MOZ_MUST_USE [[nodiscard]]
typename EnableIf<IsSame<T, bool>::value, bool>::Type typename EnableIf<IsSame<T, bool>::value, bool>::Type
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
T aArgument, T aArgument,
@@ -123,7 +123,7 @@ ToJSValue(JSContext* aCx,
} }
// Accept CallbackObjects // Accept CallbackObjects
MOZ_MUST_USE inline bool [[nodiscard]] inline bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
CallbackObject& aArgument, CallbackObject& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
@@ -139,7 +139,7 @@ ToJSValue(JSContext* aCx,
// Accept objects that inherit from nsWrapperCache (e.g. most // Accept objects that inherit from nsWrapperCache (e.g. most
// DOM objects). // DOM objects).
template <class T> template <class T>
MOZ_MUST_USE [[nodiscard]]
typename EnableIf<IsBaseOf<nsWrapperCache, T>::value, bool>::Type typename EnableIf<IsBaseOf<nsWrapperCache, T>::value, bool>::Type
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
T& aArgument, T& aArgument,
@@ -155,7 +155,7 @@ ToJSValue(JSContext* aCx,
// Accept typed arrays built from appropriate nsTArray values // Accept typed arrays built from appropriate nsTArray values
template<typename T> template<typename T>
MOZ_MUST_USE [[nodiscard]]
typename EnableIf<IsBaseOf<AllTypedArraysBase, T>::value, bool>::Type typename EnableIf<IsBaseOf<AllTypedArraysBase, T>::value, bool>::Type
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const TypedArrayCreator<T>& aArgument, const TypedArrayCreator<T>& aArgument,
@@ -175,7 +175,7 @@ ToJSValue(JSContext* aCx,
// Accept objects that inherit from nsISupports but not nsWrapperCache (e.g. // Accept objects that inherit from nsISupports but not nsWrapperCache (e.g.
// DOM File). // DOM File).
template <class T> template <class T>
MOZ_MUST_USE [[nodiscard]]
typename EnableIf<!IsBaseOf<nsWrapperCache, T>::value && typename EnableIf<!IsBaseOf<nsWrapperCache, T>::value &&
!IsBaseOf<CallbackObject, T>::value && !IsBaseOf<CallbackObject, T>::value &&
IsBaseOf<nsISupports, T>::value, bool>::Type IsBaseOf<nsISupports, T>::value, bool>::Type
@@ -193,7 +193,7 @@ ToJSValue(JSContext* aCx,
// Accept nsRefPtr/nsCOMPtr // Accept nsRefPtr/nsCOMPtr
template <typename T> template <typename T>
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const nsCOMPtr<T>& aArgument, const nsCOMPtr<T>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
@@ -202,7 +202,7 @@ ToJSValue(JSContext* aCx,
} }
template <typename T> template <typename T>
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const RefPtr<T>& aArgument, const RefPtr<T>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
@@ -211,7 +211,7 @@ ToJSValue(JSContext* aCx,
} }
template <typename T> template <typename T>
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const NonNull<T>& aArgument, const NonNull<T>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
@@ -221,7 +221,7 @@ ToJSValue(JSContext* aCx,
// Accept WebIDL dictionaries // Accept WebIDL dictionaries
template <class T> template <class T>
MOZ_MUST_USE [[nodiscard]]
typename EnableIf<IsBaseOf<DictionaryBase, T>::value, bool>::Type typename EnableIf<IsBaseOf<DictionaryBase, T>::value, bool>::Type
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const T& aArgument, const T& aArgument,
@@ -231,7 +231,7 @@ ToJSValue(JSContext* aCx,
} }
// Accept existing JS values (which may not be same-compartment with us // Accept existing JS values (which may not be same-compartment with us
MOZ_MUST_USE inline bool [[nodiscard]] inline bool
ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument, ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
{ {
@@ -240,7 +240,7 @@ ToJSValue(JSContext* aCx, JS::Handle<JS::Value> aArgument,
} }
// Accept existing JS values on the Heap (which may not be same-compartment with us // Accept existing JS values on the Heap (which may not be same-compartment with us
MOZ_MUST_USE inline bool [[nodiscard]] inline bool
ToJSValue(JSContext* aCx, const JS::Heap<JS::Value>& aArgument, ToJSValue(JSContext* aCx, const JS::Heap<JS::Value>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
{ {
@@ -249,7 +249,7 @@ ToJSValue(JSContext* aCx, const JS::Heap<JS::Value>& aArgument,
} }
// Accept existing rooted JS values (which may not be same-compartment with us // Accept existing rooted JS values (which may not be same-compartment with us
MOZ_MUST_USE inline bool [[nodiscard]] inline bool
ToJSValue(JSContext* aCx, const JS::Rooted<JS::Value>& aArgument, ToJSValue(JSContext* aCx, const JS::Rooted<JS::Value>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
{ {
@@ -259,7 +259,7 @@ ToJSValue(JSContext* aCx, const JS::Rooted<JS::Value>& aArgument,
// Accept existing rooted JS objects (which may not be same-compartment with // Accept existing rooted JS objects (which may not be same-compartment with
// us). // us).
MOZ_MUST_USE inline bool [[nodiscard]] inline bool
ToJSValue(JSContext* aCx, const JS::Rooted<JSObject*>& aArgument, ToJSValue(JSContext* aCx, const JS::Rooted<JSObject*>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
{ {
@@ -269,7 +269,7 @@ ToJSValue(JSContext* aCx, const JS::Rooted<JSObject*>& aArgument,
// Accept nsresult, for use in rejections, and create an XPCOM // Accept nsresult, for use in rejections, and create an XPCOM
// exception object representing that nsresult. // exception object representing that nsresult.
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
nsresult aArgument, nsresult aArgument,
JS::MutableHandle<JS::Value> aValue); JS::MutableHandle<JS::Value> aValue);
@@ -277,14 +277,14 @@ ToJSValue(JSContext* aCx,
// Accept ErrorResult, for use in rejections, and create an exception // Accept ErrorResult, for use in rejections, and create an exception
// representing the failure. Note, the ErrorResult must indicate a failure // representing the failure. Note, the ErrorResult must indicate a failure
// with aArgument.Failure() returning true. // with aArgument.Failure() returning true.
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
ErrorResult& aArgument, ErrorResult& aArgument,
JS::MutableHandle<JS::Value> aValue); JS::MutableHandle<JS::Value> aValue);
// Accept owning WebIDL unions. // Accept owning WebIDL unions.
template <typename T> template <typename T>
MOZ_MUST_USE [[nodiscard]]
typename EnableIf<IsBaseOf<AllOwningUnionBase, T>::value, bool>::Type typename EnableIf<IsBaseOf<AllOwningUnionBase, T>::value, bool>::Type
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const T& aArgument, const T& aArgument,
@@ -296,7 +296,7 @@ ToJSValue(JSContext* aCx,
// Accept pointers to other things we accept // Accept pointers to other things we accept
template <typename T> template <typename T>
MOZ_MUST_USE [[nodiscard]]
typename EnableIf<IsPointer<T>::value, bool>::Type typename EnableIf<IsPointer<T>::value, bool>::Type
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
T aArgument, T aArgument,
@@ -306,14 +306,14 @@ ToJSValue(JSContext* aCx,
} }
// Accept Promise objects, which need special handling. // Accept Promise objects, which need special handling.
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
Promise& aArgument, Promise& aArgument,
JS::MutableHandle<JS::Value> aValue); JS::MutableHandle<JS::Value> aValue);
// Accept arrays of other things we accept // Accept arrays of other things we accept
template <typename T> template <typename T>
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
T* aArguments, T* aArguments,
size_t aLength, size_t aLength,
@@ -340,7 +340,7 @@ ToJSValue(JSContext* aCx,
} }
template <typename T> template <typename T>
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const nsTArray<T>& aArgument, const nsTArray<T>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
@@ -350,7 +350,7 @@ ToJSValue(JSContext* aCx,
} }
template <typename T> template <typename T>
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const FallibleTArray<T>& aArgument, const FallibleTArray<T>& aArgument,
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
@@ -360,7 +360,7 @@ ToJSValue(JSContext* aCx,
} }
template <typename T, int N> template <typename T, int N>
MOZ_MUST_USE bool [[nodiscard]] bool
ToJSValue(JSContext* aCx, ToJSValue(JSContext* aCx,
const T(&aArgument)[N], const T(&aArgument)[N],
JS::MutableHandle<JS::Value> aValue) JS::MutableHandle<JS::Value> aValue)
+1 -1
View File
@@ -154,7 +154,7 @@ public:
// Whether the value change should be notified to the frame/contet nor not. // Whether the value change should be notified to the frame/contet nor not.
eSetValue_Notify = 1 << 2 eSetValue_Notify = 1 << 2
}; };
MOZ_MUST_USE bool SetValue(const nsAString& aValue, uint32_t aFlags); [[nodiscard]] bool SetValue(const nsAString& aValue, uint32_t aFlags);
void GetValue(nsAString& aValue, bool aIgnoreWrap) const; void GetValue(nsAString& aValue, bool aIgnoreWrap) const;
bool HasNonEmptyValue(); bool HasNonEmptyValue();
// The following methods are for textarea element to use whether default // The following methods are for textarea element to use whether default
+2 -2
View File
@@ -63,11 +63,11 @@ public:
virtual bool IsForApp() const = 0; virtual bool IsForApp() const = 0;
virtual bool IsForBrowser() const = 0; virtual bool IsForBrowser() const = 0;
MOZ_MUST_USE virtual PBlobParent* [[nodiscard]] virtual PBlobParent*
SendPBlobConstructor(PBlobParent* aActor, SendPBlobConstructor(PBlobParent* aActor,
const BlobConstructorParams& aParams) = 0; const BlobConstructorParams& aParams) = 0;
MOZ_MUST_USE virtual PBrowserParent* [[nodiscard]] virtual PBrowserParent*
SendPBrowserConstructor(PBrowserParent* actor, SendPBrowserConstructor(PBrowserParent* actor,
const TabId& aTabId, const TabId& aTabId,
const IPCTabContext& context, const IPCTabContext& context,
+2 -2
View File
@@ -36,7 +36,7 @@ public:
base_type::SetLength(newLen + sExtra); base_type::SetLength(newLen + sExtra);
} }
MOZ_MUST_USE [[nodiscard]]
bool SetLength(size_type newLen, const mozilla::fallible_t&) bool SetLength(size_type newLen, const mozilla::fallible_t&)
{ {
return base_type::SetLength(newLen + sExtra, mozilla::fallible); return base_type::SetLength(newLen + sExtra, mozilla::fallible);
@@ -89,7 +89,7 @@ public:
base_type::SetLength(newLen + sExtra); base_type::SetLength(newLen + sExtra);
} }
MOZ_MUST_USE [[nodiscard]]
bool SetLength(size_type newLen, const mozilla::fallible_t&) bool SetLength(size_type newLen, const mozilla::fallible_t&)
{ {
return base_type::SetLength(newLen + sExtra, mozilla::fallible); return base_type::SetLength(newLen + sExtra, mozilla::fallible);
+4 -1
View File
@@ -2210,7 +2210,10 @@ PluginModuleParent::NPP_NewInternal(NPMIMEType pluginType, NPP instance,
if (supportsAsyncRender) { if (supportsAsyncRender) {
// Prefs indicates we want async plugin rendering, make sure // Prefs indicates we want async plugin rendering, make sure
// the flash module has support. // the flash module has support.
CallModuleSupportsAsyncRender(&supportsAsyncRender); if (!CallModuleSupportsAsyncRender(&supportsAsyncRender)) {
// The actual support call failed. Should not happen; abort.
return NS_ERROR_FAILURE;
}
} }
#ifdef _WIN64 #ifdef _WIN64
// For 64-bit builds force windowless if the flash library doesn't support // For 64-bit builds force windowless if the flash library doesn't support
+3 -1
View File
@@ -34,7 +34,9 @@ public:
for (auto iter = mAudioNotificationSet->ConstIter(); !iter.Done(); iter.Next()) { for (auto iter = mAudioNotificationSet->ConstIter(); !iter.Done(); iter.Next()) {
PluginModuleParent* pluginModule = iter.Get()->GetKey(); PluginModuleParent* pluginModule = iter.Get()->GetKey();
pluginModule->SendNPP_SetValue_NPNVaudioDeviceChangeDetails(mChangeDetails); if (!pluginModule->SendNPP_SetValue_NPNVaudioDeviceChangeDetails(mChangeDetails)) {
// Sending of notification failed. Ignore for now.
}
} }
return NS_OK; return NS_OK;
} }
+2 -2
View File
@@ -287,14 +287,14 @@ public:
insertBack(aElem); insertBack(aElem);
} }
MOZ_MUST_USE [[nodiscard]]
already_AddRefed<ScriptLoadRequest> Steal(ScriptLoadRequest* aElem) already_AddRefed<ScriptLoadRequest> Steal(ScriptLoadRequest* aElem)
{ {
aElem->removeFrom(*this); aElem->removeFrom(*this);
return dont_AddRef(aElem); return dont_AddRef(aElem);
} }
MOZ_MUST_USE [[nodiscard]]
already_AddRefed<ScriptLoadRequest> StealFirst() already_AddRefed<ScriptLoadRequest> StealFirst()
{ {
MOZ_ASSERT(!isEmpty()); MOZ_ASSERT(!isEmpty());
+10 -10
View File
@@ -224,11 +224,11 @@ public:
// If aGlobalObject represents a web-visible global, errors reported by this // If aGlobalObject represents a web-visible global, errors reported by this
// AutoJSAPI as it comes off the stack will fire the relevant error events and // AutoJSAPI as it comes off the stack will fire the relevant error events and
// show up in the corresponding web console. // show up in the corresponding web console.
MOZ_MUST_USE bool Init(nsIGlobalObject* aGlobalObject); [[nodiscard]] bool Init(nsIGlobalObject* aGlobalObject);
// This is a helper that grabs the native global associated with aObject and // This is a helper that grabs the native global associated with aObject and
// invokes the above Init() with that. // invokes the above Init() with that.
MOZ_MUST_USE bool Init(JSObject* aObject); [[nodiscard]] bool Init(JSObject* aObject);
// Unsurprisingly, this uses aCx and enters the compartment of aGlobalObject. // Unsurprisingly, this uses aCx and enters the compartment of aGlobalObject.
// If aGlobalObject or its associated JS global are null then it returns // If aGlobalObject or its associated JS global are null then it returns
@@ -238,15 +238,15 @@ public:
// If aGlobalObject represents a web-visible global, errors reported by this // If aGlobalObject represents a web-visible global, errors reported by this
// AutoJSAPI as it comes off the stack will fire the relevant error events and // AutoJSAPI as it comes off the stack will fire the relevant error events and
// show up in the corresponding web console. // show up in the corresponding web console.
MOZ_MUST_USE bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx); [[nodiscard]] bool Init(nsIGlobalObject* aGlobalObject, JSContext* aCx);
// Convenience functions to take an nsPIDOMWindow* or nsGlobalWindow*, // Convenience functions to take an nsPIDOMWindow* or nsGlobalWindow*,
// when it is more easily available than an nsIGlobalObject. // when it is more easily available than an nsIGlobalObject.
MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow); [[nodiscard]] bool Init(nsPIDOMWindowInner* aWindow);
MOZ_MUST_USE bool Init(nsPIDOMWindowInner* aWindow, JSContext* aCx); [[nodiscard]] bool Init(nsPIDOMWindowInner* aWindow, JSContext* aCx);
MOZ_MUST_USE bool Init(nsGlobalWindow* aWindow); [[nodiscard]] bool Init(nsGlobalWindow* aWindow);
MOZ_MUST_USE bool Init(nsGlobalWindow* aWindow, JSContext* aCx); [[nodiscard]] bool Init(nsGlobalWindow* aWindow, JSContext* aCx);
JSContext* cx() const { JSContext* cx() const {
MOZ_ASSERT(mCx, "Must call Init before using an AutoJSAPI"); MOZ_ASSERT(mCx, "Must call Init before using an AutoJSAPI");
@@ -272,12 +272,12 @@ public:
// //
// Note that this fails if and only if we OOM while wrapping the exception // Note that this fails if and only if we OOM while wrapping the exception
// into the current compartment. // into the current compartment.
MOZ_MUST_USE bool StealException(JS::MutableHandle<JS::Value> aVal); [[nodiscard]] bool StealException(JS::MutableHandle<JS::Value> aVal);
// As for StealException(), but put the saved frames for any stack trace // As for StealException(), but put the saved frames for any stack trace
// associated with the point the exception was thrown into aStack. // associated with the point the exception was thrown into aStack.
// aVal will be in the current compartment, but aStack might not be. // aVal will be in the current compartment, but aStack might not be.
MOZ_MUST_USE bool StealExceptionAndStack(JS::MutableHandle<JS::Value> aVal, [[nodiscard]] bool StealExceptionAndStack(JS::MutableHandle<JS::Value> aVal,
JS::MutableHandle<JSObject*> aStack); JS::MutableHandle<JSObject*> aStack);
// Peek the current exception from the JS engine, without stealing it. // Peek the current exception from the JS engine, without stealing it.
@@ -286,7 +286,7 @@ public:
// //
// Note that this fails if and only if we OOM while wrapping the exception // Note that this fails if and only if we OOM while wrapping the exception
// into the current compartment. // into the current compartment.
MOZ_MUST_USE bool PeekException(JS::MutableHandle<JS::Value> aVal); [[nodiscard]] bool PeekException(JS::MutableHandle<JS::Value> aVal);
void ClearException() { void ClearException() {
MOZ_ASSERT(IsStackTop()); MOZ_ASSERT(IsStackTop());
+4 -4
View File
@@ -44,7 +44,7 @@ public:
// This method should be called only when the string is really needed because // This method should be called only when the string is really needed because
// it can cause the duplication of the strings in case the loading of the XHR // it can cause the duplication of the strings in case the loading of the XHR
// is not completed yet. // is not completed yet.
MOZ_MUST_USE bool GetAsString(nsAString& aString) const; [[nodiscard]] bool GetAsString(nsAString& aString) const;
size_t SizeOfThis(MallocSizeOf aMallocSizeOf) const; size_t SizeOfThis(MallocSizeOf aMallocSizeOf) const;
@@ -121,7 +121,7 @@ public:
return !mLength; return !mLength;
} }
MOZ_MUST_USE bool GetAsString(DOMString& aString) const; [[nodiscard]] bool GetAsString(DOMString& aString) const;
private: private:
XMLHttpRequestStringSnapshot(const XMLHttpRequestStringSnapshot&) = delete; XMLHttpRequestStringSnapshot(const XMLHttpRequestStringSnapshot&) = delete;
@@ -193,7 +193,7 @@ public:
mData.Append(aString); mData.Append(aString);
} }
MOZ_MUST_USE bool [[nodiscard]] bool
GetAsString(nsAString& aString) GetAsString(nsAString& aString)
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
@@ -206,7 +206,7 @@ public:
return mData.SizeOfExcludingThisIfUnshared(aMallocSizeOf); return mData.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
} }
MOZ_MUST_USE bool [[nodiscard]] bool
GetAsString(DOMString& aString, uint32_t aLength) GetAsString(DOMString& aString, uint32_t aLength)
{ {
MutexAutoLock lock(mMutex); MutexAutoLock lock(mMutex);
+1 -1
View File
@@ -60,7 +60,7 @@ public:
{ {
} }
~txLoadedDocumentsHash(); ~txLoadedDocumentsHash();
MOZ_MUST_USE nsresult init(const txXPathNode& aSource); [[nodiscard]] nsresult init(const txXPathNode& aSource);
private: private:
friend class txExecutionState; friend class txExecutionState;
+6 -6
View File
@@ -111,7 +111,7 @@ struct BaseRect {
// Intersection with an empty Rect may not produce an empty Rect if overflow // Intersection with an empty Rect may not produce an empty Rect if overflow
// occurs. e.g. {INT_MIN, 0, 0, 20} Intersect { 5000, 0, 500, 20 } gives: // occurs. e.g. {INT_MIN, 0, 0, 20} Intersect { 5000, 0, 500, 20 } gives:
// the non-emtpy {5000, 0, 500, 20 } instead of {5000, 0, 0, 0} // the non-emtpy {5000, 0, 500, 20 } instead of {5000, 0, 0, 0}
MOZ_MUST_USE Sub Intersect(const Sub& aRect) const [[nodiscard]] Sub Intersect(const Sub& aRect) const
{ {
Sub result; Sub result;
result.x = std::max<T>(x, aRect.x); result.x = std::max<T>(x, aRect.x);
@@ -127,7 +127,7 @@ struct BaseRect {
// better. This comes at a tiny cost in performance. // better. This comes at a tiny cost in performance.
// e.g. {INT_MIN, 0, 0, 20} Intersect { 5000, 0, 500, 20 } gives: // e.g. {INT_MIN, 0, 0, 20} Intersect { 5000, 0, 500, 20 } gives:
// {5000, 0, 0, 0} // {5000, 0, 0, 0}
MOZ_MUST_USE Sub SafeIntersect(const Sub& aRect) const [[nodiscard]] Sub SafeIntersect(const Sub& aRect) const
{ {
Sub result; Sub result;
result.x = std::max<T>(x, aRect.x); result.x = std::max<T>(x, aRect.x);
@@ -161,7 +161,7 @@ struct BaseRect {
// If both rectangles are empty, returns this. // If both rectangles are empty, returns this.
// WARNING! This is not safe against overflow, prefer using SafeUnion instead // WARNING! This is not safe against overflow, prefer using SafeUnion instead
// when dealing with int-based rects. // when dealing with int-based rects.
MOZ_MUST_USE Sub Union(const Sub& aRect) const [[nodiscard]] Sub Union(const Sub& aRect) const
{ {
if (IsEmpty()) { if (IsEmpty()) {
return aRect; return aRect;
@@ -176,7 +176,7 @@ struct BaseRect {
// Thus, empty input rectangles are allowed to affect the result. // Thus, empty input rectangles are allowed to affect the result.
// WARNING! This is not safe against overflow, prefer using SafeUnionEdges // WARNING! This is not safe against overflow, prefer using SafeUnionEdges
// instead when dealing with int-based rects. // instead when dealing with int-based rects.
MOZ_MUST_USE Sub UnionEdges(const Sub& aRect) const [[nodiscard]] Sub UnionEdges(const Sub& aRect) const
{ {
Sub result; Sub result;
result.x = std::min(x, aRect.x); result.x = std::min(x, aRect.x);
@@ -588,7 +588,7 @@ struct BaseRect {
* Clamp aPoint to this rectangle. It is allowed to end up on any * Clamp aPoint to this rectangle. It is allowed to end up on any
* edge of the rectangle. * edge of the rectangle.
*/ */
MOZ_MUST_USE Point ClampPoint(const Point& aPoint) const [[nodiscard]] Point ClampPoint(const Point& aPoint) const
{ {
return Point(std::max(x, std::min(XMost(), aPoint.x)), return Point(std::max(x, std::min(XMost(), aPoint.x)),
std::max(y, std::min(YMost(), aPoint.y))); std::max(y, std::min(YMost(), aPoint.y)));
@@ -599,7 +599,7 @@ struct BaseRect {
* aRect then the dimensions that don't fit will be shrunk so that they * aRect then the dimensions that don't fit will be shrunk so that they
* do fit. The resulting rect is returned. * do fit. The resulting rect is returned.
*/ */
MOZ_MUST_USE Sub MoveInsideAndClamp(const Sub& aRect) const [[nodiscard]] Sub MoveInsideAndClamp(const Sub& aRect) const
{ {
Sub rect(std::max(aRect.x, x), Sub rect(std::max(aRect.x, x),
std::max(aRect.y, y), std::max(aRect.y, y),
+2 -2
View File
@@ -166,7 +166,7 @@ struct IntRectTyped :
// Same as Union(), but in the cases where aRect is non-empty, the union is // Same as Union(), but in the cases where aRect is non-empty, the union is
// done while guarding against overflow. If an overflow is detected, Nothing // done while guarding against overflow. If an overflow is detected, Nothing
// is returned. // is returned.
MOZ_MUST_USE Maybe<Self> SafeUnion(const Self& aRect) const [[nodiscard]] Maybe<Self> SafeUnion(const Self& aRect) const
{ {
if (this->IsEmpty()) { if (this->IsEmpty()) {
return aRect.Overflows() ? Nothing() : Some(aRect); return aRect.Overflows() ? Nothing() : Some(aRect);
@@ -179,7 +179,7 @@ struct IntRectTyped :
// Same as UnionEdges, but guards against overflow. If an overflow is detected, // Same as UnionEdges, but guards against overflow. If an overflow is detected,
// Nothing is returned. // Nothing is returned.
MOZ_MUST_USE Maybe<Self> SafeUnionEdges(const Self& aRect) const [[nodiscard]] Maybe<Self> SafeUnionEdges(const Self& aRect) const
{ {
if (this->Overflows() || aRect.Overflows()) { if (this->Overflows() || aRect.Overflows()) {
return Nothing(); return Nothing();
@@ -823,9 +823,9 @@ extern int pplex \
*/ */
YY_DECL YY_DECL
{ {
register yy_state_type yy_current_state; yy_state_type yy_current_state;
register char *yy_cp, *yy_bp; char *yy_cp, *yy_bp;
register int yy_act; int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yylval = yylval_param; yylval = yylval_param;
@@ -878,7 +878,7 @@ YY_DECL
yy_match: yy_match:
do do
{ {
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@@ -1336,9 +1336,9 @@ ECHO;
static int yy_get_next_buffer (yyscan_t yyscanner) static int yy_get_next_buffer (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = yyg->yytext_ptr; char *source = yyg->yytext_ptr;
register int number_to_move, i; int number_to_move, i;
int ret_val; int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -1470,15 +1470,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
static yy_state_type yy_get_previous_state (yyscan_t yyscanner) static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{ {
register yy_state_type yy_current_state; yy_state_type yy_current_state;
register char *yy_cp; char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_current_state = yyg->yy_start; yy_current_state = yyg->yy_start;
for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{ {
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@@ -1503,11 +1503,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/ */
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{ {
register int yy_is_jam; int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
register char *yy_cp = yyg->yy_c_buf_p; char *yy_cp = yyg->yy_c_buf_p;
register YY_CHAR yy_c = 1; YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@@ -1286,9 +1286,9 @@ extern int yylex \
*/ */
YY_DECL YY_DECL
{ {
register yy_state_type yy_current_state; yy_state_type yy_current_state;
register char *yy_cp, *yy_bp; char *yy_cp, *yy_bp;
register int yy_act; int yy_act;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yylval = yylval_param; yylval = yylval_param;
@@ -1341,7 +1341,7 @@ YY_DECL
yy_match: yy_match:
do do
{ {
register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@@ -2237,9 +2237,9 @@ ECHO;
static int yy_get_next_buffer (yyscan_t yyscanner) static int yy_get_next_buffer (yyscan_t yyscanner)
{ {
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
register char *source = yyg->yytext_ptr; char *source = yyg->yytext_ptr;
register int number_to_move, i; int number_to_move, i;
int ret_val; int ret_val;
if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] ) if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
@@ -2371,15 +2371,15 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
static yy_state_type yy_get_previous_state (yyscan_t yyscanner) static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
{ {
register yy_state_type yy_current_state; yy_state_type yy_current_state;
register char *yy_cp; char *yy_cp;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
yy_current_state = yyg->yy_start; yy_current_state = yyg->yy_start;
for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp ) for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
{ {
register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
@@ -2404,11 +2404,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
*/ */
static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner) static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
{ {
register int yy_is_jam; int yy_is_jam;
struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
register char *yy_cp = yyg->yy_c_buf_p; char *yy_cp = yyg->yy_c_buf_p;
register YY_CHAR yy_c = 1; YY_CHAR yy_c = 1;
if ( yy_accept[yy_current_state] ) if ( yy_accept[yy_current_state] )
{ {
yyg->yy_last_accepting_state = yy_current_state; yyg->yy_last_accepting_state = yy_current_state;
+3 -3
View File
@@ -35,12 +35,12 @@ struct nsPoint : public mozilla::gfx::BasePoint<nscoord, nsPoint> {
* @param aFromAPP the APP to scale from * @param aFromAPP the APP to scale from
* @param aToAPP the APP to scale to * @param aToAPP the APP to scale to
*/ */
MOZ_MUST_USE inline nsPoint [[nodiscard]] inline nsPoint
ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const; ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
MOZ_MUST_USE inline nsPoint [[nodiscard]] inline nsPoint
RemoveResolution(const float resolution) const; RemoveResolution(const float resolution) const;
MOZ_MUST_USE inline nsPoint [[nodiscard]] inline nsPoint
ApplyResolution(const float resolution) const; ApplyResolution(const float resolution) const;
}; };
+13 -13
View File
@@ -56,7 +56,7 @@ struct nsRect :
// overflowing nscoord values in the 'width' and 'height' fields by // overflowing nscoord values in the 'width' and 'height' fields by
// clamping the width and height values to nscoord_MAX if necessary. // clamping the width and height values to nscoord_MAX if necessary.
MOZ_MUST_USE nsRect SaturatingUnion(const nsRect& aRect) const [[nodiscard]] nsRect SaturatingUnion(const nsRect& aRect) const
{ {
if (IsEmpty()) { if (IsEmpty()) {
return aRect; return aRect;
@@ -67,7 +67,7 @@ struct nsRect :
} }
} }
MOZ_MUST_USE nsRect SaturatingUnionEdges(const nsRect& aRect) const [[nodiscard]] nsRect SaturatingUnionEdges(const nsRect& aRect) const
{ {
#ifdef NS_COORD_IS_FLOAT #ifdef NS_COORD_IS_FLOAT
return UnionEdges(aRect); return UnionEdges(aRect);
@@ -102,7 +102,7 @@ struct nsRect :
#ifndef NS_COORD_IS_FLOAT #ifndef NS_COORD_IS_FLOAT
// Make all nsRect Union methods be saturating. // Make all nsRect Union methods be saturating.
MOZ_MUST_USE nsRect UnionEdges(const nsRect& aRect) const [[nodiscard]] nsRect UnionEdges(const nsRect& aRect) const
{ {
return SaturatingUnionEdges(aRect); return SaturatingUnionEdges(aRect);
} }
@@ -110,7 +110,7 @@ struct nsRect :
{ {
*this = aRect1.UnionEdges(aRect2); *this = aRect1.UnionEdges(aRect2);
} }
MOZ_MUST_USE nsRect Union(const nsRect& aRect) const [[nodiscard]] nsRect Union(const nsRect& aRect) const
{ {
return SaturatingUnion(aRect); return SaturatingUnion(aRect);
} }
@@ -141,32 +141,32 @@ struct nsRect :
* @param aToAPP the APP to scale to * @param aToAPP the APP to scale to
* @note this can turn an empty rectangle into a non-empty rectangle * @note this can turn an empty rectangle into a non-empty rectangle
*/ */
MOZ_MUST_USE inline nsRect [[nodiscard]] inline nsRect
ScaleToOtherAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const; ScaleToOtherAppUnitsRoundOut(int32_t aFromAPP, int32_t aToAPP) const;
MOZ_MUST_USE inline nsRect [[nodiscard]] inline nsRect
ScaleToOtherAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const; ScaleToOtherAppUnitsRoundIn(int32_t aFromAPP, int32_t aToAPP) const;
MOZ_MUST_USE inline mozilla::gfx::IntRect [[nodiscard]] inline mozilla::gfx::IntRect
ScaleToNearestPixels(float aXScale, float aYScale, ScaleToNearestPixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const; nscoord aAppUnitsPerPixel) const;
MOZ_MUST_USE inline mozilla::gfx::IntRect [[nodiscard]] inline mozilla::gfx::IntRect
ToNearestPixels(nscoord aAppUnitsPerPixel) const; ToNearestPixels(nscoord aAppUnitsPerPixel) const;
// Note: this can turn an empty rectangle into a non-empty rectangle // Note: this can turn an empty rectangle into a non-empty rectangle
MOZ_MUST_USE inline mozilla::gfx::IntRect [[nodiscard]] inline mozilla::gfx::IntRect
ScaleToOutsidePixels(float aXScale, float aYScale, ScaleToOutsidePixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const; nscoord aAppUnitsPerPixel) const;
// Note: this can turn an empty rectangle into a non-empty rectangle // Note: this can turn an empty rectangle into a non-empty rectangle
MOZ_MUST_USE inline mozilla::gfx::IntRect [[nodiscard]] inline mozilla::gfx::IntRect
ToOutsidePixels(nscoord aAppUnitsPerPixel) const; ToOutsidePixels(nscoord aAppUnitsPerPixel) const;
MOZ_MUST_USE inline mozilla::gfx::IntRect [[nodiscard]] inline mozilla::gfx::IntRect
ScaleToInsidePixels(float aXScale, float aYScale, ScaleToInsidePixels(float aXScale, float aYScale,
nscoord aAppUnitsPerPixel) const; nscoord aAppUnitsPerPixel) const;
MOZ_MUST_USE inline mozilla::gfx::IntRect [[nodiscard]] inline mozilla::gfx::IntRect
ToInsidePixels(nscoord aAppUnitsPerPixel) const; ToInsidePixels(nscoord aAppUnitsPerPixel) const;
// This is here only to keep IPDL-generated code happy. DO NOT USE. // This is here only to keep IPDL-generated code happy. DO NOT USE.
@@ -175,7 +175,7 @@ struct nsRect :
return IsEqualEdges(aRect); return IsEqualEdges(aRect);
} }
MOZ_MUST_USE inline nsRect RemoveResolution(const float aResolution) const; [[nodiscard]] inline nsRect RemoveResolution(const float aResolution) const;
}; };
/* /*
+2 -2
View File
@@ -296,9 +296,9 @@ public:
* @param aToAPP the APP to scale to * @param aToAPP the APP to scale to
* @note this can turn an empty region into a non-empty region * @note this can turn an empty region into a non-empty region
*/ */
MOZ_MUST_USE nsRegion [[nodiscard]] nsRegion
ScaleToOtherAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const; ScaleToOtherAppUnitsRoundOut (int32_t aFromAPP, int32_t aToAPP) const;
MOZ_MUST_USE nsRegion [[nodiscard]] nsRegion
ScaleToOtherAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const; ScaleToOtherAppUnitsRoundIn (int32_t aFromAPP, int32_t aToAPP) const;
nsRegion& ScaleRoundOut(float aXScale, float aYScale); nsRegion& ScaleRoundOut(float aXScale, float aYScale);
nsRegion& ScaleInverseRoundOut(float aXScale, float aYScale); nsRegion& ScaleInverseRoundOut(float aXScale, float aYScale);
+1 -1
View File
@@ -30,7 +30,7 @@ struct nsSize : public mozilla::gfx::BaseSize<nscoord, nsSize> {
* @param aFromAPP the APP to scale from * @param aFromAPP the APP to scale from
* @param aToAPP the APP to scale to * @param aToAPP the APP to scale to
*/ */
MOZ_MUST_USE inline nsSize [[nodiscard]] inline nsSize
ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const; ScaleToOtherAppUnits(int32_t aFromAPP, int32_t aToAPP) const;
}; };
+3 -3
View File
@@ -333,7 +333,7 @@ void NotifyScreenConfigurationChange(const hal::ScreenConfiguration& aScreenConf
* Lock the screen orientation to the specific orientation. * Lock the screen orientation to the specific orientation.
* @return Whether the lock has been accepted. * @return Whether the lock has been accepted.
*/ */
MOZ_MUST_USE bool LockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation); [[nodiscard]] bool LockScreenOrientation(const dom::ScreenOrientationInternal& aOrientation);
/** /**
* Unlock the screen orientation. * Unlock the screen orientation.
@@ -346,7 +346,7 @@ void UnlockScreenOrientation();
* *
* Currently, there can only be 0 or 1 alarm observers. * Currently, there can only be 0 or 1 alarm observers.
*/ */
MOZ_MUST_USE bool RegisterTheOneAlarmObserver(hal::AlarmObserver* aObserver); [[nodiscard]] bool RegisterTheOneAlarmObserver(hal::AlarmObserver* aObserver);
/** /**
* Unregister the alarm observer. Doing so will implicitly cancel any * Unregister the alarm observer. Doing so will implicitly cancel any
@@ -373,7 +373,7 @@ void NotifyAlarmFired();
* This API is currently only allowed to be used from non-sandboxed * This API is currently only allowed to be used from non-sandboxed
* contexts. * contexts.
*/ */
MOZ_MUST_USE bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds); [[nodiscard]] bool SetAlarm(int32_t aSeconds, int32_t aNanoseconds);
/** /**
* Set the priority of the given process. * Set the priority of the given process.
+1 -1
View File
@@ -56,7 +56,7 @@ void DisableScreenConfigurationNotifications();
/** /**
* Enable alarm notifications from the backend. * Enable alarm notifications from the backend.
*/ */
MOZ_MUST_USE bool EnableAlarm(); [[nodiscard]] bool EnableAlarm();
/** /**
* Disable alarm notifications from the backend. * Disable alarm notifications from the backend.
+15 -15
View File
@@ -287,22 +287,22 @@ public:
imgLoader(); imgLoader();
nsresult Init(); nsresult Init();
MOZ_MUST_USE nsresult LoadImage(nsIURI* aURI, [[nodiscard]] nsresult LoadImage(nsIURI* aURI,
nsIURI* aInitialDocumentURI, nsIURI* aInitialDocumentURI,
nsIURI* aReferrerURI, nsIURI* aReferrerURI,
ReferrerPolicy aReferrerPolicy, ReferrerPolicy aReferrerPolicy,
nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aLoadingPrincipal,
nsILoadGroup* aLoadGroup, nsILoadGroup* aLoadGroup,
imgINotificationObserver* aObserver, imgINotificationObserver* aObserver,
nsINode* aContext, nsINode* aContext,
nsIDocument* aLoadingDocument, nsIDocument* aLoadingDocument,
nsLoadFlags aLoadFlags, nsLoadFlags aLoadFlags,
nsISupports* aCacheKey, nsISupports* aCacheKey,
nsContentPolicyType aContentPolicyType, nsContentPolicyType aContentPolicyType,
const nsAString& initiatorType, const nsAString& initiatorType,
imgRequestProxy** _retval); imgRequestProxy** _retval);
MOZ_MUST_USE nsresult [[nodiscard]] nsresult
LoadImageWithChannel(nsIChannel* channel, LoadImageWithChannel(nsIChannel* channel,
imgINotificationObserver* aObserver, imgINotificationObserver* aObserver,
nsISupports* aCX, nsISupports* aCX,
+10 -10
View File
@@ -65,16 +65,16 @@ public:
NS_DECL_NSIINTERFACEREQUESTOR NS_DECL_NSIINTERFACEREQUESTOR
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
MOZ_MUST_USE nsresult Init(nsIURI* aURI, [[nodiscard]] nsresult Init(nsIURI* aURI,
nsIURI* aCurrentURI, nsIURI* aCurrentURI,
bool aHadInsecureRedirect, bool aHadInsecureRedirect,
nsIRequest* aRequest, nsIRequest* aRequest,
nsIChannel* aChannel, nsIChannel* aChannel,
imgCacheEntry* aCacheEntry, imgCacheEntry* aCacheEntry,
nsISupports* aCX, nsISupports* aCX,
nsIPrincipal* aLoadingPrincipal, nsIPrincipal* aLoadingPrincipal,
int32_t aCORSMode, int32_t aCORSMode,
ReferrerPolicy aReferrerPolicy); ReferrerPolicy aReferrerPolicy);
void ClearLoader(); void ClearLoader();
+3 -3
View File
@@ -110,9 +110,9 @@ public:
* NS_ERROR_OUT_OF_MEMORY if OOM * NS_ERROR_OUT_OF_MEMORY if OOM
* NS_OK is all we have is an approximation * NS_OK is all we have is an approximation
*/ */
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength) = 0; int32_t* aDestLength) = 0;
/** /**
* Resets the charset converter so it may be recycled for a completely * Resets the charset converter so it may be recycled for a completely
+3 -3
View File
@@ -135,9 +135,9 @@ public:
* NS_ERROR_OUT_OF_MEMORY if OOM * NS_ERROR_OUT_OF_MEMORY if OOM
* NS_OK if all we have is an approximation * NS_OK if all we have is an approximation
*/ */
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char16_t* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char16_t* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength) = 0; int32_t* aDestLength) = 0;
/** /**
* Resets the charset converter so it may be recycled for a completely * Resets the charset converter so it may be recycled for a completely
+3 -3
View File
@@ -24,9 +24,9 @@ public:
char16_t* aDest, char16_t* aDest,
int32_t* aDestLength) override; int32_t* aDestLength) override;
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength) override; int32_t* aDestLength) override;
NS_IMETHOD Reset() override; NS_IMETHOD Reset() override;
+3 -3
View File
@@ -49,9 +49,9 @@ protected:
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Subclassing of nsDecoderSupport class [declaration] // Subclassing of nsDecoderSupport class [declaration]
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength) override; int32_t* aDestLength) override;
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Subclassing of nsBasicDecoderSupport class [declaration] // Subclassing of nsBasicDecoderSupport class [declaration]
+3 -3
View File
@@ -48,9 +48,9 @@ public:
NS_IMETHOD Finish(char* aDest, int32_t* aDestLength) override; NS_IMETHOD Finish(char* aDest, int32_t* aDestLength) override;
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char16_t* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char16_t* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength) override; int32_t* aDestLength) override;
NS_IMETHOD Reset() override {mHighSurrogate = 0; return NS_OK;} NS_IMETHOD Reset() override {mHighSurrogate = 0; return NS_OK;}
+3 -3
View File
@@ -24,9 +24,9 @@ public:
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Subclassing of nsDecoderSupport class [declaration] // Subclassing of nsDecoderSupport class [declaration]
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength) override; int32_t* aDestLength) override;
NS_IMETHOD Reset() override; NS_IMETHOD Reset() override;
protected: protected:
+3 -3
View File
@@ -19,9 +19,9 @@ public:
NS_IMETHOD Convert(const char16_t* aSrc, int32_t* aSrcLength, NS_IMETHOD Convert(const char16_t* aSrc, int32_t* aSrcLength,
char* aDest, int32_t* aDestLength); char* aDest, int32_t* aDestLength);
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char16_t* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char16_t* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength); int32_t* aDestLength);
NS_IMETHOD Finish(char* aDest, int32_t* aDestLength); NS_IMETHOD Finish(char* aDest, int32_t* aDestLength);
NS_IMETHOD Reset(); NS_IMETHOD Reset();
NS_IMETHOD SetOutputErrorBehavior(int32_t aBehavior, NS_IMETHOD SetOutputErrorBehavior(int32_t aBehavior,
+3 -3
View File
@@ -29,9 +29,9 @@ public:
NS_IMETHOD Finish(char* aDest, NS_IMETHOD Finish(char* aDest,
int32_t* aDestLength) override; int32_t* aDestLength) override;
MOZ_MUST_USE NS_IMETHOD GetMaxLength(const char16_t* aSrc, [[nodiscard]] NS_IMETHOD GetMaxLength(const char16_t* aSrc,
int32_t aSrcLength, int32_t aSrcLength,
int32_t* aDestLength) override; int32_t* aDestLength) override;
NS_IMETHOD Reset() override; NS_IMETHOD Reset() override;
+23 -22
View File
@@ -1,5 +1,6 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Copyright (c) 2023, Moonchild Productions.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
@@ -92,32 +93,32 @@ class Pickle {
// the Pickle, initialize *iter to NULL. If successful, these methods return // the Pickle, initialize *iter to NULL. If successful, these methods return
// true. Otherwise, false is returned to indicate that the result could not // true. Otherwise, false is returned to indicate that the result could not
// be extracted. // be extracted.
MOZ_MUST_USE bool ReadBool(PickleIterator* iter, bool* result) const; [[nodiscard]] bool ReadBool(PickleIterator* iter, bool* result) const;
MOZ_MUST_USE bool ReadInt16(PickleIterator* iter, int16_t* result) const; [[nodiscard]] bool ReadInt16(PickleIterator* iter, int16_t* result) const;
MOZ_MUST_USE bool ReadUInt16(PickleIterator* iter, uint16_t* result) const; [[nodiscard]] bool ReadUInt16(PickleIterator* iter, uint16_t* result) const;
MOZ_MUST_USE bool ReadShort(PickleIterator* iter, short* result) const; [[nodiscard]] bool ReadShort(PickleIterator* iter, short* result) const;
MOZ_MUST_USE bool ReadInt(PickleIterator* iter, int* result) const; [[nodiscard]] bool ReadInt(PickleIterator* iter, int* result) const;
MOZ_MUST_USE bool ReadLong(PickleIterator* iter, long* result) const; [[nodiscard]] bool ReadLong(PickleIterator* iter, long* result) const;
MOZ_MUST_USE bool ReadULong(PickleIterator* iter, unsigned long* result) const; [[nodiscard]] bool ReadULong(PickleIterator* iter, unsigned long* result) const;
MOZ_MUST_USE bool ReadSize(PickleIterator* iter, size_t* result) const; [[nodiscard]] bool ReadSize(PickleIterator* iter, size_t* result) const;
MOZ_MUST_USE bool ReadInt32(PickleIterator* iter, int32_t* result) const; [[nodiscard]] bool ReadInt32(PickleIterator* iter, int32_t* result) const;
MOZ_MUST_USE bool ReadUInt32(PickleIterator* iter, uint32_t* result) const; [[nodiscard]] bool ReadUInt32(PickleIterator* iter, uint32_t* result) const;
MOZ_MUST_USE bool ReadInt64(PickleIterator* iter, int64_t* result) const; [[nodiscard]] bool ReadInt64(PickleIterator* iter, int64_t* result) const;
MOZ_MUST_USE bool ReadUInt64(PickleIterator* iter, uint64_t* result) const; [[nodiscard]] bool ReadUInt64(PickleIterator* iter, uint64_t* result) const;
MOZ_MUST_USE bool ReadDouble(PickleIterator* iter, double* result) const; [[nodiscard]] bool ReadDouble(PickleIterator* iter, double* result) const;
MOZ_MUST_USE bool ReadIntPtr(PickleIterator* iter, intptr_t* result) const; [[nodiscard]] bool ReadIntPtr(PickleIterator* iter, intptr_t* result) const;
MOZ_MUST_USE bool ReadUnsignedChar(PickleIterator* iter, unsigned char* result) const; [[nodiscard]] bool ReadUnsignedChar(PickleIterator* iter, unsigned char* result) const;
MOZ_MUST_USE bool ReadString(PickleIterator* iter, std::string* result) const; [[nodiscard]] bool ReadString(PickleIterator* iter, std::string* result) const;
MOZ_MUST_USE bool ReadWString(PickleIterator* iter, std::wstring* result) const; [[nodiscard]] bool ReadWString(PickleIterator* iter, std::wstring* result) const;
MOZ_MUST_USE bool ReadBytesInto(PickleIterator* iter, void* data, uint32_t length) const; [[nodiscard]] bool ReadBytesInto(PickleIterator* iter, void* data, uint32_t length) const;
MOZ_MUST_USE bool ExtractBuffers(PickleIterator* iter, size_t length, BufferList* buffers, [[nodiscard]] bool ExtractBuffers(PickleIterator* iter, size_t length, BufferList* buffers,
uint32_t alignment = sizeof(memberAlignmentType)) const; uint32_t alignment = sizeof(memberAlignmentType)) const;
// Safer version of ReadInt() checks for the result not being negative. // Safer version of ReadInt() checks for the result not being negative.
// Use it for reading the object sizes. // Use it for reading the object sizes.
MOZ_MUST_USE bool ReadLength(PickleIterator* iter, int* result) const; [[nodiscard]] bool ReadLength(PickleIterator* iter, int* result) const;
MOZ_MUST_USE bool ReadSentinel(PickleIterator* iter, uint32_t sentinel) const [[nodiscard]] bool ReadSentinel(PickleIterator* iter, uint32_t sentinel) const
#ifdef MOZ_PICKLE_SENTINEL_CHECKING #ifdef MOZ_PICKLE_SENTINEL_CHECKING
; ;
#else #else
+1 -1
View File
@@ -185,7 +185,7 @@ class CxxCodeGen(CodePrinter, Visitor):
self.printdent() self.printdent()
if md.warn_unused: if md.warn_unused:
self.write('MOZ_MUST_USE ') self.write('[[nodiscard]] ')
if md.inline: if md.inline:
self.write('inline ') self.write('inline ')
if md.never_inline: if md.never_inline:
+1 -1
View File
@@ -37,7 +37,7 @@ public:
return mPtr.get(); return mPtr.get();
} }
MOZ_MUST_USE Interface* Release() [[nodiscard]] Interface* Release()
{ {
return mPtr.release(); return mPtr.release();
} }
+16 -16
View File
@@ -88,7 +88,7 @@ class HashMap
// HashMap construction is fallible (due to OOM); thus the user must call // HashMap construction is fallible (due to OOM); thus the user must call
// init after constructing a HashMap and check the return value. // init after constructing a HashMap and check the return value.
explicit HashMap(AllocPolicy a = AllocPolicy()) : impl(a) {} explicit HashMap(AllocPolicy a = AllocPolicy()) : impl(a) {}
MOZ_MUST_USE bool init(uint32_t len = 16) { return impl.init(len); } [[nodiscard]] bool init(uint32_t len = 16) { return impl.init(len); }
bool initialized() const { return impl.initialized(); } bool initialized() const { return impl.initialized(); }
// Return whether the given lookup value is present in the map. E.g.: // Return whether the given lookup value is present in the map. E.g.:
@@ -151,19 +151,19 @@ class HashMap
} }
template<typename KeyInput, typename ValueInput> template<typename KeyInput, typename ValueInput>
MOZ_MUST_USE bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) { [[nodiscard]] bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) {
return impl.add(p, return impl.add(p,
mozilla::Forward<KeyInput>(k), mozilla::Forward<KeyInput>(k),
mozilla::Forward<ValueInput>(v)); mozilla::Forward<ValueInput>(v));
} }
template<typename KeyInput> template<typename KeyInput>
MOZ_MUST_USE bool add(AddPtr& p, KeyInput&& k) { [[nodiscard]] bool add(AddPtr& p, KeyInput&& k) {
return impl.add(p, mozilla::Forward<KeyInput>(k), Value()); return impl.add(p, mozilla::Forward<KeyInput>(k), Value());
} }
template<typename KeyInput, typename ValueInput> template<typename KeyInput, typename ValueInput>
MOZ_MUST_USE bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) { [[nodiscard]] bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) {
return impl.relookupOrAdd(p, k, return impl.relookupOrAdd(p, k,
mozilla::Forward<KeyInput>(k), mozilla::Forward<KeyInput>(k),
mozilla::Forward<ValueInput>(v)); mozilla::Forward<ValueInput>(v));
@@ -232,7 +232,7 @@ class HashMap
// Overwrite existing value with v. Return false on oom. // Overwrite existing value with v. Return false on oom.
template<typename KeyInput, typename ValueInput> template<typename KeyInput, typename ValueInput>
MOZ_MUST_USE bool put(KeyInput&& k, ValueInput&& v) { [[nodiscard]] bool put(KeyInput&& k, ValueInput&& v) {
AddPtr p = lookupForAdd(k); AddPtr p = lookupForAdd(k);
if (p) { if (p) {
p->value() = mozilla::Forward<ValueInput>(v); p->value() = mozilla::Forward<ValueInput>(v);
@@ -243,7 +243,7 @@ class HashMap
// Like put, but assert that the given key is not already present. // Like put, but assert that the given key is not already present.
template<typename KeyInput, typename ValueInput> template<typename KeyInput, typename ValueInput>
MOZ_MUST_USE bool putNew(KeyInput&& k, ValueInput&& v) { [[nodiscard]] bool putNew(KeyInput&& k, ValueInput&& v) {
return impl.putNew(k, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v)); return impl.putNew(k, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v));
} }
@@ -341,7 +341,7 @@ class HashSet
// HashSet construction is fallible (due to OOM); thus the user must call // HashSet construction is fallible (due to OOM); thus the user must call
// init after constructing a HashSet and check the return value. // init after constructing a HashSet and check the return value.
explicit HashSet(AllocPolicy a = AllocPolicy()) : impl(a) {} explicit HashSet(AllocPolicy a = AllocPolicy()) : impl(a) {}
MOZ_MUST_USE bool init(uint32_t len = 16) { return impl.init(len); } [[nodiscard]] bool init(uint32_t len = 16) { return impl.init(len); }
bool initialized() const { return impl.initialized(); } bool initialized() const { return impl.initialized(); }
// Return whether the given lookup value is present in the map. E.g.: // Return whether the given lookup value is present in the map. E.g.:
@@ -399,12 +399,12 @@ class HashSet
AddPtr lookupForAdd(const Lookup& l) const { return impl.lookupForAdd(l); } AddPtr lookupForAdd(const Lookup& l) const { return impl.lookupForAdd(l); }
template <typename U> template <typename U>
MOZ_MUST_USE bool add(AddPtr& p, U&& u) { [[nodiscard]] bool add(AddPtr& p, U&& u) {
return impl.add(p, mozilla::Forward<U>(u)); return impl.add(p, mozilla::Forward<U>(u));
} }
template <typename U> template <typename U>
MOZ_MUST_USE bool relookupOrAdd(AddPtr& p, const Lookup& l, U&& u) { [[nodiscard]] bool relookupOrAdd(AddPtr& p, const Lookup& l, U&& u) {
return impl.relookupOrAdd(p, l, mozilla::Forward<U>(u)); return impl.relookupOrAdd(p, l, mozilla::Forward<U>(u));
} }
@@ -471,19 +471,19 @@ class HashSet
// Add |u| if it is not present already. Return false on oom. // Add |u| if it is not present already. Return false on oom.
template <typename U> template <typename U>
MOZ_MUST_USE bool put(U&& u) { [[nodiscard]] bool put(U&& u) {
AddPtr p = lookupForAdd(u); AddPtr p = lookupForAdd(u);
return p ? true : add(p, mozilla::Forward<U>(u)); return p ? true : add(p, mozilla::Forward<U>(u));
} }
// Like put, but assert that the given key is not already present. // Like put, but assert that the given key is not already present.
template <typename U> template <typename U>
MOZ_MUST_USE bool putNew(U&& u) { [[nodiscard]] bool putNew(U&& u) {
return impl.putNew(u, mozilla::Forward<U>(u)); return impl.putNew(u, mozilla::Forward<U>(u));
} }
template <typename U> template <typename U>
MOZ_MUST_USE bool putNew(const Lookup& l, U&& u) { [[nodiscard]] bool putNew(const Lookup& l, U&& u) {
return impl.putNew(l, mozilla::Forward<U>(u)); return impl.putNew(l, mozilla::Forward<U>(u));
} }
@@ -1277,7 +1277,7 @@ class HashTable : private AllocPolicy
#endif #endif
{} {}
MOZ_MUST_USE bool init(uint32_t length) [[nodiscard]] bool init(uint32_t length)
{ {
MOZ_ASSERT(!initialized()); MOZ_ASSERT(!initialized());
@@ -1775,7 +1775,7 @@ class HashTable : private AllocPolicy
} }
template <typename... Args> template <typename... Args>
MOZ_MUST_USE bool add(AddPtr& p, Args&&... args) [[nodiscard]] bool add(AddPtr& p, Args&&... args)
{ {
mozilla::ReentrancyGuard g(*this); mozilla::ReentrancyGuard g(*this);
MOZ_ASSERT(table); MOZ_ASSERT(table);
@@ -1828,7 +1828,7 @@ class HashTable : private AllocPolicy
// Note: |l| may be alias arguments in |args|, so this function must take // Note: |l| may be alias arguments in |args|, so this function must take
// care not to use |l| after moving |args|. // care not to use |l| after moving |args|.
template <typename... Args> template <typename... Args>
MOZ_MUST_USE bool putNew(const Lookup& l, Args&&... args) [[nodiscard]] bool putNew(const Lookup& l, Args&&... args)
{ {
if (!this->checkSimulatedOOM()) if (!this->checkSimulatedOOM())
return false; return false;
@@ -1846,7 +1846,7 @@ class HashTable : private AllocPolicy
// Note: |l| may be a reference to a piece of |u|, so this function // Note: |l| may be a reference to a piece of |u|, so this function
// must take care not to use |l| after moving |u|. // must take care not to use |l| after moving |u|.
template <typename... Args> template <typename... Args>
MOZ_MUST_USE bool relookupOrAdd(AddPtr& p, const Lookup& l, Args&&... args) [[nodiscard]] bool relookupOrAdd(AddPtr& p, const Lookup& l, Args&&... args)
{ {
// Check for error from ensureHash() here. // Check for error from ensureHash() here.
if (p.isValid()) if (p.isValid())
+1 -1
View File
@@ -1274,7 +1274,7 @@ class MutableWrappedPtrOperations<UniquePtr<T, D>, Container>
UniquePtr<T, D>& uniquePtr() { return static_cast<Container*>(this)->get(); } UniquePtr<T, D>& uniquePtr() { return static_cast<Container*>(this)->get(); }
public: public:
MOZ_MUST_USE typename UniquePtr<T, D>::Pointer release() { return uniquePtr().release(); } [[nodiscard]] typename UniquePtr<T, D>::Pointer release() { return uniquePtr().release(); }
void reset(T* ptr = T()) { uniquePtr().reset(ptr); } void reset(T* ptr = T()) { uniquePtr().reset(ptr); }
}; };
+11 -11
View File
@@ -285,7 +285,7 @@ class BaseStackFrame {
// simplifies the principals check into the boolean isSystem() state. This // simplifies the principals check into the boolean isSystem() state. This
// is fine because we only expose JS::ubi::Stack to devtools and chrome // is fine because we only expose JS::ubi::Stack to devtools and chrome
// code, and not to the web platform. // code, and not to the web platform.
virtual MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, [[nodiscard]] virtual bool constructSavedFrameStack(JSContext* cx,
MutableHandleObject outSavedFrameStack) MutableHandleObject outSavedFrameStack)
const = 0; const = 0;
@@ -416,7 +416,7 @@ class StackFrame {
StackFrame parent() const { return base()->parent(); } StackFrame parent() const { return base()->parent(); }
bool isSystem() const { return base()->isSystem(); } bool isSystem() const { return base()->isSystem(); }
bool isSelfHosted(JSContext* cx) const { return base()->isSelfHosted(cx); } bool isSelfHosted(JSContext* cx) const { return base()->isSelfHosted(cx); }
MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, [[nodiscard]] bool constructSavedFrameStack(JSContext* cx,
MutableHandleObject outSavedFrameStack) const { MutableHandleObject outSavedFrameStack) const {
return base()->constructSavedFrameStack(cx, outSavedFrameStack); return base()->constructSavedFrameStack(cx, outSavedFrameStack);
} }
@@ -449,7 +449,7 @@ class ConcreteStackFrame<void> : public BaseStackFrame {
uint64_t identifier() const override { return 0; } uint64_t identifier() const override { return 0; }
void trace(JSTracer* trc) override { } void trace(JSTracer* trc) override { }
MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, MutableHandleObject out) [[nodiscard]] bool constructSavedFrameStack(JSContext* cx, MutableHandleObject out)
const override const override
{ {
out.set(nullptr); out.set(nullptr);
@@ -465,7 +465,7 @@ class ConcreteStackFrame<void> : public BaseStackFrame {
bool isSelfHosted(JSContext* cx) const override { MOZ_CRASH("null JS::ubi::StackFrame"); } bool isSelfHosted(JSContext* cx) const override { MOZ_CRASH("null JS::ubi::StackFrame"); }
}; };
MOZ_MUST_USE JS_PUBLIC_API(bool) [[nodiscard]] JS_PUBLIC_API(bool)
ConstructSavedFrameStackSlow(JSContext* cx, ConstructSavedFrameStackSlow(JSContext* cx,
JS::ubi::StackFrame& frame, JS::ubi::StackFrame& frame,
MutableHandleObject outSavedFrameStack); MutableHandleObject outSavedFrameStack);
@@ -628,7 +628,7 @@ class JS_PUBLIC_API(Base) {
// Otherwise, place nullptr in the out parameter. Caller maintains ownership // Otherwise, place nullptr in the out parameter. Caller maintains ownership
// of the out parameter. True is returned on success, false is returned on // of the out parameter. True is returned on success, false is returned on
// OOM. // OOM.
virtual MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) [[nodiscard]] virtual bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName)
const const
{ {
outName.reset(nullptr); outName.reset(nullptr);
@@ -778,7 +778,7 @@ class Node {
JS::Zone* zone() const { return base()->zone(); } JS::Zone* zone() const { return base()->zone(); }
JSCompartment* compartment() const { return base()->compartment(); } JSCompartment* compartment() const { return base()->compartment(); }
const char* jsObjectClassName() const { return base()->jsObjectClassName(); } const char* jsObjectClassName() const { return base()->jsObjectClassName(); }
MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) const { [[nodiscard]] bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) const {
return base()->jsObjectConstructorName(cx, outName); return base()->jsObjectConstructorName(cx, outName);
} }
@@ -981,12 +981,12 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(RootList) {
RootList(JSContext* cx, Maybe<AutoCheckCannotGC>& noGC, bool wantNames = false); RootList(JSContext* cx, Maybe<AutoCheckCannotGC>& noGC, bool wantNames = false);
// Find all GC roots. // Find all GC roots.
MOZ_MUST_USE bool init(); [[nodiscard]] bool init();
// Find only GC roots in the provided set of |JSCompartment|s. // Find only GC roots in the provided set of |JSCompartment|s.
MOZ_MUST_USE bool init(CompartmentSet& debuggees); [[nodiscard]] bool init(CompartmentSet& debuggees);
// Find only GC roots in the given Debugger object's set of debuggee // Find only GC roots in the given Debugger object's set of debuggee
// compartments. // compartments.
MOZ_MUST_USE bool init(HandleObject debuggees); [[nodiscard]] bool init(HandleObject debuggees);
// Returns true if the RootList has been initialized successfully, false // Returns true if the RootList has been initialized successfully, false
// otherwise. // otherwise.
@@ -995,7 +995,7 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(RootList) {
// Explicitly add the given Node as a root in this RootList. If wantNames is // Explicitly add the given Node as a root in this RootList. If wantNames is
// true, you must pass an edgeName. The RootList does not take ownership of // true, you must pass an edgeName. The RootList does not take ownership of
// edgeName. // edgeName.
MOZ_MUST_USE bool addRoot(Node node, const char16_t* edgeName = nullptr); [[nodiscard]] bool addRoot(Node node, const char16_t* edgeName = nullptr);
}; };
@@ -1100,7 +1100,7 @@ class JS_PUBLIC_API(Concrete<JSObject>) : public TracerConcreteWithCompartment<J
} }
const char* jsObjectClassName() const override; const char* jsObjectClassName() const override;
MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) [[nodiscard]] bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName)
const override; const override;
Size size(mozilla::MallocSizeOf mallocSizeOf) const override; Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
+11 -11
View File
@@ -104,14 +104,14 @@ struct CountType {
// Implement the 'count' method for counts returned by this CountType // Implement the 'count' method for counts returned by this CountType
// instance's 'newCount' method. // instance's 'newCount' method.
virtual MOZ_MUST_USE bool count(CountBase& count, [[nodiscard]] virtual bool count(CountBase& count,
mozilla::MallocSizeOf mallocSizeOf, mozilla::MallocSizeOf mallocSizeOf,
const Node& node) = 0; const Node& node) = 0;
// Implement the 'report' method for counts returned by this CountType // Implement the 'report' method for counts returned by this CountType
// instance's 'newCount' method. // instance's 'newCount' method.
virtual MOZ_MUST_USE bool report(JSContext* cx, CountBase& count, [[nodiscard]] virtual bool report(JSContext* cx, CountBase& count,
MutableHandleValue report) = 0; MutableHandleValue report) = 0;
}; };
using CountTypePtr = js::UniquePtr<CountType>; using CountTypePtr = js::UniquePtr<CountType>;
@@ -135,7 +135,7 @@ class CountBase {
{ } { }
// Categorize and count |node| as appropriate for this count's type. // Categorize and count |node| as appropriate for this count's type.
MOZ_MUST_USE bool count(mozilla::MallocSizeOf mallocSizeOf, const Node& node) { [[nodiscard]] bool count(mozilla::MallocSizeOf mallocSizeOf, const Node& node) {
total_++; total_++;
auto id = node.identifier(); auto id = node.identifier();
@@ -158,7 +158,7 @@ class CountBase {
// Construct a JavaScript object reporting the counts recorded in this // Construct a JavaScript object reporting the counts recorded in this
// count, and store it in |report|. Return true on success, or false on // count, and store it in |report|. Return true on success, or false on
// failure. // failure.
MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) { [[nodiscard]] bool report(JSContext* cx, MutableHandleValue report) {
return type.report(cx, *this, report); return type.report(cx, *this, report);
} }
@@ -202,7 +202,7 @@ struct Census {
explicit Census(JSContext* cx) : cx(cx), atomsZone(nullptr) { } explicit Census(JSContext* cx) : cx(cx), atomsZone(nullptr) { }
MOZ_MUST_USE JS_PUBLIC_API(bool) init(); [[nodiscard]] JS_PUBLIC_API(bool) init();
}; };
// A BreadthFirst handler type that conducts a census, using a CountBase to // A BreadthFirst handler type that conducts a census, using a CountBase to
@@ -219,14 +219,14 @@ class CensusHandler {
mallocSizeOf(mallocSizeOf) mallocSizeOf(mallocSizeOf)
{ } { }
MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) { [[nodiscard]] bool report(JSContext* cx, MutableHandleValue report) {
return rootCount->report(cx, report); return rootCount->report(cx, report);
} }
// This class needs to retain no per-node data. // This class needs to retain no per-node data.
class NodeData { }; class NodeData { };
MOZ_MUST_USE JS_PUBLIC_API(bool) operator() (BreadthFirst<CensusHandler>& traversal, [[nodiscard]] JS_PUBLIC_API(bool) operator() (BreadthFirst<CensusHandler>& traversal,
Node origin, const Edge& edge, Node origin, const Edge& edge,
NodeData* referentData, bool first); NodeData* referentData, bool first);
}; };
@@ -235,7 +235,7 @@ using CensusTraversal = BreadthFirst<CensusHandler>;
// Examine the census options supplied by the API consumer, and (among other // Examine the census options supplied by the API consumer, and (among other
// things) use that to build a CountType tree. // things) use that to build a CountType tree.
MOZ_MUST_USE JS_PUBLIC_API(bool) ParseCensusOptions(JSContext* cx, [[nodiscard]] JS_PUBLIC_API(bool) ParseCensusOptions(JSContext* cx,
Census& census, HandleObject options, Census& census, HandleObject options,
CountTypePtr& outResult); CountTypePtr& outResult);
+9 -9
View File
@@ -322,9 +322,9 @@ class DominatorTree
// Do the post order traversal of the heap graph and populate our // Do the post order traversal of the heap graph and populate our
// predecessor sets. // predecessor sets.
static MOZ_MUST_USE bool doTraversal(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root, [[nodiscard]] static bool doTraversal(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root,
JS::ubi::Vector<Node>& postOrder, JS::ubi::Vector<Node>& postOrder,
PredecessorSets& predecessorSets) { PredecessorSets& predecessorSets) {
uint32_t nodeCount = 0; uint32_t nodeCount = 0;
auto onNode = [&](const Node& node) { auto onNode = [&](const Node& node) {
nodeCount++; nodeCount++;
@@ -356,8 +356,8 @@ class DominatorTree
// Populates the given `map` with an entry for each node to its index in // Populates the given `map` with an entry for each node to its index in
// `postOrder`. // `postOrder`.
static MOZ_MUST_USE bool mapNodesToTheirIndices(JS::ubi::Vector<Node>& postOrder, [[nodiscard]] static bool mapNodesToTheirIndices(JS::ubi::Vector<Node>& postOrder,
NodeToIndexMap& map) { NodeToIndexMap& map) {
MOZ_ASSERT(!map.initialized()); MOZ_ASSERT(!map.initialized());
MOZ_ASSERT(postOrder.length() < UINT32_MAX); MOZ_ASSERT(postOrder.length() < UINT32_MAX);
uint32_t length = postOrder.length(); uint32_t length = postOrder.length();
@@ -370,7 +370,7 @@ class DominatorTree
// Convert the Node -> NodeSet predecessorSets to a index -> Vector<index> // Convert the Node -> NodeSet predecessorSets to a index -> Vector<index>
// form. // form.
static MOZ_MUST_USE bool convertPredecessorSetsToVectors( [[nodiscard]] static bool convertPredecessorSetsToVectors(
const Node& root, const Node& root,
JS::ubi::Vector<Node>& postOrder, JS::ubi::Vector<Node>& postOrder,
PredecessorSets& predecessorSets, PredecessorSets& predecessorSets,
@@ -409,7 +409,7 @@ class DominatorTree
// Initialize `doms` such that the immediate dominator of the `root` is the // Initialize `doms` such that the immediate dominator of the `root` is the
// `root` itself and all others are `UNDEFINED`. // `root` itself and all others are `UNDEFINED`.
static MOZ_MUST_USE bool initializeDominators(JS::ubi::Vector<uint32_t>& doms, [[nodiscard]] static bool initializeDominators(JS::ubi::Vector<uint32_t>& doms,
uint32_t length) { uint32_t length) {
MOZ_ASSERT(doms.length() == 0); MOZ_ASSERT(doms.length() == 0);
if (!doms.growByUninitialized(length)) if (!doms.growByUninitialized(length))
@@ -426,7 +426,7 @@ class DominatorTree
MOZ_ASSERT_IF(retainedSizes.isSome(), postOrder.length() == retainedSizes->length()); MOZ_ASSERT_IF(retainedSizes.isSome(), postOrder.length() == retainedSizes->length());
} }
MOZ_MUST_USE bool computeRetainedSizes(mozilla::MallocSizeOf mallocSizeOf) { [[nodiscard]] bool computeRetainedSizes(mozilla::MallocSizeOf mallocSizeOf) {
MOZ_ASSERT(retainedSizes.isNothing()); MOZ_ASSERT(retainedSizes.isNothing());
auto length = postOrder.length(); auto length = postOrder.length();
@@ -651,7 +651,7 @@ class DominatorTree
* `outSize`, or 0 if `node` is not a member of the dominator tree. Returns * `outSize`, or 0 if `node` is not a member of the dominator tree. Returns
* false on OOM failure, leaving `outSize` unchanged. * false on OOM failure, leaving `outSize` unchanged.
*/ */
MOZ_MUST_USE bool getRetainedSize(const Node& node, mozilla::MallocSizeOf mallocSizeOf, [[nodiscard]] bool getRetainedSize(const Node& node, mozilla::MallocSizeOf mallocSizeOf,
Node::Size& outSize) { Node::Size& outSize) {
assertSanity(); assertSanity();
auto ptr = nodeToPostOrderIndex.lookup(node); auto ptr = nodeToPostOrderIndex.lookup(node);
+5 -5
View File
@@ -90,7 +90,7 @@ struct PostOrder {
#endif #endif
private: private:
MOZ_MUST_USE bool fillEdgesFromRange(EdgeVector& edges, js::UniquePtr<EdgeRange>& range) { [[nodiscard]] bool fillEdgesFromRange(EdgeVector& edges, js::UniquePtr<EdgeRange>& range) {
MOZ_ASSERT(range); MOZ_ASSERT(range);
for ( ; !range->empty(); range->popFront()) { for ( ; !range->empty(); range->popFront()) {
if (!edges.append(mozilla::Move(range->front()))) if (!edges.append(mozilla::Move(range->front())))
@@ -99,7 +99,7 @@ struct PostOrder {
return true; return true;
} }
MOZ_MUST_USE bool pushForTraversing(const Node& node) { [[nodiscard]] bool pushForTraversing(const Node& node) {
EdgeVector edges; EdgeVector edges;
auto range = node.edges(cx, /* wantNames */ false); auto range = node.edges(cx, /* wantNames */ false);
return range && return range &&
@@ -124,11 +124,11 @@ struct PostOrder {
{ } { }
// Initialize this traversal object. Return false on OOM. // Initialize this traversal object. Return false on OOM.
MOZ_MUST_USE bool init() { return seen.init(); } [[nodiscard]] bool init() { return seen.init(); }
// Add `node` as a starting point for the traversal. You may add // Add `node` as a starting point for the traversal. You may add
// as many starting points as you like. Returns false on OOM. // as many starting points as you like. Returns false on OOM.
MOZ_MUST_USE bool addStart(const Node& node) { [[nodiscard]] bool addStart(const Node& node) {
if (!seen.put(node)) if (!seen.put(node))
return false; return false;
return pushForTraversing(node); return pushForTraversing(node);
@@ -144,7 +144,7 @@ struct PostOrder {
// Return false on OOM or error return from `onNode::operator()` or // Return false on OOM or error return from `onNode::operator()` or
// `onEdge::operator()`. // `onEdge::operator()`.
template<typename NodeVisitor, typename EdgeVisitor> template<typename NodeVisitor, typename EdgeVisitor>
MOZ_MUST_USE bool traverse(NodeVisitor onNode, EdgeVisitor onEdge) { [[nodiscard]] bool traverse(NodeVisitor onNode, EdgeVisitor onEdge) {
#ifdef DEBUG #ifdef DEBUG
MOZ_ASSERT(!traversed, "Can only traverse() once!"); MOZ_ASSERT(!traversed, "Can only traverse() once!");
traversed = true; traversed = true;
+2 -2
View File
@@ -32,7 +32,7 @@ struct JS_PUBLIC_API(BackEdge)
BackEdge() : predecessor_(), name_(nullptr) { } BackEdge() : predecessor_(), name_(nullptr) { }
MOZ_MUST_USE bool init(const Node& predecessor, Edge& edge) { [[nodiscard]] bool init(const Node& predecessor, Edge& edge) {
MOZ_ASSERT(!predecessor_); MOZ_ASSERT(!predecessor_);
MOZ_ASSERT(!name_); MOZ_ASSERT(!name_);
@@ -289,7 +289,7 @@ struct JS_PUBLIC_API(ShortestPaths)
* the given target, in which case `func` will not be invoked. * the given target, in which case `func` will not be invoked.
*/ */
template <class Func> template <class Func>
MOZ_MUST_USE bool forEachPath(const Node& target, Func func) { [[nodiscard]] bool forEachPath(const Node& target, Func func) {
MOZ_ASSERT(initialized()); MOZ_ASSERT(initialized());
MOZ_ASSERT(targets_.has(target)); MOZ_ASSERT(targets_.has(target));
+2 -2
View File
@@ -352,7 +352,7 @@ namespace js {
* instances of type |T|. Return false if the calculation overflowed. * instances of type |T|. Return false if the calculation overflowed.
*/ */
template <typename T> template <typename T>
MOZ_MUST_USE inline bool [[nodiscard]] inline bool
CalculateAllocSize(size_t numElems, size_t* bytesOut) CalculateAllocSize(size_t numElems, size_t* bytesOut)
{ {
*bytesOut = numElems * sizeof(T); *bytesOut = numElems * sizeof(T);
@@ -365,7 +365,7 @@ CalculateAllocSize(size_t numElems, size_t* bytesOut)
* false if the calculation overflowed. * false if the calculation overflowed.
*/ */
template <typename T, typename Extra> template <typename T, typename Extra>
MOZ_MUST_USE inline bool [[nodiscard]] inline bool
CalculateAllocSizeWithExtra(size_t numExtra, size_t* bytesOut) CalculateAllocSizeWithExtra(size_t numExtra, size_t* bytesOut)
{ {
*bytesOut = sizeof(T) + numExtra * sizeof(Extra); *bytesOut = sizeof(T) + numExtra * sizeof(Extra);
+17 -17
View File
@@ -21,21 +21,21 @@ class AtomicsObject : public JSObject
public: public:
static const Class class_; static const Class class_;
static JSObject* initClass(JSContext* cx, Handle<GlobalObject*> global); static JSObject* initClass(JSContext* cx, Handle<GlobalObject*> global);
static MOZ_MUST_USE bool toString(JSContext* cx, unsigned int argc, Value* vp); [[nodiscard]] static bool toString(JSContext* cx, unsigned int argc, Value* vp);
}; };
MOZ_MUST_USE bool atomics_compareExchange(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_compareExchange(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_exchange(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_exchange(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_load(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_load(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_store(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_store(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_add(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_add(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_sub(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_sub(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_and(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_and(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_or(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_or(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_xor(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_xor(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_isLockFree(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_isLockFree(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_wait(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_wait(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool atomics_notify(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool atomics_notify(JSContext* cx, unsigned argc, Value* vp);
/* asm.js callouts */ /* asm.js callouts */
namespace wasm { class Instance; } namespace wasm { class Instance; }
@@ -52,14 +52,14 @@ class FutexRuntime
friend class AutoLockFutexAPI; friend class AutoLockFutexAPI;
public: public:
static MOZ_MUST_USE bool initialize(); [[nodiscard]] static bool initialize();
static void destroy(); static void destroy();
static void lock(); static void lock();
static void unlock(); static void unlock();
FutexRuntime(); FutexRuntime();
MOZ_MUST_USE bool initInstance(); [[nodiscard]] bool initInstance();
void destroyInstance(); void destroyInstance();
// Parameters to notify(). // Parameters to notify().
@@ -83,8 +83,8 @@ public:
// wait. // wait.
// //
// wait() will not wake up spuriously. // wait() will not wake up spuriously.
MOZ_MUST_USE bool wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked, [[nodiscard]] bool wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked,
mozilla::Maybe<mozilla::TimeDuration>& timeout, WaitResult* result); mozilla::Maybe<mozilla::TimeDuration>& timeout, WaitResult* result);
// Notify the thread represented by this Runtime. // Notify the thread represented by this Runtime.
// //
+3 -3
View File
@@ -16,17 +16,17 @@ namespace js {
// JSOP_EVAL which in turn calls DirectEval. Thus, even though IndirectEval is // JSOP_EVAL which in turn calls DirectEval. Thus, even though IndirectEval is
// the callee function object for *all* calls to eval, it is by construction // the callee function object for *all* calls to eval, it is by construction
// only ever called in the case indirect eval. // only ever called in the case indirect eval.
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
IndirectEval(JSContext* cx, unsigned argc, Value* vp); IndirectEval(JSContext* cx, unsigned argc, Value* vp);
// Performs a direct eval of |v| (a string containing code, or another value // Performs a direct eval of |v| (a string containing code, or another value
// that will be vacuously returned), which must correspond to the currently- // that will be vacuously returned), which must correspond to the currently-
// executing stack frame, which must be a script frame. // executing stack frame, which must be a script frame.
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
DirectEval(JSContext* cx, HandleValue v, MutableHandleValue vp); DirectEval(JSContext* cx, HandleValue v, MutableHandleValue vp);
// Performs a direct eval called from Ion code. // Performs a direct eval called from Ion code.
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
DirectEvalStringFromIon(JSContext* cx, DirectEvalStringFromIon(JSContext* cx,
HandleObject scopeObj, HandleScript callerScript, HandleObject scopeObj, HandleScript callerScript,
HandleValue newTargetValue, HandleString str, HandleValue newTargetValue, HandleString str,
+3 -3
View File
@@ -476,7 +476,7 @@ class js::OrderedHashTableRef : public gc::BufferableRef
}; };
template <typename ObjectT> template <typename ObjectT>
inline static MOZ_MUST_USE bool [[nodiscard]] inline static bool
WriteBarrierPostImpl(JSRuntime* rt, ObjectT* obj, const Value& keyValue) WriteBarrierPostImpl(JSRuntime* rt, ObjectT* obj, const Value& keyValue)
{ {
if (MOZ_LIKELY(!keyValue.isObject())) if (MOZ_LIKELY(!keyValue.isObject()))
@@ -501,13 +501,13 @@ WriteBarrierPostImpl(JSRuntime* rt, ObjectT* obj, const Value& keyValue)
return true; return true;
} }
inline static MOZ_MUST_USE bool [[nodiscard]] inline static bool
WriteBarrierPost(JSRuntime* rt, MapObject* map, const Value& key) WriteBarrierPost(JSRuntime* rt, MapObject* map, const Value& key)
{ {
return WriteBarrierPostImpl(rt, map, key); return WriteBarrierPostImpl(rt, map, key);
} }
inline static MOZ_MUST_USE bool [[nodiscard]] inline static bool
WriteBarrierPost(JSRuntime* rt, SetObject* set, const Value& key) WriteBarrierPost(JSRuntime* rt, SetObject* set, const Value& key)
{ {
return WriteBarrierPostImpl(rt, set, key); return WriteBarrierPostImpl(rt, set, key);
+53 -53
View File
@@ -41,7 +41,7 @@ class HashableValue
HashableValue() : value(UndefinedValue()) {} HashableValue() : value(UndefinedValue()) {}
MOZ_MUST_USE bool setValue(JSContext* cx, HandleValue v); [[nodiscard]] bool setValue(JSContext* cx, HandleValue v);
HashNumber hash(const mozilla::HashCodeScrambler& hcs) const; HashNumber hash(const mozilla::HashCodeScrambler& hcs) const;
bool operator==(const HashableValue& other) const; bool operator==(const HashableValue& other) const;
HashableValue mark(JSTracer* trc) const; HashableValue mark(JSTracer* trc) const;
@@ -66,7 +66,7 @@ class MutableWrappedPtrOperations<HashableValue, Wrapper>
: public WrappedPtrOperations<HashableValue, Wrapper> : public WrappedPtrOperations<HashableValue, Wrapper>
{ {
public: public:
MOZ_MUST_USE bool setValue(JSContext* cx, HandleValue v) { [[nodiscard]] bool setValue(JSContext* cx, HandleValue v) {
return static_cast<Wrapper*>(this)->get().setValue(cx, v); return static_cast<Wrapper*>(this)->get().setValue(cx, v);
} }
}; };
@@ -107,26 +107,26 @@ class MapObject : public NativeObject {
enum { NurseryKeysSlot, SlotCount }; enum { NurseryKeysSlot, SlotCount };
static MOZ_MUST_USE bool getKeysAndValuesInterleaved(JSContext* cx, HandleObject obj, [[nodiscard]] static bool getKeysAndValuesInterleaved(JSContext* cx, HandleObject obj,
JS::MutableHandle<GCVector<JS::Value>> entries); JS::MutableHandle<GCVector<JS::Value>> entries);
static MOZ_MUST_USE bool entries(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool entries(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool has(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool has(JSContext* cx, unsigned argc, Value* vp);
static MapObject* create(JSContext* cx, HandleObject proto = nullptr); static MapObject* create(JSContext* cx, HandleObject proto = nullptr);
// Publicly exposed Map calls for JSAPI access (webidl maplike/setlike // Publicly exposed Map calls for JSAPI access (webidl maplike/setlike
// interfaces, etc.) // interfaces, etc.)
static uint32_t size(JSContext *cx, HandleObject obj); static uint32_t size(JSContext *cx, HandleObject obj);
static MOZ_MUST_USE bool get(JSContext *cx, HandleObject obj, HandleValue key, [[nodiscard]] static bool get(JSContext *cx, HandleObject obj, HandleValue key,
MutableHandleValue rval); MutableHandleValue rval);
static MOZ_MUST_USE bool has(JSContext *cx, HandleObject obj, HandleValue key, bool* rval); [[nodiscard]] static bool has(JSContext *cx, HandleObject obj, HandleValue key, bool* rval);
static MOZ_MUST_USE bool delete_(JSContext *cx, HandleObject obj, HandleValue key, bool* rval); [[nodiscard]] static bool delete_(JSContext *cx, HandleObject obj, HandleValue key, bool* rval);
// Set call for public JSAPI exposure. Does not actually return map object // Set call for public JSAPI exposure. Does not actually return map object
// as stated in spec, expects caller to return a value. for instance, with // as stated in spec, expects caller to return a value. for instance, with
// webidl maplike/setlike, should return interface object. // webidl maplike/setlike, should return interface object.
static MOZ_MUST_USE bool set(JSContext *cx, HandleObject obj, HandleValue key, HandleValue val); [[nodiscard]] static bool set(JSContext *cx, HandleObject obj, HandleValue key, HandleValue val);
static MOZ_MUST_USE bool clear(JSContext *cx, HandleObject obj); [[nodiscard]] static bool clear(JSContext *cx, HandleObject obj);
static MOZ_MUST_USE bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj, [[nodiscard]] static bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj,
MutableHandleValue iter); MutableHandleValue iter);
using UnbarrieredTable = OrderedHashMap<Value, Value, UnbarrieredHashPolicy, RuntimeAllocPolicy>; using UnbarrieredTable = OrderedHashMap<Value, Value, UnbarrieredHashPolicy, RuntimeAllocPolicy>;
@@ -143,29 +143,29 @@ class MapObject : public NativeObject {
static ValueMap& extract(const CallArgs& args); static ValueMap& extract(const CallArgs& args);
static void mark(JSTracer* trc, JSObject* obj); static void mark(JSTracer* trc, JSObject* obj);
static void finalize(FreeOp* fop, JSObject* obj); static void finalize(FreeOp* fop, JSObject* obj);
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
static bool is(HandleValue v); static bool is(HandleValue v);
static bool is(HandleObject o); static bool is(HandleObject o);
static MOZ_MUST_USE bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind); [[nodiscard]] static bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind);
static MOZ_MUST_USE bool size_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool size_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool size(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool size(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool get_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool get_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool get(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool get(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool has_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool has_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool set_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool set_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool set(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool set(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool delete_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool delete_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool delete_(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool delete_(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool keys_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool keys_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool keys(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool keys(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool values_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool values_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool values(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool values(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool entries_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool entries_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool clear_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool clear_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool clear(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool clear(JSContext* cx, unsigned argc, Value* vp);
}; };
class MapIteratorObject : public NativeObject class MapIteratorObject : public NativeObject
@@ -187,7 +187,7 @@ class MapIteratorObject : public NativeObject
MapObject::IteratorKind kind); MapObject::IteratorKind kind);
static void finalize(FreeOp* fop, JSObject* obj); static void finalize(FreeOp* fop, JSObject* obj);
static MOZ_MUST_USE bool next(Handle<MapIteratorObject*> mapIterator, [[nodiscard]] static bool next(Handle<MapIteratorObject*> mapIterator,
HandleArrayObject resultPairObj, JSContext* cx); HandleArrayObject resultPairObj, JSContext* cx);
static JSObject* createResultPair(JSContext* cx); static JSObject* createResultPair(JSContext* cx);
@@ -213,21 +213,21 @@ class SetObject : public NativeObject {
enum { NurseryKeysSlot, SlotCount }; enum { NurseryKeysSlot, SlotCount };
static MOZ_MUST_USE bool keys(JSContext *cx, HandleObject obj, [[nodiscard]] static bool keys(JSContext *cx, HandleObject obj,
JS::MutableHandle<GCVector<JS::Value>> keys); JS::MutableHandle<GCVector<JS::Value>> keys);
static MOZ_MUST_USE bool values(JSContext *cx, unsigned argc, Value *vp); [[nodiscard]] static bool values(JSContext *cx, unsigned argc, Value *vp);
static MOZ_MUST_USE bool add(JSContext *cx, HandleObject obj, HandleValue key); [[nodiscard]] static bool add(JSContext *cx, HandleObject obj, HandleValue key);
static MOZ_MUST_USE bool has(JSContext *cx, unsigned argc, Value *vp); [[nodiscard]] static bool has(JSContext *cx, unsigned argc, Value *vp);
// Publicly exposed Set calls for JSAPI access (webidl maplike/setlike // Publicly exposed Set calls for JSAPI access (webidl maplike/setlike
// interfaces, etc.) // interfaces, etc.)
static SetObject* create(JSContext *cx, HandleObject proto = nullptr); static SetObject* create(JSContext *cx, HandleObject proto = nullptr);
static uint32_t size(JSContext *cx, HandleObject obj); static uint32_t size(JSContext *cx, HandleObject obj);
static MOZ_MUST_USE bool has(JSContext *cx, HandleObject obj, HandleValue key, bool* rval); [[nodiscard]] static bool has(JSContext *cx, HandleObject obj, HandleValue key, bool* rval);
static MOZ_MUST_USE bool clear(JSContext *cx, HandleObject obj); [[nodiscard]] static bool clear(JSContext *cx, HandleObject obj);
static MOZ_MUST_USE bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj, [[nodiscard]] static bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj,
MutableHandleValue iter); MutableHandleValue iter);
static MOZ_MUST_USE bool delete_(JSContext *cx, HandleObject obj, HandleValue key, bool *rval); [[nodiscard]] static bool delete_(JSContext *cx, HandleObject obj, HandleValue key, bool *rval);
using UnbarrieredTable = OrderedHashSet<Value, UnbarrieredHashPolicy, RuntimeAllocPolicy>; using UnbarrieredTable = OrderedHashSet<Value, UnbarrieredHashPolicy, RuntimeAllocPolicy>;
friend class OrderedHashTableRef<SetObject>; friend class OrderedHashTableRef<SetObject>;
@@ -251,20 +251,20 @@ class SetObject : public NativeObject {
static bool isBuiltinAdd(HandleValue add, JSContext* cx); static bool isBuiltinAdd(HandleValue add, JSContext* cx);
static MOZ_MUST_USE bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind); [[nodiscard]] static bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind);
static MOZ_MUST_USE bool size_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool size_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool size(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool size(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool has_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool has_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool add_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool add_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool add(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool add(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool delete_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool delete_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool delete_(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool delete_(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool values_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool values_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool entries_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool entries_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool entries(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool entries(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool clear_impl(JSContext* cx, const CallArgs& args); [[nodiscard]] static bool clear_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool clear(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool clear(JSContext* cx, unsigned argc, Value* vp);
}; };
class SetIteratorObject : public NativeObject class SetIteratorObject : public NativeObject
@@ -286,7 +286,7 @@ class SetIteratorObject : public NativeObject
SetObject::IteratorKind kind); SetObject::IteratorKind kind);
static void finalize(FreeOp* fop, JSObject* obj); static void finalize(FreeOp* fop, JSObject* obj);
static MOZ_MUST_USE bool next(Handle<SetIteratorObject*> setIterator, [[nodiscard]] static bool next(Handle<SetIteratorObject*> setIterator,
HandleArrayObject resultObj, JSContext* cx); HandleArrayObject resultObj, JSContext* cx);
static JSObject* createResult(JSContext* cx); static JSObject* createResult(JSContext* cx);
@@ -299,7 +299,7 @@ using SetInitGetPrototypeOp = NativeObject* (*)(JSContext*, Handle<GlobalObject*
using SetInitIsBuiltinOp = bool (*)(HandleValue, JSContext*); using SetInitIsBuiltinOp = bool (*)(HandleValue, JSContext*);
template <SetInitGetPrototypeOp getPrototypeOp, SetInitIsBuiltinOp isBuiltinOp> template <SetInitGetPrototypeOp getPrototypeOp, SetInitIsBuiltinOp isBuiltinOp>
static MOZ_MUST_USE bool [[nodiscard]] static bool
IsOptimizableInitForSet(JSContext* cx, HandleObject setObject, HandleValue iterable, bool* optimized) IsOptimizableInitForSet(JSContext* cx, HandleObject setObject, HandleValue iterable, bool* optimized)
{ {
MOZ_ASSERT(!*optimized); MOZ_ASSERT(!*optimized);
+13 -13
View File
@@ -18,10 +18,10 @@ class Value;
namespace js { namespace js {
// Object constructor native. Exposed only so the JIT can know its address. // Object constructor native. Exposed only so the JIT can know its address.
MOZ_MUST_USE bool [[nodiscard]] bool
obj_construct(JSContext* cx, unsigned argc, JS::Value* vp); obj_construct(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_propertyIsEnumerable(JSContext* cx, unsigned argc, Value* vp); obj_propertyIsEnumerable(JSContext* cx, unsigned argc, Value* vp);
PlainObject* PlainObject*
@@ -32,32 +32,32 @@ PlainObject*
ObjectCreateWithTemplate(JSContext* cx, HandlePlainObject templateObj); ObjectCreateWithTemplate(JSContext* cx, HandlePlainObject templateObj);
// Object methods exposed so they can be installed in the self-hosting global. // Object methods exposed so they can be installed in the self-hosting global.
MOZ_MUST_USE bool [[nodiscard]] bool
obj_create(JSContext* cx, unsigned argc, JS::Value* vp); obj_create(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_defineProperty(JSContext* cx, unsigned argc, JS::Value* vp); obj_defineProperty(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_getOwnPropertyNames(JSContext* cx, unsigned argc, JS::Value* vp); obj_getOwnPropertyNames(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_getOwnPropertyDescriptor(JSContext* cx, unsigned argc, JS::Value* vp); obj_getOwnPropertyDescriptor(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_getPrototypeOf(JSContext* cx, unsigned argc, JS::Value* vp); obj_getPrototypeOf(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_hasOwnProperty(JSContext* cx, unsigned argc, JS::Value* vp); obj_hasOwnProperty(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_isExtensible(JSContext* cx, unsigned argc, JS::Value* vp); obj_isExtensible(JSContext* cx, unsigned argc, JS::Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
obj_toString(JSContext* cx, unsigned argc, JS::Value* vp); obj_toString(JSContext* cx, unsigned argc, JS::Value* vp);
// Exposed so SelfHosting.cpp can use it in the OwnPropertyKeys intrinsic // Exposed so SelfHosting.cpp can use it in the OwnPropertyKeys intrinsic
MOZ_MUST_USE bool [[nodiscard]] bool
GetOwnPropertyKeys(JSContext* cx, const JS::CallArgs& args, unsigned flags); GetOwnPropertyKeys(JSContext* cx, const JS::CallArgs& args, unsigned flags);
/* /*
@@ -65,7 +65,7 @@ GetOwnPropertyKeys(JSContext* cx, const JS::CallArgs& args, unsigned flags);
* exposing a jsid to script for Object.getOwnProperty{Names,Symbols} * exposing a jsid to script for Object.getOwnProperty{Names,Symbols}
* or scriptable proxy traps. * or scriptable proxy traps.
*/ */
MOZ_MUST_USE bool [[nodiscard]] bool
IdToStringOrSymbol(JSContext* cx, JS::HandleId id, JS::MutableHandleValue result); IdToStringOrSymbol(JSContext* cx, JS::HandleId id, JS::MutableHandleValue result);
#if JS_HAS_TOSOURCE #if JS_HAS_TOSOURCE
@@ -74,7 +74,7 @@ JSString*
ObjectToSource(JSContext* cx, JS::HandleObject obj); ObjectToSource(JSContext* cx, JS::HandleObject obj);
#endif // JS_HAS_TOSOURCE #endif // JS_HAS_TOSOURCE
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
WatchHandler(JSContext* cx, JSObject* obj, jsid id, const JS::Value& old, WatchHandler(JSContext* cx, JSObject* obj, jsid id, const JS::Value& old,
JS::Value* nvp, void* closure); JS::Value* nvp, void* closure);
+10 -10
View File
@@ -29,21 +29,21 @@ typedef int pid_t;
* *
* Returns true if no profilers fail to start. * Returns true if no profilers fail to start.
*/ */
extern MOZ_MUST_USE JS_PUBLIC_API(bool) [[nodiscard]] extern JS_PUBLIC_API(bool)
JS_StartProfiling(const char* profileName, pid_t pid); JS_StartProfiling(const char* profileName, pid_t pid);
/** /**
* Stop any profilers that were previously started with JS_StartProfiling. * Stop any profilers that were previously started with JS_StartProfiling.
* Returns true if no profilers fail to stop. * Returns true if no profilers fail to stop.
*/ */
extern MOZ_MUST_USE JS_PUBLIC_API(bool) [[nodiscard]] extern JS_PUBLIC_API(bool)
JS_StopProfiling(const char* profileName); JS_StopProfiling(const char* profileName);
/** /**
* Write the current profile data to the given file, if applicable to whatever * Write the current profile data to the given file, if applicable to whatever
* profiler is being used. * profiler is being used.
*/ */
extern MOZ_MUST_USE JS_PUBLIC_API(bool) [[nodiscard]] extern JS_PUBLIC_API(bool)
JS_DumpProfile(const char* outfile, const char* profileName); JS_DumpProfile(const char* outfile, const char* profileName);
/** /**
@@ -51,13 +51,13 @@ JS_DumpProfile(const char* outfile, const char* profileName);
* whether any profilers failed to pause. (Profilers that do not support * whether any profilers failed to pause. (Profilers that do not support
* pause/resume do not count.) * pause/resume do not count.)
*/ */
extern MOZ_MUST_USE JS_PUBLIC_API(bool) [[nodiscard]] extern JS_PUBLIC_API(bool)
JS_PauseProfilers(const char* profileName); JS_PauseProfilers(const char* profileName);
/** /**
* Resume suspended profilers * Resume suspended profilers
*/ */
extern MOZ_MUST_USE JS_PUBLIC_API(bool) [[nodiscard]] extern JS_PUBLIC_API(bool)
JS_ResumeProfilers(const char* profileName); JS_ResumeProfilers(const char* profileName);
/** /**
@@ -70,23 +70,23 @@ JS_UnsafeGetLastProfilingError();
#ifdef MOZ_CALLGRIND #ifdef MOZ_CALLGRIND
extern MOZ_MUST_USE JS_FRIEND_API(bool) [[nodiscard]] extern JS_FRIEND_API(bool)
js_StopCallgrind(); js_StopCallgrind();
extern MOZ_MUST_USE JS_FRIEND_API(bool) [[nodiscard]] extern JS_FRIEND_API(bool)
js_StartCallgrind(); js_StartCallgrind();
extern MOZ_MUST_USE JS_FRIEND_API(bool) [[nodiscard]] extern JS_FRIEND_API(bool)
js_DumpCallgrind(const char* outfile); js_DumpCallgrind(const char* outfile);
#endif /* MOZ_CALLGRIND */ #endif /* MOZ_CALLGRIND */
#ifdef __linux__ #ifdef __linux__
extern MOZ_MUST_USE JS_FRIEND_API(bool) [[nodiscard]] extern JS_FRIEND_API(bool)
js_StartPerf(); js_StartPerf();
extern MOZ_MUST_USE JS_FRIEND_API(bool) [[nodiscard]] extern JS_FRIEND_API(bool)
js_StopPerf(); js_StopPerf();
#endif /* __linux__ */ #endif /* __linux__ */
+69 -69
View File
@@ -311,7 +311,7 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
elements().setElementNeedsWrapping = needsWrapping; elements().setElementNeedsWrapping = needsWrapping;
} }
MOZ_MUST_USE bool pushUndefined(JSContext* cx) { [[nodiscard]] bool pushUndefined(JSContext* cx) {
// Helper for the AutoCompartment we need to work with |array|. We mostly do this // Helper for the AutoCompartment we need to work with |array|. We mostly do this
// for performance; we could go ahead and do the define via a cross- // for performance; we could go ahead and do the define via a cross-
// compartment proxy instead... // compartment proxy instead...
@@ -335,7 +335,7 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
// Promise.all/allSettled/any function, which isn't necessarily the same // Promise.all/allSettled/any function, which isn't necessarily the same
// compartment as unwrappedArray as explained in NewPromiseCombinatorElements. // compartment as unwrappedArray as explained in NewPromiseCombinatorElements.
// So before storing |val| we may need to enter unwrappedArray's compartment. // So before storing |val| we may need to enter unwrappedArray's compartment.
MOZ_MUST_USE bool setElement(JSContext* cx, uint32_t index, HandleValue val) { [[nodiscard]] bool setElement(JSContext* cx, uint32_t index, HandleValue val) {
// The index is guaranteed to be initialized to `undefined`. // The index is guaranteed to be initialized to `undefined`.
MOZ_ASSERT(unwrappedArray()->getDenseElement(index).isUndefined()); MOZ_ASSERT(unwrappedArray()->getDenseElement(index).isUndefined());
@@ -560,7 +560,7 @@ MaybeGetAndClearException(JSContext* cx, MutableHandleValue rval)
return GetAndClearException(cx, rval); return GetAndClearException(cx, rval);
} }
static MOZ_MUST_USE bool RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, [[nodiscard]] static bool RunResolutionFunction(JSContext *cx, HandleObject resolutionFun,
HandleValue result, ResolutionMode mode, HandleValue result, ResolutionMode mode,
HandleObject promiseObj); HandleObject promiseObj);
@@ -778,7 +778,7 @@ static bool ResolvePromiseFunction(JSContext* cx, unsigned argc, Value* vp);
static bool RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp); static bool RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp);
// ES2016, 25.4.1.3. // ES2016, 25.4.1.3.
static MOZ_MUST_USE bool [[nodiscard]] static bool
CreateResolvingFunctions(JSContext* cx, HandleObject promise, CreateResolvingFunctions(JSContext* cx, HandleObject promise,
MutableHandleObject resolveFn, MutableHandleObject resolveFn,
MutableHandleObject rejectFn) MutableHandleObject rejectFn)
@@ -823,11 +823,11 @@ IsSettledMaybeWrappedPromise(JSObject* promise)
} }
// ES2016, 25.4.1.7. // ES2016, 25.4.1.7.
static MOZ_MUST_USE bool [[nodiscard]] static bool
RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason); RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason);
// ES2016, 25.4.1.7. // ES2016, 25.4.1.7.
static MOZ_MUST_USE bool [[nodiscard]] static bool
RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason); RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason);
// ES2016, 25.4.1.3.1. // ES2016, 25.4.1.3.1.
@@ -874,15 +874,15 @@ RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp)
return true; return true;
} }
static MOZ_MUST_USE bool FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, [[nodiscard]] static bool FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj,
HandleValue value_); HandleValue value_);
static MOZ_MUST_USE bool EnqueuePromiseResolveThenableJob(JSContext* cx, [[nodiscard]] static bool EnqueuePromiseResolveThenableJob(JSContext* cx,
HandleValue promiseToResolve, HandleValue promiseToResolve,
HandleValue thenable, HandleValue thenable,
HandleValue thenVal); HandleValue thenVal);
static MOZ_MUST_USE bool EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, [[nodiscard]] static bool EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx,
HandleObject promiseToResolve, HandleObject promiseToResolve,
HandleObject thenable); HandleObject thenable);
@@ -891,7 +891,7 @@ static bool Promise_then_impl(JSContext* cx, HandleValue promiseVal, HandleValue
HandleValue onRejected, MutableHandleValue rval, bool rvalUsed); HandleValue onRejected, MutableHandleValue rval, bool rvalUsed);
// ES2016, 25.4.1.3.2, steps 6-13. // ES2016, 25.4.1.3.2, steps 6-13.
static MOZ_MUST_USE bool [[nodiscard]] static bool
ResolvePromiseInternal(JSContext* cx, HandleObject promise, HandleValue resolutionVal) ResolvePromiseInternal(JSContext* cx, HandleObject promise, HandleValue resolutionVal)
{ {
assertSameCompartment(cx, promise, resolutionVal); assertSameCompartment(cx, promise, resolutionVal);
@@ -1024,7 +1024,7 @@ static bool PromiseReactionJob(JSContext* cx, unsigned argc, Value* vp);
* targetState - The PromiseState this reaction job targets. This decides * targetState - The PromiseState this reaction job targets. This decides
* whether the onFulfilled or onRejected handler is called. * whether the onFulfilled or onRejected handler is called.
*/ */
MOZ_MUST_USE static bool [[nodiscard]] static bool
EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj, EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj,
HandleValue handlerArg_, JS::PromiseState targetState) HandleValue handlerArg_, JS::PromiseState targetState)
{ {
@@ -1130,11 +1130,11 @@ EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj,
return cx->runtime()->enqueuePromiseJob(cx, job, promise, global); return cx->runtime()->enqueuePromiseJob(cx, job, promise, global);
} }
static MOZ_MUST_USE bool TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, [[nodiscard]] static bool TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal,
JS::PromiseState state, HandleValue valueOrReason); JS::PromiseState state, HandleValue valueOrReason);
// ES2016, Commoned-out implementation of 25.4.1.4. and 25.4.1.7. // ES2016, Commoned-out implementation of 25.4.1.4. and 25.4.1.7.
static MOZ_MUST_USE bool [[nodiscard]] static bool
ResolvePromise(JSContext* cx, Handle<PromiseObject*> promise, HandleValue valueOrReason, ResolvePromise(JSContext* cx, Handle<PromiseObject*> promise, HandleValue valueOrReason,
JS::PromiseState state) JS::PromiseState state)
{ {
@@ -1177,14 +1177,14 @@ ResolvePromise(JSContext* cx, Handle<PromiseObject*> promise, HandleValue valueO
} }
// ES2016, 25.4.1.7. // ES2016, 25.4.1.7.
static MOZ_MUST_USE bool [[nodiscard]] static bool
RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason) RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason)
{ {
return ResolvePromise(cx, promise, reason, JS::PromiseState::Rejected); return ResolvePromise(cx, promise, reason, JS::PromiseState::Rejected);
} }
// ES2016, 25.4.1.4. // ES2016, 25.4.1.4.
static MOZ_MUST_USE bool [[nodiscard]] static bool
FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue value_) FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue value_)
{ {
Rooted<PromiseObject*> promise(cx); Rooted<PromiseObject*> promise(cx);
@@ -1210,7 +1210,7 @@ FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue v
static bool GetCapabilitiesExecutor(JSContext* cx, unsigned argc, Value* vp); static bool GetCapabilitiesExecutor(JSContext* cx, unsigned argc, Value* vp);
static bool PromiseConstructor(JSContext* cx, unsigned argc, Value* vp); static bool PromiseConstructor(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE PromiseObject* CreatePromiseObjectInternal(JSContext* cx, [[nodiscard]] static PromiseObject* CreatePromiseObjectInternal(JSContext* cx,
HandleObject proto = nullptr, HandleObject proto = nullptr,
bool protoIsWrapped = false, bool protoIsWrapped = false,
bool informDebugger = true); bool informDebugger = true);
@@ -1220,7 +1220,7 @@ enum GetCapabilitiesExecutorSlots {
GetCapabilitiesExecutorSlots_Reject GetCapabilitiesExecutorSlots_Reject
}; };
static MOZ_MUST_USE PromiseObject* [[nodiscard]] static PromiseObject*
CreatePromiseObjectWithoutResolutionFunctions(JSContext* cx) CreatePromiseObjectWithoutResolutionFunctions(JSContext* cx)
{ {
Rooted<PromiseObject*> promise(cx, CreatePromiseObjectInternal(cx)); Rooted<PromiseObject*> promise(cx, CreatePromiseObjectInternal(cx));
@@ -1231,7 +1231,7 @@ CreatePromiseObjectWithoutResolutionFunctions(JSContext* cx)
return promise; return promise;
} }
static MOZ_MUST_USE PromiseObject* [[nodiscard]] static PromiseObject*
CreatePromiseWithDefaultResolutionFunctions(JSContext* cx, MutableHandleObject resolve, CreatePromiseWithDefaultResolutionFunctions(JSContext* cx, MutableHandleObject resolve,
MutableHandleObject reject) MutableHandleObject reject)
{ {
@@ -1258,7 +1258,7 @@ CreatePromiseWithDefaultResolutionFunctions(JSContext* cx, MutableHandleObject r
} }
// ES2016, 25.4.1.5. // ES2016, 25.4.1.5.
static MOZ_MUST_USE bool [[nodiscard]] static bool
NewPromiseCapability(JSContext* cx, HandleObject C, MutableHandle<PromiseCapability> capability, NewPromiseCapability(JSContext* cx, HandleObject C, MutableHandle<PromiseCapability> capability,
bool canOmitResolutionFunctions) bool canOmitResolutionFunctions)
{ {
@@ -1369,7 +1369,7 @@ GetCapabilitiesExecutor(JSContext* cx, unsigned argc, Value* vp)
} }
// ES2016, 25.4.1.7. // ES2016, 25.4.1.7.
static MOZ_MUST_USE bool [[nodiscard]] static bool
RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason_) RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason_)
{ {
Rooted<PromiseObject*> promise(cx); Rooted<PromiseObject*> promise(cx);
@@ -1410,7 +1410,7 @@ RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue re
} }
// ES2016, 25.4.1.8. // ES2016, 25.4.1.8.
static MOZ_MUST_USE bool [[nodiscard]] static bool
TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseState state, TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseState state,
HandleValue valueOrReason) HandleValue valueOrReason)
{ {
@@ -1440,7 +1440,7 @@ TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseStat
// Implements PromiseReactionJob optimized for the case when the reaction // Implements PromiseReactionJob optimized for the case when the reaction
// handler is one of the default resolving functions as created by the // handler is one of the default resolving functions as created by the
// CreateResolvingFunctions abstract operation. // CreateResolvingFunctions abstract operation.
static MOZ_MUST_USE bool [[nodiscard]] static bool
DefaultResolvingPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction, DefaultResolvingPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval) MutableHandleValue rval)
{ {
@@ -1485,7 +1485,7 @@ DefaultResolvingPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*>
return true; return true;
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
AsyncFunctionPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction, AsyncFunctionPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval) MutableHandleValue rval)
{ {
@@ -1513,7 +1513,7 @@ AsyncFunctionPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> re
return true; return true;
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
AsyncGeneratorPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction, AsyncGeneratorPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval) MutableHandleValue rval)
{ {
@@ -1723,7 +1723,7 @@ PromiseResolveThenableJob(JSContext* cx, unsigned argc, Value* vp)
return Call(cx, rejectVal, UndefinedHandleValue, rval, &rval); return Call(cx, rejectVal, UndefinedHandleValue, rval, &rval);
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise, OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve); Handle<PromiseObject*> promiseToResolve);
@@ -1785,7 +1785,7 @@ PromiseResolveBuiltinThenableJob(JSContext* cx, unsigned argc, Value* vp)
* thenable_ - The thenable to resolve the Promise with. * thenable_ - The thenable to resolve the Promise with.
* thenVal - The `then` function to invoke with the `thenable` as the receiver. * thenVal - The `then` function to invoke with the `thenable` as the receiver.
*/ */
static MOZ_MUST_USE bool [[nodiscard]] static bool
EnqueuePromiseResolveThenableJob(JSContext* cx, HandleValue promiseToResolve_, EnqueuePromiseResolveThenableJob(JSContext* cx, HandleValue promiseToResolve_,
HandleValue thenable_, HandleValue thenVal) HandleValue thenable_, HandleValue thenVal)
{ {
@@ -1847,7 +1847,7 @@ EnqueuePromiseResolveThenableJob(JSContext* cx, HandleValue promiseToResolve_,
* promiseToResolve - The promise to resolve, obviously. * promiseToResolve - The promise to resolve, obviously.
* thenable - The thenable to resolve the Promise with. * thenable - The thenable to resolve the Promise with.
*/ */
static MOZ_MUST_USE bool [[nodiscard]] static bool
EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToResolve, EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToResolve,
HandleObject thenable) HandleObject thenable)
{ {
@@ -1869,11 +1869,11 @@ EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToRes
return cx->runtime()->enqueuePromiseJob(cx, job, promiseToResolve, incumbentGlobal); return cx->runtime()->enqueuePromiseJob(cx, job, promiseToResolve, incumbentGlobal);
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise, AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise,
HandleObject dependentPromise); HandleObject dependentPromise);
static MOZ_MUST_USE bool [[nodiscard]] static bool
AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise, AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction); Handle<PromiseReactionRecord*> reaction);
@@ -1947,7 +1947,7 @@ ClearResolutionFunctionSlots(JSFunction* resolutionFun)
} }
// ES2016, 25.4.3.1. steps 3-7. // ES2016, 25.4.3.1. steps 3-7.
static MOZ_MUST_USE PromiseObject* [[nodiscard]] static PromiseObject*
CreatePromiseObjectInternal(JSContext* cx, HandleObject proto /* = nullptr */, CreatePromiseObjectInternal(JSContext* cx, HandleObject proto /* = nullptr */,
bool protoIsWrapped /* = false */, bool informDebugger /* = true */) bool protoIsWrapped /* = false */, bool informDebugger /* = true */)
{ {
@@ -2175,19 +2175,19 @@ class MOZ_STACK_CLASS PromiseForOfIterator : public JS::ForOfIterator {
} }
}; };
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseAll(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C, PerformPromiseAll(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done); Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseAllSettled(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C, PerformPromiseAllSettled(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done); Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseAny(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C, PerformPromiseAny(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done); Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseRace(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C, PerformPromiseRace(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done); Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
@@ -2204,7 +2204,7 @@ enum class CombinatorKind { All, AllSettled, Any, Race };
// https://tc39.es/proposal-promise-any/ // https://tc39.es/proposal-promise-any/
// //
// Promise.any ( iterable ) // Promise.any ( iterable )
static MOZ_MUST_USE bool [[nodiscard]] static bool
CommonPromiseCombinator(JSContext* cx, CallArgs& args, CombinatorKind mode) CommonPromiseCombinator(JSContext* cx, CallArgs& args, CombinatorKind mode)
{ {
HandleValue iterable = args.get(0); HandleValue iterable = args.get(0);
@@ -2340,11 +2340,11 @@ static bool Promise_static_all(JSContext* cx, unsigned argc, Value* vp) {
return CommonPromiseCombinator(cx, args, CombinatorKind::All); return CommonPromiseCombinator(cx, args, CombinatorKind::All);
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_, PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_,
HandleValue onRejected_, Handle<PromiseCapability> resultCapability); HandleValue onRejected_, Handle<PromiseCapability> resultCapability);
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise, PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve, Handle<PromiseObject*> promiseToResolve,
Handle<PromiseCapability> resultCapability); Handle<PromiseCapability> resultCapability);
@@ -2356,7 +2356,7 @@ static JSFunction* NewPromiseCombinatorElementFunction(
static bool PromiseAllResolveElementFunction(JSContext* cx, unsigned argc, Value* vp); static bool PromiseAllResolveElementFunction(JSContext* cx, unsigned argc, Value* vp);
// Unforgeable version of ES2016, 25.4.4.1. // Unforgeable version of ES2016, 25.4.4.1.
MOZ_MUST_USE JSObject* [[nodiscard]] JSObject*
js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises) js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises)
{ {
#ifdef DEBUG #ifdef DEBUG
@@ -2476,7 +2476,7 @@ js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises)
return resultCapability.promise(); return resultCapability.promise();
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue result, RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue result,
ResolutionMode mode, HandleObject promiseObj) ResolutionMode mode, HandleObject promiseObj)
{ {
@@ -2528,7 +2528,7 @@ RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue res
return RejectPromiseInternal(cx, promise, result); return RejectPromiseInternal(cx, promise, result);
} }
static MOZ_MUST_USE JSObject* [[nodiscard]] static JSObject*
CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal, CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal,
ResolutionMode mode); ResolutionMode mode);
@@ -2544,7 +2544,7 @@ IsPromiseSpecies(JSContext* cx, JSFunction* species);
// https://tc39.es/proposal-promise-any/ // https://tc39.es/proposal-promise-any/
// Runtime Semantics: PerformPromiseAny, steps 6-8. // Runtime Semantics: PerformPromiseAny, steps 6-8.
template <typename T> template <typename T>
static MOZ_MUST_USE bool [[nodiscard]] static bool
CommonPerformPromiseCombinator(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C, CommonPerformPromiseCombinator(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
HandleObject resultPromise, HandleValue promiseResolve, bool* done, HandleObject resultPromise, HandleValue promiseResolve, bool* done,
bool resolveReturnsUndefined, T getResolveAndReject) bool resolveReturnsUndefined, T getResolveAndReject)
@@ -2810,7 +2810,7 @@ CommonPerformPromiseCombinator(JSContext *cx, PromiseForOfIterator& iterator, Ha
// Create the elements for the Promise combinators Promise.all and // Create the elements for the Promise combinators Promise.all and
// Promise.allSettled. // Promise.allSettled.
static MOZ_MUST_USE bool [[nodiscard]] static bool
NewPromiseCombinatorElements(JSContext* cx, Handle<PromiseCapability> resultCapability, NewPromiseCombinatorElements(JSContext* cx, Handle<PromiseCapability> resultCapability,
MutableHandle<PromiseCombinatorElements> elements) MutableHandle<PromiseCombinatorElements> elements)
{ {
@@ -2862,7 +2862,7 @@ NewPromiseCombinatorElements(JSContext* cx, Handle<PromiseCapability> resultCapa
} }
// Retrieve the combinator elements from the data holder. // Retrieve the combinator elements from the data holder.
static MOZ_MUST_USE bool [[nodiscard]] static bool
GetPromiseCombinatorElements(JSContext* cx, Handle<PromiseCombinatorDataHolder*> data, GetPromiseCombinatorElements(JSContext* cx, Handle<PromiseCombinatorDataHolder*> data,
MutableHandle<PromiseCombinatorElements> elements) MutableHandle<PromiseCombinatorElements> elements)
{ {
@@ -2947,7 +2947,7 @@ PromiseCombinatorElementFunctionAlreadyCalled(const CallArgs& args,
// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646 // ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
// 25.6.4.1.1 PerformPromiseAll (iteratorRecord, constructor, resultCapability) // 25.6.4.1.1 PerformPromiseAll (iteratorRecord, constructor, resultCapability)
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseAll(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C, PerformPromiseAll(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done) Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done)
{ {
@@ -3083,7 +3083,7 @@ Promise_static_race(JSContext* cx, unsigned argc, Value* vp)
// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646 // ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
// 25.6.4.3.1 PerformPromiseRace (iteratorRecord, constructor, resultCapability) // 25.6.4.3.1 PerformPromiseRace (iteratorRecord, constructor, resultCapability)
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseRace(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C, PerformPromiseRace(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done) Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done)
{ {
@@ -3138,7 +3138,7 @@ static bool Promise_static_allSettled(JSContext* cx, unsigned argc, Value* vp) {
// 25.6.4.2 Promise.allSettled ( iterable ) // 25.6.4.2 Promise.allSettled ( iterable )
// //
// PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability ) // PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
static MOZ_MUST_USE bool PerformPromiseAllSettled( [[nodiscard]] static bool PerformPromiseAllSettled(
JSContext* cx, PromiseForOfIterator& iterator, HandleObject C, JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done) { Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done) {
*done = false; *done = false;
@@ -3349,7 +3349,7 @@ static void ThrowAggregateError(JSContext* cx,
// https://tc39.es/proposal-promise-any/ // https://tc39.es/proposal-promise-any/
// //
// PerformPromiseAny ( iteratorRecord, constructor, resultCapability ) // PerformPromiseAny ( iteratorRecord, constructor, resultCapability )
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseAny(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C, PerformPromiseAny(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done) Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done)
{ {
@@ -3553,7 +3553,7 @@ ThrowAggregateError(JSContext* cx, Handle<PromiseCombinatorElements> errors, Han
// 25.6.4.4 Promise.reject ( r ) // 25.6.4.4 Promise.reject ( r )
// 25.6.4.5 Promise.resolve ( x ) // 25.6.4.5 Promise.resolve ( x )
// 25.6.4.5.1 PromiseResolve ( C, x ) // 25.6.4.5.1 PromiseResolve ( C, x )
static MOZ_MUST_USE JSObject* [[nodiscard]] static JSObject*
CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal, CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal,
ResolutionMode mode) ResolutionMode mode)
{ {
@@ -3610,7 +3610,7 @@ CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue ar
return capability.promise(); return capability.promise();
} }
MOZ_MUST_USE JSObject* [[nodiscard]] JSObject*
js::PromiseResolve(JSContext* cx, HandleObject constructor, HandleValue value) js::PromiseResolve(JSContext* cx, HandleObject constructor, HandleValue value)
{ {
RootedValue C(cx, ObjectValue(*constructor)); RootedValue C(cx, ObjectValue(*constructor));
@@ -3789,7 +3789,7 @@ PromiseThenNewPromiseCapability(JSContext* cx, HandleObject promiseObj,
} }
// ES2016, 25.4.5.3., steps 3-5. // ES2016, 25.4.5.3., steps 3-5.
MOZ_MUST_USE bool [[nodiscard]] bool
js::OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, js::OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
HandleValue onFulfilled, HandleValue onRejected, HandleValue onFulfilled, HandleValue onRejected,
MutableHandleObject dependent, CreateDependentPromise createDependent) MutableHandleObject dependent, CreateDependentPromise createDependent)
@@ -3813,7 +3813,7 @@ js::OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
return true; return true;
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise, OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve) Handle<PromiseObject*> promiseToResolve)
{ {
@@ -3870,7 +3870,7 @@ OriginalPromiseThenBuiltin(JSContext* cx, HandleValue promiseVal, HandleValue on
return true; return true;
} }
MOZ_MUST_USE bool [[nodiscard]] bool
js::RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise) js::RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise)
{ {
// Not much we can do about uncatchable exceptions, just bail. // Not much we can do about uncatchable exceptions, just bail.
@@ -3880,7 +3880,7 @@ js::RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise)
return PromiseObject::reject(cx, promise, exn); return PromiseObject::reject(cx, promise, exn);
} }
static MOZ_MUST_USE bool PerformPromiseThenWithReaction(JSContext* cx, [[nodiscard]] static bool PerformPromiseThenWithReaction(JSContext* cx,
Handle<PromiseObject*> promise, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction); Handle<PromiseReactionRecord*> reaction);
@@ -3888,7 +3888,7 @@ static MOZ_MUST_USE bool PerformPromiseThenWithReaction(JSContext* cx,
// js/src/builtin/AsyncFunction.cpp, to call Promise internal functions. // js/src/builtin/AsyncFunction.cpp, to call Promise internal functions.
// ES 2018 draft 14.6.11 and 14.7.14 step 1. // ES 2018 draft 14.6.11 and 14.7.14 step 1.
MOZ_MUST_USE PromiseObject* [[nodiscard]] PromiseObject*
js::CreatePromiseObjectForAsync(JSContext* cx, HandleValue generatorVal) js::CreatePromiseObjectForAsync(JSContext* cx, HandleValue generatorVal)
{ {
// Step 1. // Step 1.
@@ -3909,7 +3909,7 @@ js::IsPromiseForAsync(JSObject* promise)
} }
// ES 2018 draft 25.5.5.2 steps 3.f, 3.g. // ES 2018 draft 25.5.5.2 steps 3.f, 3.g.
MOZ_MUST_USE bool [[nodiscard]] bool
js::AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise) js::AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise)
{ {
// Step 3.f. // Step 3.f.
@@ -3925,7 +3925,7 @@ js::AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise)
} }
// ES 2018 draft 25.5.5.2 steps 3.d-e, 3.g. // ES 2018 draft 25.5.5.2 steps 3.d-e, 3.g.
MOZ_MUST_USE bool [[nodiscard]] bool
js::AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value) js::AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value)
{ {
// Steps 3.d-e. // Steps 3.d-e.
@@ -3939,7 +3939,7 @@ js::AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, H
// Helper function that performs the equivalent steps as // Helper function that performs the equivalent steps as
// Async Iteration proposal 4.1 Await steps 2-3, 6-9 or similar. // Async Iteration proposal 4.1 Await steps 2-3, 6-9 or similar.
template <typename T> template <typename T>
static MOZ_MUST_USE bool [[nodiscard]] static bool
InternalAwait(JSContext* cx, HandleValue value, HandleObject resultPromise, InternalAwait(JSContext* cx, HandleValue value, HandleObject resultPromise,
HandleValue onFulfilled, HandleValue onRejected, T extraStep) HandleValue onFulfilled, HandleValue onRejected, T extraStep)
{ {
@@ -3972,7 +3972,7 @@ InternalAwait(JSContext* cx, HandleValue value, HandleObject resultPromise,
} }
// ES 2018 draft 25.5.5.3 steps 2-10. // ES 2018 draft 25.5.5.3 steps 2-10.
MOZ_MUST_USE bool [[nodiscard]] bool
js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value) js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value)
{ {
// Steps 4-5. // Steps 4-5.
@@ -3987,7 +3987,7 @@ js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, Hand
} }
// Async Iteration proposal 4.1 Await steps 2-9. // Async Iteration proposal 4.1 Await steps 2-9.
MOZ_MUST_USE bool [[nodiscard]] bool
js::AsyncGeneratorAwait(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, js::AsyncGeneratorAwait(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value) HandleValue value)
{ {
@@ -4146,13 +4146,13 @@ enum class ResumeNextKind {
Enqueue, Reject, Resolve Enqueue, Reject, Resolve
}; };
static MOZ_MUST_USE bool [[nodiscard]] static bool
AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
ResumeNextKind kind, HandleValue valueOrException = UndefinedHandleValue, ResumeNextKind kind, HandleValue valueOrException = UndefinedHandleValue,
bool done = false); bool done = false);
// Async Iteration proposal 11.4.3.3. // Async Iteration proposal 11.4.3.3.
MOZ_MUST_USE bool [[nodiscard]] bool
js::AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, js::AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value, bool done) HandleValue value, bool done)
{ {
@@ -4160,7 +4160,7 @@ js::AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenO
} }
// Async Iteration proposal 11.4.3.4. // Async Iteration proposal 11.4.3.4.
MOZ_MUST_USE bool [[nodiscard]] bool
js::AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, js::AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue exception) HandleValue exception)
{ {
@@ -4168,7 +4168,7 @@ js::AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenOb
} }
// Async Iteration proposal 11.4.3.5. // Async Iteration proposal 11.4.3.5.
static MOZ_MUST_USE bool [[nodiscard]] static bool
AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
ResumeNextKind kind, ResumeNextKind kind,
HandleValue valueOrException_ /* = UndefinedHandleValue */, HandleValue valueOrException_ /* = UndefinedHandleValue */,
@@ -4349,7 +4349,7 @@ AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenOb
} }
// Async Iteration proposal 11.4.3.6. // Async Iteration proposal 11.4.3.6.
MOZ_MUST_USE bool [[nodiscard]] bool
js::AsyncGeneratorEnqueue(JSContext* cx, HandleValue asyncGenVal, js::AsyncGeneratorEnqueue(JSContext* cx, HandleValue asyncGenVal,
CompletionKind completionKind, HandleValue completionValue, CompletionKind completionKind, HandleValue completionValue,
MutableHandleValue result) MutableHandleValue result)
@@ -4540,7 +4540,7 @@ Promise_then(JSContext* cx, unsigned argc, Value* vp)
} }
// ES2016, 25.4.5.3.1. // ES2016, 25.4.5.3.1.
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_, PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_,
HandleValue onRejected_, Handle<PromiseCapability> resultCapability) HandleValue onRejected_, Handle<PromiseCapability> resultCapability)
{ {
@@ -4567,7 +4567,7 @@ PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue on
return PerformPromiseThenWithReaction(cx, promise, reaction); return PerformPromiseThenWithReaction(cx, promise, reaction);
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise, PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve, Handle<PromiseObject*> promiseToResolve,
Handle<PromiseCapability> resultCapability) Handle<PromiseCapability> resultCapability)
@@ -4593,7 +4593,7 @@ PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> pr
return PerformPromiseThenWithReaction(cx, promise, reaction); return PerformPromiseThenWithReaction(cx, promise, reaction);
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
PerformPromiseThenWithReaction(JSContext* cx, Handle<PromiseObject*> promise, PerformPromiseThenWithReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction) Handle<PromiseReactionRecord*> reaction)
{ {
@@ -4637,7 +4637,7 @@ PerformPromiseThenWithReaction(JSContext* cx, Handle<PromiseObject*> promise,
return true; return true;
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise, AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction) Handle<PromiseReactionRecord*> reaction)
{ {
@@ -4705,7 +4705,7 @@ AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
return true; return true;
} }
static MOZ_MUST_USE bool [[nodiscard]] static bool
AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise, AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise,
HandleObject dependentPromise) HandleObject dependentPromise)
{ {
+18 -18
View File
@@ -73,10 +73,10 @@ class PromiseObject : public NativeObject
return getFixedSlot(PromiseSlot_ReactionsOrResult); return getFixedSlot(PromiseSlot_ReactionsOrResult);
} }
static MOZ_MUST_USE bool resolve(JSContext* cx, Handle<PromiseObject*> promise, [[nodiscard]] static bool resolve(JSContext* cx, Handle<PromiseObject*> promise,
HandleValue resolutionValue); HandleValue resolutionValue);
static MOZ_MUST_USE bool reject(JSContext* cx, Handle<PromiseObject*> promise, [[nodiscard]] static bool reject(JSContext* cx, Handle<PromiseObject*> promise,
HandleValue rejectionValue); HandleValue rejectionValue);
static void onSettled(JSContext* cx, Handle<PromiseObject*> promise); static void onSettled(JSContext* cx, Handle<PromiseObject*> promise);
@@ -89,7 +89,7 @@ class PromiseObject : public NativeObject
MOZ_ASSERT(state() != JS::PromiseState::Pending); MOZ_ASSERT(state() != JS::PromiseState::Pending);
return resolutionTime() - allocationTime(); return resolutionTime() - allocationTime();
} }
MOZ_MUST_USE bool dependentPromises(JSContext* cx, MutableHandle<GCVector<Value>> values); [[nodiscard]] bool dependentPromises(JSContext* cx, MutableHandle<GCVector<Value>> values);
uint64_t getID(); uint64_t getID();
bool isUnhandled() { bool isUnhandled() {
MOZ_ASSERT(state() == JS::PromiseState::Rejected); MOZ_ASSERT(state() == JS::PromiseState::Rejected);
@@ -113,7 +113,7 @@ class PromiseObject : public NativeObject
* Asserts that all objects in the `promises` vector are, maybe wrapped, * Asserts that all objects in the `promises` vector are, maybe wrapped,
* instances of `Promise` or a subclass of `Promise`. * instances of `Promise` or a subclass of `Promise`.
*/ */
MOZ_MUST_USE JSObject* [[nodiscard]] JSObject*
GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises); GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises);
enum class CreateDependentPromise { enum class CreateDependentPromise {
@@ -132,7 +132,7 @@ enum class CreateDependentPromise {
* `promise` field that can contain null. That field is only ever used by * `promise` field that can contain null. That field is only ever used by
* devtools, which have to treat these reactions specially. * devtools, which have to treat these reactions specially.
*/ */
MOZ_MUST_USE bool [[nodiscard]] bool
OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
HandleValue onFulfilled, HandleValue onRejected, HandleValue onFulfilled, HandleValue onRejected,
MutableHandleObject dependent, CreateDependentPromise createDependent); MutableHandleObject dependent, CreateDependentPromise createDependent);
@@ -143,41 +143,41 @@ OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
* The abstract operation PromiseResolve, given a constructor and a value, * The abstract operation PromiseResolve, given a constructor and a value,
* returns a new promise resolved with that value. * returns a new promise resolved with that value.
*/ */
MOZ_MUST_USE JSObject* [[nodiscard]] JSObject*
PromiseResolve(JSContext* cx, HandleObject constructor, HandleValue value); PromiseResolve(JSContext* cx, HandleObject constructor, HandleValue value);
MOZ_MUST_USE bool [[nodiscard]] bool
RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise); RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise);
MOZ_MUST_USE PromiseObject* [[nodiscard]] PromiseObject*
CreatePromiseObjectForAsync(JSContext* cx, HandleValue generatorVal); CreatePromiseObjectForAsync(JSContext* cx, HandleValue generatorVal);
MOZ_MUST_USE bool [[nodiscard]] bool
IsPromiseForAsync(JSObject* promise); IsPromiseForAsync(JSObject* promise);
MOZ_MUST_USE bool [[nodiscard]] bool
AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value); AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value);
MOZ_MUST_USE bool [[nodiscard]] bool
AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise); AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise);
MOZ_MUST_USE bool [[nodiscard]] bool
AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value); AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value);
class AsyncGeneratorObject; class AsyncGeneratorObject;
MOZ_MUST_USE bool [[nodiscard]] bool
AsyncGeneratorAwait(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value); AsyncGeneratorAwait(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value);
MOZ_MUST_USE bool [[nodiscard]] bool
AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value, bool done); HandleValue value, bool done);
MOZ_MUST_USE bool [[nodiscard]] bool
AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue exception); HandleValue exception);
MOZ_MUST_USE bool [[nodiscard]] bool
AsyncGeneratorEnqueue(JSContext* cx, HandleValue asyncGenVal, CompletionKind completionKind, AsyncGeneratorEnqueue(JSContext* cx, HandleValue asyncGenVal, CompletionKind completionKind,
HandleValue completionValue, MutableHandleValue result); HandleValue completionValue, MutableHandleValue result);
+2 -2
View File
@@ -17,10 +17,10 @@ InitReflect(JSContext* cx, js::HandleObject obj);
namespace js { namespace js {
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
Reflect_getPrototypeOf(JSContext* cx, unsigned argc, Value* vp); Reflect_getPrototypeOf(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
Reflect_isExtensible(JSContext* cx, unsigned argc, Value* vp); Reflect_isExtensible(JSContext* cx, unsigned argc, Value* vp);
} }
+84 -84
View File
@@ -256,7 +256,7 @@ class NodeBuilder
userv(c) userv(c)
{} {}
MOZ_MUST_USE bool init(HandleObject userobj = nullptr) { [[nodiscard]] bool init(HandleObject userobj = nullptr) {
if (src) { if (src) {
if (!atomValue(src, &srcval)) if (!atomValue(src, &srcval))
return false; return false;
@@ -307,7 +307,7 @@ class NodeBuilder
} }
private: private:
MOZ_MUST_USE bool callbackHelper(HandleValue fun, const InvokeArgs& args, size_t i, [[nodiscard]] bool callbackHelper(HandleValue fun, const InvokeArgs& args, size_t i,
TokenPos* pos, MutableHandleValue dst) TokenPos* pos, MutableHandleValue dst)
{ {
// The end of the implementation of callback(). All arguments except // The end of the implementation of callback(). All arguments except
@@ -324,7 +324,7 @@ class NodeBuilder
// that convert to HandleValue, so this isn't as template-y as it seems, // that convert to HandleValue, so this isn't as template-y as it seems,
// just variadic. // just variadic.
template <typename... Arguments> template <typename... Arguments>
MOZ_MUST_USE bool callbackHelper(HandleValue fun, const InvokeArgs& args, size_t i, [[nodiscard]] bool callbackHelper(HandleValue fun, const InvokeArgs& args, size_t i,
HandleValue head, Arguments&&... tail) HandleValue head, Arguments&&... tail)
{ {
// Recursive loop to store the arguments into args. This eventually // Recursive loop to store the arguments into args. This eventually
@@ -338,7 +338,7 @@ class NodeBuilder
// bool callback(HandleValue fun, HandleValue... args, TokenPos* pos, // bool callback(HandleValue fun, HandleValue... args, TokenPos* pos,
// MutableHandleValue dst); // MutableHandleValue dst);
template <typename... Arguments> template <typename... Arguments>
MOZ_MUST_USE bool callback(HandleValue fun, Arguments&&... args) { [[nodiscard]] bool callback(HandleValue fun, Arguments&&... args) {
InvokeArgs iargs(cx); InvokeArgs iargs(cx);
if (!iargs.init(cx, sizeof...(args) - 2 + size_t(saveLoc))) if (!iargs.init(cx, sizeof...(args) - 2 + size_t(saveLoc)))
return false; return false;
@@ -355,7 +355,7 @@ class NodeBuilder
return v.isMagic(JS_SERIALIZE_NO_NODE) ? JS::UndefinedHandleValue : v; return v.isMagic(JS_SERIALIZE_NO_NODE) ? JS::UndefinedHandleValue : v;
} }
MOZ_MUST_USE bool atomValue(const char* s, MutableHandleValue dst) { [[nodiscard]] bool atomValue(const char* s, MutableHandleValue dst) {
/* /*
* Bug 575416: instead of Atomize, lookup constant atoms in tbl file * Bug 575416: instead of Atomize, lookup constant atoms in tbl file
*/ */
@@ -367,7 +367,7 @@ class NodeBuilder
return true; return true;
} }
MOZ_MUST_USE bool newObject(MutableHandleObject dst) { [[nodiscard]] bool newObject(MutableHandleObject dst) {
RootedPlainObject nobj(cx, NewBuiltinClassInstance<PlainObject>(cx)); RootedPlainObject nobj(cx, NewBuiltinClassInstance<PlainObject>(cx));
if (!nobj) if (!nobj)
return false; return false;
@@ -376,11 +376,11 @@ class NodeBuilder
return true; return true;
} }
MOZ_MUST_USE bool newArray(NodeVector& elts, MutableHandleValue dst); [[nodiscard]] bool newArray(NodeVector& elts, MutableHandleValue dst);
MOZ_MUST_USE bool createNode(ASTType type, TokenPos* pos, MutableHandleObject dst); [[nodiscard]] bool createNode(ASTType type, TokenPos* pos, MutableHandleObject dst);
MOZ_MUST_USE bool newNodeHelper(HandleObject obj, MutableHandleValue dst) { [[nodiscard]] bool newNodeHelper(HandleObject obj, MutableHandleValue dst) {
// The end of the implementation of newNode(). // The end of the implementation of newNode().
MOZ_ASSERT(obj); MOZ_ASSERT(obj);
dst.setObject(*obj); dst.setObject(*obj);
@@ -388,7 +388,7 @@ class NodeBuilder
} }
template <typename... Arguments> template <typename... Arguments>
MOZ_MUST_USE bool newNodeHelper(HandleObject obj, const char *name, HandleValue value, [[nodiscard]] bool newNodeHelper(HandleObject obj, const char *name, HandleValue value,
Arguments&&... rest) Arguments&&... rest)
{ {
// Recursive loop to define properties. Note that the newNodeHelper() // Recursive loop to define properties. Note that the newNodeHelper()
@@ -407,13 +407,13 @@ class NodeBuilder
// {const char *name0, HandleValue value0,}... // {const char *name0, HandleValue value0,}...
// MutableHandleValue dst); // MutableHandleValue dst);
template <typename... Arguments> template <typename... Arguments>
MOZ_MUST_USE bool newNode(ASTType type, TokenPos* pos, Arguments&&... args) { [[nodiscard]] bool newNode(ASTType type, TokenPos* pos, Arguments&&... args) {
RootedObject node(cx); RootedObject node(cx);
return createNode(type, pos, &node) && return createNode(type, pos, &node) &&
newNodeHelper(node, Forward<Arguments>(args)...); newNodeHelper(node, Forward<Arguments>(args)...);
} }
MOZ_MUST_USE bool listNode(ASTType type, const char* propName, NodeVector& elts, TokenPos* pos, [[nodiscard]] bool listNode(ASTType type, const char* propName, NodeVector& elts, TokenPos* pos,
MutableHandleValue dst) { MutableHandleValue dst) {
RootedValue array(cx); RootedValue array(cx);
if (!newArray(elts, &array)) if (!newArray(elts, &array))
@@ -426,7 +426,7 @@ class NodeBuilder
return newNode(type, pos, propName, array, dst); return newNode(type, pos, propName, array, dst);
} }
MOZ_MUST_USE bool defineProperty(HandleObject obj, const char* name, HandleValue val) { [[nodiscard]] bool defineProperty(HandleObject obj, const char* name, HandleValue val) {
MOZ_ASSERT_IF(val.isMagic(), val.whyMagic() == JS_SERIALIZE_NO_NODE); MOZ_ASSERT_IF(val.isMagic(), val.whyMagic() == JS_SERIALIZE_NO_NODE);
/* /*
@@ -441,9 +441,9 @@ class NodeBuilder
return DefineProperty(cx, obj, atom->asPropertyName(), optVal); return DefineProperty(cx, obj, atom->asPropertyName(), optVal);
} }
MOZ_MUST_USE bool newNodeLoc(TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool newNodeLoc(TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool setNodeLoc(HandleObject node, TokenPos* pos); [[nodiscard]] bool setNodeLoc(HandleObject node, TokenPos* pos);
public: public:
/* /*
@@ -459,27 +459,27 @@ class NodeBuilder
* misc nodes * misc nodes
*/ */
MOZ_MUST_USE bool program(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool program(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool literal(HandleValue val, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool literal(HandleValue val, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool identifier(HandleValue name, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool identifier(HandleValue name, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool function(ASTType type, TokenPos* pos, [[nodiscard]] bool function(ASTType type, TokenPos* pos,
HandleValue id, NodeVector& args, NodeVector& defaults, HandleValue id, NodeVector& args, NodeVector& defaults,
HandleValue body, HandleValue rest, GeneratorStyle generatorStyle, HandleValue body, HandleValue rest, GeneratorStyle generatorStyle,
bool isAsync, bool isExpression, MutableHandleValue dst); bool isAsync, bool isExpression, MutableHandleValue dst);
MOZ_MUST_USE bool variableDeclarator(HandleValue id, HandleValue init, TokenPos* pos, [[nodiscard]] bool variableDeclarator(HandleValue id, HandleValue init, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool switchCase(HandleValue expr, NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool switchCase(HandleValue expr, NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool catchClause(HandleValue var, HandleValue guard, HandleValue body, TokenPos* pos, [[nodiscard]] bool catchClause(HandleValue var, HandleValue guard, HandleValue body, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool prototypeMutation(HandleValue val, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool prototypeMutation(HandleValue val, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool propertyInitializer(HandleValue key, HandleValue val, PropKind kind, [[nodiscard]] bool propertyInitializer(HandleValue key, HandleValue val, PropKind kind,
bool isShorthand, bool isMethod, TokenPos* pos, bool isShorthand, bool isMethod, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
@@ -488,165 +488,165 @@ class NodeBuilder
* statements * statements
*/ */
MOZ_MUST_USE bool blockStatement(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool blockStatement(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool expressionStatement(HandleValue expr, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool expressionStatement(HandleValue expr, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool emptyStatement(TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool emptyStatement(TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool ifStatement(HandleValue test, HandleValue cons, HandleValue alt, TokenPos* pos, [[nodiscard]] bool ifStatement(HandleValue test, HandleValue cons, HandleValue alt, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool breakStatement(HandleValue label, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool breakStatement(HandleValue label, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool continueStatement(HandleValue label, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool continueStatement(HandleValue label, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool labeledStatement(HandleValue label, HandleValue stmt, TokenPos* pos, [[nodiscard]] bool labeledStatement(HandleValue label, HandleValue stmt, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool throwStatement(HandleValue arg, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool throwStatement(HandleValue arg, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool returnStatement(HandleValue arg, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool returnStatement(HandleValue arg, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool forStatement(HandleValue init, HandleValue test, HandleValue update, HandleValue stmt, [[nodiscard]] bool forStatement(HandleValue init, HandleValue test, HandleValue update, HandleValue stmt,
TokenPos* pos, MutableHandleValue dst); TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool forInStatement(HandleValue var, HandleValue expr, HandleValue stmt, [[nodiscard]] bool forInStatement(HandleValue var, HandleValue expr, HandleValue stmt,
bool isForEach, TokenPos* pos, MutableHandleValue dst); bool isForEach, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool forOfStatement(HandleValue var, HandleValue expr, HandleValue stmt, TokenPos* pos, [[nodiscard]] bool forOfStatement(HandleValue var, HandleValue expr, HandleValue stmt, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool withStatement(HandleValue expr, HandleValue stmt, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool withStatement(HandleValue expr, HandleValue stmt, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool whileStatement(HandleValue test, HandleValue stmt, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool whileStatement(HandleValue test, HandleValue stmt, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool doWhileStatement(HandleValue stmt, HandleValue test, TokenPos* pos, [[nodiscard]] bool doWhileStatement(HandleValue stmt, HandleValue test, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool switchStatement(HandleValue disc, NodeVector& elts, bool lexical, TokenPos* pos, [[nodiscard]] bool switchStatement(HandleValue disc, NodeVector& elts, bool lexical, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool tryStatement(HandleValue body, NodeVector& guarded, HandleValue unguarded, [[nodiscard]] bool tryStatement(HandleValue body, NodeVector& guarded, HandleValue unguarded,
HandleValue finally, TokenPos* pos, MutableHandleValue dst); HandleValue finally, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool debuggerStatement(TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool debuggerStatement(TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool importDeclaration(NodeVector& elts, HandleValue moduleSpec, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool importDeclaration(NodeVector& elts, HandleValue moduleSpec, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool importSpecifier(HandleValue importName, HandleValue bindingName, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool importSpecifier(HandleValue importName, HandleValue bindingName, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool exportDeclaration(HandleValue decl, NodeVector& elts, HandleValue moduleSpec, [[nodiscard]] bool exportDeclaration(HandleValue decl, NodeVector& elts, HandleValue moduleSpec,
HandleValue isDefault, TokenPos* pos, MutableHandleValue dst); HandleValue isDefault, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool exportSpecifier(HandleValue bindingName, HandleValue exportName, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool exportSpecifier(HandleValue bindingName, HandleValue exportName, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool exportBatchSpecifier(TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool exportBatchSpecifier(TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool classDefinition(bool expr, HandleValue name, HandleValue heritage, [[nodiscard]] bool classDefinition(bool expr, HandleValue name, HandleValue heritage,
HandleValue block, TokenPos* pos, MutableHandleValue dst); HandleValue block, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool classMembers(NodeVector& members, MutableHandleValue dst); [[nodiscard]] bool classMembers(NodeVector& members, MutableHandleValue dst);
MOZ_MUST_USE bool classMethod(HandleValue name, HandleValue body, PropKind kind, bool isStatic, [[nodiscard]] bool classMethod(HandleValue name, HandleValue body, PropKind kind, bool isStatic,
TokenPos* pos, MutableHandleValue dst); TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool classField(HandleValue name, HandleValue initializer, [[nodiscard]] bool classField(HandleValue name, HandleValue initializer,
TokenPos* pos, MutableHandleValue dst); TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool staticClassBlock(HandleValue body, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool staticClassBlock(HandleValue body, TokenPos* pos, MutableHandleValue dst);
/* /*
* expressions * expressions
*/ */
MOZ_MUST_USE bool binaryExpression(BinaryOperator op, HandleValue left, HandleValue right, [[nodiscard]] bool binaryExpression(BinaryOperator op, HandleValue left, HandleValue right,
TokenPos* pos, MutableHandleValue dst); TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool unaryExpression(UnaryOperator op, HandleValue expr, TokenPos* pos, [[nodiscard]] bool unaryExpression(UnaryOperator op, HandleValue expr, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool assignmentExpression(AssignmentOperator op, HandleValue lhs, HandleValue rhs, [[nodiscard]] bool assignmentExpression(AssignmentOperator op, HandleValue lhs, HandleValue rhs,
TokenPos* pos, MutableHandleValue dst); TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool updateExpression(HandleValue expr, bool incr, bool prefix, TokenPos* pos, [[nodiscard]] bool updateExpression(HandleValue expr, bool incr, bool prefix, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool logicalExpression(ParseNodeKind kind, HandleValue left, HandleValue right, TokenPos* pos, [[nodiscard]] bool logicalExpression(ParseNodeKind kind, HandleValue left, HandleValue right, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool conditionalExpression(HandleValue test, HandleValue cons, HandleValue alt, [[nodiscard]] bool conditionalExpression(HandleValue test, HandleValue cons, HandleValue alt,
TokenPos* pos, MutableHandleValue dst); TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool sequenceExpression(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool sequenceExpression(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool newExpression(HandleValue callee, NodeVector& args, TokenPos* pos, [[nodiscard]] bool newExpression(HandleValue callee, NodeVector& args, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool callExpression(HandleValue callee, NodeVector& args, TokenPos* pos, [[nodiscard]] bool callExpression(HandleValue callee, NodeVector& args, TokenPos* pos,
MutableHandleValue dst, bool isOptional = false); MutableHandleValue dst, bool isOptional = false);
MOZ_MUST_USE bool memberExpression(bool computed, HandleValue expr, HandleValue member, [[nodiscard]] bool memberExpression(bool computed, HandleValue expr, HandleValue member,
TokenPos* pos, MutableHandleValue dst, TokenPos* pos, MutableHandleValue dst,
bool isOptional = false); bool isOptional = false);
MOZ_MUST_USE bool arrayExpression(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool arrayExpression(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool templateLiteral(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool templateLiteral(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool taggedTemplate(HandleValue callee, NodeVector& args, TokenPos* pos, [[nodiscard]] bool taggedTemplate(HandleValue callee, NodeVector& args, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool callSiteObj(NodeVector& raw, NodeVector& cooked, TokenPos* pos, [[nodiscard]] bool callSiteObj(NodeVector& raw, NodeVector& cooked, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool spreadExpression(HandleValue expr, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool spreadExpression(HandleValue expr, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool optionalExpression(HandleValue expr, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool optionalExpression(HandleValue expr, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool deleteOptionalExpression(HandleValue expr, TokenPos* pos, [[nodiscard]] bool deleteOptionalExpression(HandleValue expr, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool computedName(HandleValue name, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool computedName(HandleValue name, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool objectExpression(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool objectExpression(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool thisExpression(TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool thisExpression(TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool yieldExpression(HandleValue arg, YieldKind kind, TokenPos* pos, [[nodiscard]] bool yieldExpression(HandleValue arg, YieldKind kind, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool comprehensionBlock(HandleValue patt, HandleValue src, bool isForEach, [[nodiscard]] bool comprehensionBlock(HandleValue patt, HandleValue src, bool isForEach,
bool isForOf, TokenPos* pos, MutableHandleValue dst); bool isForOf, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool comprehensionIf(HandleValue test, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool comprehensionIf(HandleValue test, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool comprehensionExpression(HandleValue body, NodeVector& blocks, [[nodiscard]] bool comprehensionExpression(HandleValue body, NodeVector& blocks,
HandleValue filter, bool isLegacy, TokenPos* pos, HandleValue filter, bool isLegacy, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool generatorExpression(HandleValue body, NodeVector& blocks, HandleValue filter, [[nodiscard]] bool generatorExpression(HandleValue body, NodeVector& blocks, HandleValue filter,
bool isLegacy, TokenPos* pos, MutableHandleValue dst); bool isLegacy, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool metaProperty(HandleValue meta, HandleValue property, TokenPos* pos, [[nodiscard]] bool metaProperty(HandleValue meta, HandleValue property, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool callImportExpression(HandleValue ident, HandleValue arg, TokenPos* pos, [[nodiscard]] bool callImportExpression(HandleValue ident, HandleValue arg, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
MOZ_MUST_USE bool super(TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool super(TokenPos* pos, MutableHandleValue dst);
/* /*
* declarations * declarations
*/ */
MOZ_MUST_USE bool variableDeclaration(NodeVector& elts, VarDeclKind kind, TokenPos* pos, [[nodiscard]] bool variableDeclaration(NodeVector& elts, VarDeclKind kind, TokenPos* pos,
MutableHandleValue dst); MutableHandleValue dst);
/* /*
* patterns * patterns
*/ */
MOZ_MUST_USE bool arrayPattern(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool arrayPattern(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool objectPattern(NodeVector& elts, TokenPos* pos, MutableHandleValue dst); [[nodiscard]] bool objectPattern(NodeVector& elts, TokenPos* pos, MutableHandleValue dst);
MOZ_MUST_USE bool propertyPattern(HandleValue key, HandleValue patt, bool isShorthand, [[nodiscard]] bool propertyPattern(HandleValue key, HandleValue patt, bool isShorthand,
TokenPos* pos, MutableHandleValue dst); TokenPos* pos, MutableHandleValue dst);
}; };
+28 -28
View File
@@ -25,42 +25,42 @@ InitRegExpClass(JSContext* cx, HandleObject obj);
* |input| may be nullptr if there is no JSString corresponding to * |input| may be nullptr if there is no JSString corresponding to
* |chars| and |length|. * |chars| and |length|.
*/ */
MOZ_MUST_USE bool [[nodiscard]] bool
ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, Handle<RegExpObject*> reobj, ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, Handle<RegExpObject*> reobj,
HandleLinearString input, size_t* lastIndex, bool test, HandleLinearString input, size_t* lastIndex, bool test,
MutableHandleValue rval); MutableHandleValue rval);
/* Translation from MatchPairs to a JS array in regexp_exec()'s output format. */ /* Translation from MatchPairs to a JS array in regexp_exec()'s output format. */
MOZ_MUST_USE bool [[nodiscard]] bool
CreateRegExpMatchResult(JSContext* cx, RegExpShared& re, CreateRegExpMatchResult(JSContext* cx, RegExpShared& re,
HandleString input, const MatchPairs& matches, HandleString input, const MatchPairs& matches,
MutableHandleValue rval); MutableHandleValue rval);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpMatcher(JSContext* cx, unsigned argc, Value* vp); RegExpMatcher(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpMatcherRaw(JSContext* cx, HandleObject regexp, HandleString input, RegExpMatcherRaw(JSContext* cx, HandleObject regexp, HandleString input,
int32_t lastIndex, MatchPairs* maybeMatches, MutableHandleValue output); int32_t lastIndex, MatchPairs* maybeMatches, MutableHandleValue output);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpSearcher(JSContext* cx, unsigned argc, Value* vp); RegExpSearcher(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpSearcherRaw(JSContext* cx, HandleObject regexp, HandleString input, RegExpSearcherRaw(JSContext* cx, HandleObject regexp, HandleString input,
int32_t lastIndex, MatchPairs* maybeMatches, int32_t* result); int32_t lastIndex, MatchPairs* maybeMatches, int32_t* result);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpTester(JSContext* cx, unsigned argc, Value* vp); RegExpTester(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpTesterRaw(JSContext* cx, HandleObject regexp, HandleString input, RegExpTesterRaw(JSContext* cx, HandleObject regexp, HandleString input,
int32_t lastIndex, int32_t* endIndex); int32_t lastIndex, int32_t* endIndex);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intrinsic_GetElemBaseForLambda(JSContext* cx, unsigned argc, Value* vp); intrinsic_GetElemBaseForLambda(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intrinsic_GetStringDataProperty(JSContext* cx, unsigned argc, Value* vp); intrinsic_GetStringDataProperty(JSContext* cx, unsigned argc, Value* vp);
/* /*
@@ -73,67 +73,67 @@ intrinsic_GetStringDataProperty(JSContext* cx, unsigned argc, Value* vp);
* Must be called without |new|. * Must be called without |new|.
* Dedicated function for RegExp.prototype[@@split] optimized path. * Dedicated function for RegExp.prototype[@@split] optimized path.
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_construct_raw_flags(JSContext* cx, unsigned argc, Value* vp); regexp_construct_raw_flags(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Clone given RegExp object, inheriting pattern and flags, ignoring other * Clone given RegExp object, inheriting pattern and flags, ignoring other
* properties. * properties.
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_clone(JSContext* cx, unsigned argc, Value* vp); regexp_clone(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
IsRegExp(JSContext* cx, HandleValue value, bool* result); IsRegExp(JSContext* cx, HandleValue value, bool* result);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpCreate(JSContext* cx, HandleValue pattern, HandleValue flags, MutableHandleValue rval); RegExpCreate(JSContext* cx, HandleValue pattern, HandleValue flags, MutableHandleValue rval);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpPrototypeOptimizable(JSContext* cx, unsigned argc, Value* vp); RegExpPrototypeOptimizable(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpPrototypeOptimizableRaw(JSContext* cx, JSObject* proto); RegExpPrototypeOptimizableRaw(JSContext* cx, JSObject* proto);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpInstanceOptimizable(JSContext* cx, unsigned argc, Value* vp); RegExpInstanceOptimizable(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpInstanceOptimizableRaw(JSContext* cx, JSObject* obj, JSObject* proto); RegExpInstanceOptimizableRaw(JSContext* cx, JSObject* obj, JSObject* proto);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
RegExpGetSubstitution(JSContext* cx, HandleArrayObject matchResult, HandleLinearString string, RegExpGetSubstitution(JSContext* cx, HandleArrayObject matchResult, HandleLinearString string,
size_t position, HandleLinearString replacement, size_t firstDollarIndex, size_t position, HandleLinearString replacement, size_t firstDollarIndex,
HandleValue namedCaptures, MutableHandleValue rval); HandleValue namedCaptures, MutableHandleValue rval);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
GetFirstDollarIndex(JSContext* cx, unsigned argc, Value* vp); GetFirstDollarIndex(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
GetFirstDollarIndexRaw(JSContext* cx, HandleString str, int32_t* index); GetFirstDollarIndexRaw(JSContext* cx, HandleString str, int32_t* index);
extern int32_t extern int32_t
GetFirstDollarIndexRawFlat(JSLinearString* text); GetFirstDollarIndexRawFlat(JSLinearString* text);
// RegExp ClassSpec members used in RegExpObject.cpp. // RegExp ClassSpec members used in RegExpObject.cpp.
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_construct(JSContext* cx, unsigned argc, Value* vp); regexp_construct(JSContext* cx, unsigned argc, Value* vp);
extern const JSPropertySpec regexp_static_props[]; extern const JSPropertySpec regexp_static_props[];
extern const JSPropertySpec regexp_properties[]; extern const JSPropertySpec regexp_properties[];
extern const JSFunctionSpec regexp_methods[]; extern const JSFunctionSpec regexp_methods[];
// Used in RegExpObject::isOriginalFlagGetter. // Used in RegExpObject::isOriginalFlagGetter.
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_global(JSContext* cx, unsigned argc, JS::Value* vp); regexp_global(JSContext* cx, unsigned argc, JS::Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_ignoreCase(JSContext* cx, unsigned argc, JS::Value* vp); regexp_ignoreCase(JSContext* cx, unsigned argc, JS::Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_multiline(JSContext* cx, unsigned argc, JS::Value* vp); regexp_multiline(JSContext* cx, unsigned argc, JS::Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_sticky(JSContext* cx, unsigned argc, JS::Value* vp); regexp_sticky(JSContext* cx, unsigned argc, JS::Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_unicode(JSContext* cx, unsigned argc, JS::Value* vp); regexp_unicode(JSContext* cx, unsigned argc, JS::Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
regexp_dotAll(JSContext* cx, unsigned argc, JS::Value* vp); regexp_dotAll(JSContext* cx, unsigned argc, JS::Value* vp);
} /* namespace js */ } /* namespace js */
+147 -147
View File
File diff suppressed because it is too large. Load diff
+26 -26
View File
@@ -37,31 +37,31 @@ class ReadableStream : public NativeObject
JS::ReadableStreamMode mode() const; JS::ReadableStreamMode mode() const;
static MOZ_MUST_USE bool close(JSContext* cx, Handle<ReadableStream*> stream); [[nodiscard]] static bool close(JSContext* cx, Handle<ReadableStream*> stream);
static MOZ_MUST_USE JSObject* cancel(JSContext* cx, Handle<ReadableStream*> stream, [[nodiscard]] static JSObject* cancel(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue reason); HandleValue reason);
static MOZ_MUST_USE bool error(JSContext* cx, Handle<ReadableStream*> stream, [[nodiscard]] static bool error(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue error); HandleValue error);
static MOZ_MUST_USE NativeObject* getReader(JSContext* cx, Handle<ReadableStream*> stream, [[nodiscard]] static NativeObject* getReader(JSContext* cx, Handle<ReadableStream*> stream,
JS::ReadableStreamReaderMode mode); JS::ReadableStreamReaderMode mode);
static MOZ_MUST_USE bool tee(JSContext* cx, [[nodiscard]] static bool tee(JSContext* cx,
Handle<ReadableStream*> stream, bool cloneForBranch2, Handle<ReadableStream*> stream, bool cloneForBranch2,
MutableHandle<ReadableStream*> branch1Stream, MutableHandle<ReadableStream*> branch1Stream,
MutableHandle<ReadableStream*> branch2Stream); MutableHandle<ReadableStream*> branch2Stream);
static MOZ_MUST_USE bool enqueue(JSContext* cx, Handle<ReadableStream*> stream, [[nodiscard]] static bool enqueue(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue chunk); HandleValue chunk);
static MOZ_MUST_USE bool enqueueBuffer(JSContext* cx, Handle<ReadableStream*> stream, [[nodiscard]] static bool enqueueBuffer(JSContext* cx, Handle<ReadableStream*> stream,
Handle<ArrayBufferObject*> chunk); Handle<ArrayBufferObject*> chunk);
static MOZ_MUST_USE bool getExternalSource(JSContext* cx, Handle<ReadableStream*> stream, [[nodiscard]] static bool getExternalSource(JSContext* cx, Handle<ReadableStream*> stream,
void** source); void** source);
void releaseExternalSource(); void releaseExternalSource();
uint8_t embeddingFlags() const; uint8_t embeddingFlags() const;
static MOZ_MUST_USE bool updateDataAvailableFromSource(JSContext* cx, [[nodiscard]] static bool updateDataAvailableFromSource(JSContext* cx,
Handle<ReadableStream*> stream, Handle<ReadableStream*> stream,
uint32_t availableData); uint32_t availableData);
enum State { enum State {
Readable = 1 << 0, Readable = 1 << 0,
@@ -71,7 +71,7 @@ class ReadableStream : public NativeObject
}; };
private: private:
static MOZ_MUST_USE ReadableStream* createStream(JSContext* cx, HandleObject proto = nullptr); [[nodiscard]] static ReadableStream* createStream(JSContext* cx, HandleObject proto = nullptr);
public: public:
static bool constructor(JSContext* cx, unsigned argc, Value* vp); static bool constructor(JSContext* cx, unsigned argc, Value* vp);
@@ -84,7 +84,7 @@ class ReadableStream : public NativeObject
class ReadableStreamDefaultReader : public NativeObject class ReadableStreamDefaultReader : public NativeObject
{ {
public: public:
static MOZ_MUST_USE JSObject* read(JSContext* cx, Handle<ReadableStreamDefaultReader*> reader); [[nodiscard]] static JSObject* read(JSContext* cx, Handle<ReadableStreamDefaultReader*> reader);
static bool constructor(JSContext* cx, unsigned argc, Value* vp); static bool constructor(JSContext* cx, unsigned argc, Value* vp);
static const ClassSpec classSpec_; static const ClassSpec classSpec_;
@@ -96,8 +96,8 @@ class ReadableStreamDefaultReader : public NativeObject
class ReadableStreamBYOBReader : public NativeObject class ReadableStreamBYOBReader : public NativeObject
{ {
public: public:
static MOZ_MUST_USE JSObject* read(JSContext* cx, Handle<ReadableStreamBYOBReader*> reader, [[nodiscard]] static JSObject* read(JSContext* cx, Handle<ReadableStreamBYOBReader*> reader,
Handle<ArrayBufferViewObject*> view); Handle<ArrayBufferViewObject*> view);
static bool constructor(JSContext* cx, unsigned argc, Value* vp); static bool constructor(JSContext* cx, unsigned argc, Value* vp);
static const ClassSpec classSpec_; static const ClassSpec classSpec_;
@@ -108,10 +108,10 @@ class ReadableStreamBYOBReader : public NativeObject
bool ReadableStreamReaderIsClosed(const JSObject* reader); bool ReadableStreamReaderIsClosed(const JSObject* reader);
MOZ_MUST_USE bool ReadableStreamReaderCancel(JSContext* cx, HandleObject reader, [[nodiscard]] bool ReadableStreamReaderCancel(JSContext* cx, HandleObject reader,
HandleValue reason); HandleValue reason);
MOZ_MUST_USE bool ReadableStreamReaderReleaseLock(JSContext* cx, HandleObject reader); [[nodiscard]] bool ReadableStreamReaderReleaseLock(JSContext* cx, HandleObject reader);
class ReadableStreamDefaultController : public NativeObject class ReadableStreamDefaultController : public NativeObject
{ {
+10 -10
View File
@@ -38,22 +38,22 @@ class SymbolObject : public NativeObject
setFixedSlot(PRIMITIVE_VALUE_SLOT, SymbolValue(symbol)); setFixedSlot(PRIMITIVE_VALUE_SLOT, SymbolValue(symbol));
} }
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); static [[nodiscard]] bool construct(JSContext* cx, unsigned argc, Value* vp);
// Static methods. // Static methods.
static MOZ_MUST_USE bool for_(JSContext* cx, unsigned argc, Value* vp); static [[nodiscard]] bool for_(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool keyFor(JSContext* cx, unsigned argc, Value* vp); static [[nodiscard]] bool keyFor(JSContext* cx, unsigned argc, Value* vp);
// Methods defined on Symbol.prototype. // Methods defined on Symbol.prototype.
static MOZ_MUST_USE bool toString_impl(JSContext* cx, const CallArgs& args); static [[nodiscard]] bool toString_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool toString(JSContext* cx, unsigned argc, Value* vp); static [[nodiscard]] bool toString(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool valueOf_impl(JSContext* cx, const CallArgs& args); static [[nodiscard]] bool valueOf_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool valueOf(JSContext* cx, unsigned argc, Value* vp); static [[nodiscard]] bool valueOf(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool toPrimitive(JSContext* cx, unsigned argc, Value* vp); static [[nodiscard]] bool toPrimitive(JSContext* cx, unsigned argc, Value* vp);
// Properties defined on Symbol.prototype. // Properties defined on Symbol.prototype.
static MOZ_MUST_USE bool descriptionGetter_impl(JSContext* cx, const CallArgs& args); static [[nodiscard]] bool descriptionGetter_impl(JSContext* cx, const CallArgs& args);
static MOZ_MUST_USE bool descriptionGetter(JSContext* cx, unsigned argc, Value *vp); static [[nodiscard]] bool descriptionGetter(JSContext* cx, unsigned argc, Value *vp);
static const JSPropertySpec properties[]; static const JSPropertySpec properties[];
static const JSFunctionSpec methods[]; static const JSFunctionSpec methods[];
+3 -3
View File
@@ -10,13 +10,13 @@
namespace js { namespace js {
MOZ_MUST_USE bool [[nodiscard]] bool
DefineTestingFunctions(JSContext* cx, HandleObject obj, bool fuzzingSafe, bool disableOOMFunctions); DefineTestingFunctions(JSContext* cx, HandleObject obj, bool fuzzingSafe, bool disableOOMFunctions);
MOZ_MUST_USE bool [[nodiscard]] bool
testingFunc_assertFloat32(JSContext* cx, unsigned argc, Value* vp); testingFunc_assertFloat32(JSContext* cx, unsigned argc, Value* vp);
MOZ_MUST_USE bool [[nodiscard]] bool
testingFunc_assertRecoveredOnBailout(JSContext* cx, unsigned argc, Value* vp); testingFunc_assertRecoveredOnBailout(JSContext* cx, unsigned argc, Value* vp);
} /* namespace js */ } /* namespace js */
+59 -59
View File
@@ -176,7 +176,7 @@ class TypeDescr : public NativeObject
} }
// Whether id is an 'own' property of objects with this descriptor. // Whether id is an 'own' property of objects with this descriptor.
MOZ_MUST_USE bool hasProperty(const JSAtomState& names, jsid id); [[nodiscard]] bool hasProperty(const JSAtomState& names, jsid id);
// Type descriptors may contain a list of their references for use during // Type descriptors may contain a list of their references for use during
// scanning. Marking code is optimized to use this list to mark inline // scanning. Marking code is optimized to use this list to mark inline
@@ -188,7 +188,7 @@ class TypeDescr : public NativeObject
// The list is three consecutive arrays of int32_t offsets, with each array // The list is three consecutive arrays of int32_t offsets, with each array
// terminated by -1. The arrays store offsets of string, object, and value // terminated by -1. The arrays store offsets of string, object, and value
// references in the descriptor, in that order. // references in the descriptor, in that order.
MOZ_MUST_USE bool hasTraceList() const { [[nodiscard]] bool hasTraceList() const {
return !getFixedSlot(JS_DESCR_SLOT_TRACE_LIST).isUndefined(); return !getFixedSlot(JS_DESCR_SLOT_TRACE_LIST).isUndefined();
} }
const int32_t* traceList() const { const int32_t* traceList() const {
@@ -257,7 +257,7 @@ class ScalarTypeDescr : public SimpleTypeDescr
return Type(getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32()); return Type(getReservedSlot(JS_DESCR_SLOT_TYPE).toInt32());
} }
static MOZ_MUST_USE bool call(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool call(JSContext* cx, unsigned argc, Value* vp);
}; };
// Enumerates the cases of ScalarTypeDescr::Type which have // Enumerates the cases of ScalarTypeDescr::Type which have
@@ -310,7 +310,7 @@ class ReferenceTypeDescr : public SimpleTypeDescr
return typeName(type()); return typeName(type());
} }
static MOZ_MUST_USE bool call(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool call(JSContext* cx, unsigned argc, Value* vp);
}; };
#define JS_FOR_EACH_REFERENCE_TYPE_REPR(macro_) \ #define JS_FOR_EACH_REFERENCE_TYPE_REPR(macro_) \
@@ -333,7 +333,7 @@ class ComplexTypeDescr : public TypeDescr
bool IsTypedObjectClass(const Class* clasp); // Defined below bool IsTypedObjectClass(const Class* clasp); // Defined below
bool IsTypedObjectArray(JSObject& obj); bool IsTypedObjectArray(JSObject& obj);
MOZ_MUST_USE bool CreateUserSizeAndAlignmentProperties(JSContext* cx, HandleTypeDescr obj); [[nodiscard]] bool CreateUserSizeAndAlignmentProperties(JSContext* cx, HandleTypeDescr obj);
class ArrayTypeDescr; class ArrayTypeDescr;
@@ -371,7 +371,7 @@ class ArrayMetaTypeDescr : public NativeObject
// This is the function that gets called when the user // This is the function that gets called when the user
// does `new ArrayType(elem)`. It produces an array type object. // does `new ArrayType(elem)`. It produces an array type object.
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
}; };
/* /*
@@ -422,7 +422,7 @@ class StructMetaTypeDescr : public NativeObject
// This is the function that gets called when the user // This is the function that gets called when the user
// does `new StructType(...)`. It produces a struct type object. // does `new StructType(...)`. It produces a struct type object.
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
}; };
class StructTypeDescr : public ComplexTypeDescr class StructTypeDescr : public ComplexTypeDescr
@@ -435,7 +435,7 @@ class StructTypeDescr : public ComplexTypeDescr
// Set `*out` to the index of the field named `id` and returns true, // Set `*out` to the index of the field named `id` and returns true,
// or return false if no such field exists. // or return false if no such field exists.
MOZ_MUST_USE bool fieldIndex(jsid id, size_t* out) const; [[nodiscard]] bool fieldIndex(jsid id, size_t* out) const;
// Return the name of the field at index `index`. // Return the name of the field at index `index`.
JSAtom& fieldName(size_t index) const; JSAtom& fieldName(size_t index) const;
@@ -475,45 +475,45 @@ class TypedObject : public ShapedObject
{ {
static const bool IsTypedObjectClass = true; static const bool IsTypedObjectClass = true;
static MOZ_MUST_USE bool obj_getArrayElement(JSContext* cx, [[nodiscard]] static bool obj_getArrayElement(JSContext* cx,
Handle<TypedObject*> typedObj, Handle<TypedObject*> typedObj,
Handle<TypeDescr*> typeDescr, Handle<TypeDescr*> typeDescr,
uint32_t index, uint32_t index,
MutableHandleValue vp); MutableHandleValue vp);
protected: protected:
static const ObjectOps objectOps_; static const ObjectOps objectOps_;
static MOZ_MUST_USE bool obj_lookupProperty(JSContext* cx, HandleObject obj, [[nodiscard]] static bool obj_lookupProperty(JSContext* cx, HandleObject obj,
HandleId id, MutableHandleObject objp, HandleId id, MutableHandleObject objp,
MutableHandle<PropertyResult> propp); MutableHandle<PropertyResult> propp);
static MOZ_MUST_USE bool obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id, [[nodiscard]] static bool obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<PropertyDescriptor> desc, Handle<PropertyDescriptor> desc,
ObjectOpResult& result); ObjectOpResult& result);
static MOZ_MUST_USE bool obj_hasProperty(JSContext* cx, HandleObject obj, HandleId id, [[nodiscard]] static bool obj_hasProperty(JSContext* cx, HandleObject obj, HandleId id,
bool* foundp); bool* foundp);
static MOZ_MUST_USE bool obj_getProperty(JSContext* cx, HandleObject obj, HandleValue receiver, [[nodiscard]] static bool obj_getProperty(JSContext* cx, HandleObject obj, HandleValue receiver,
HandleId id, MutableHandleValue vp); HandleId id, MutableHandleValue vp);
static MOZ_MUST_USE bool obj_getElement(JSContext* cx, HandleObject obj, HandleValue receiver, [[nodiscard]] static bool obj_getElement(JSContext* cx, HandleObject obj, HandleValue receiver,
uint32_t index, MutableHandleValue vp); uint32_t index, MutableHandleValue vp);
static MOZ_MUST_USE bool obj_setProperty(JSContext* cx, HandleObject obj, HandleId id, [[nodiscard]] static bool obj_setProperty(JSContext* cx, HandleObject obj, HandleId id,
HandleValue v, HandleValue receiver, HandleValue v, HandleValue receiver,
ObjectOpResult& result); ObjectOpResult& result);
static MOZ_MUST_USE bool obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj, [[nodiscard]] static bool obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj,
HandleId id, HandleId id,
MutableHandle<PropertyDescriptor> desc); MutableHandle<PropertyDescriptor> desc);
static MOZ_MUST_USE bool obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId id, [[nodiscard]] static bool obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId id,
ObjectOpResult& result); ObjectOpResult& result);
static MOZ_MUST_USE bool obj_enumerate(JSContext* cx, HandleObject obj, [[nodiscard]] static bool obj_enumerate(JSContext* cx, HandleObject obj,
AutoIdVector& properties, bool enumerableOnly); AutoIdVector& properties, bool enumerableOnly);
uint8_t* typedMem() const; uint8_t* typedMem() const;
@@ -548,7 +548,7 @@ class TypedObject : public ShapedObject
return typedMem(nogc) + offset; return typedMem(nogc) + offset;
} }
inline MOZ_MUST_USE bool opaque() const; [[nodiscard]] inline bool opaque() const;
// Creates a new typed object whose memory is freshly allocated and // Creates a new typed object whose memory is freshly allocated and
// initialized with zeroes (or, in the case of references, an appropriate // initialized with zeroes (or, in the case of references, an appropriate
@@ -558,11 +558,11 @@ class TypedObject : public ShapedObject
// User-accessible constructor (`new TypeDescriptor(...)`). Note that the // User-accessible constructor (`new TypeDescriptor(...)`). Note that the
// callee here is the type descriptor. // callee here is the type descriptor.
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
/* Accessors for self hosted code. */ /* Accessors for self hosted code. */
static MOZ_MUST_USE bool GetBuffer(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool GetBuffer(JSContext* cx, unsigned argc, Value* vp);
static MOZ_MUST_USE bool GetByteOffset(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool GetByteOffset(JSContext* cx, unsigned argc, Value* vp);
Shape** addressOfShapeFromGC() { return shape_.unsafeUnbarrieredForTracing(); } Shape** addressOfShapeFromGC() { return shape_.unsafeUnbarrieredForTracing(); }
}; };
@@ -733,14 +733,14 @@ class InlineOpaqueTypedObject : public InlineTypedObject
* *
* Constructs a new, unattached instance of `Handle`. * Constructs a new, unattached instance of `Handle`.
*/ */
MOZ_MUST_USE bool NewOpaqueTypedObject(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool NewOpaqueTypedObject(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: NewDerivedTypedObject(typeObj, owner, offset) * Usage: NewDerivedTypedObject(typeObj, owner, offset)
* *
* Constructs a new, unattached instance of `Handle`. * Constructs a new, unattached instance of `Handle`.
*/ */
MOZ_MUST_USE bool NewDerivedTypedObject(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool NewDerivedTypedObject(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: AttachTypedObject(typedObj, newDatum, newOffset) * Usage: AttachTypedObject(typedObj, newDatum, newOffset)
@@ -748,7 +748,7 @@ MOZ_MUST_USE bool NewDerivedTypedObject(JSContext* cx, unsigned argc, Value* vp)
* Moves `typedObj` to point at the memory referenced by `newDatum` with * Moves `typedObj` to point at the memory referenced by `newDatum` with
* the offset `newOffset`. * the offset `newOffset`.
*/ */
MOZ_MUST_USE bool AttachTypedObject(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool AttachTypedObject(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: SetTypedObjectOffset(typedObj, offset) * Usage: SetTypedObjectOffset(typedObj, offset)
@@ -756,41 +756,41 @@ MOZ_MUST_USE bool AttachTypedObject(JSContext* cx, unsigned argc, Value* vp);
* Changes the offset for `typedObj` within its buffer to `offset`. * Changes the offset for `typedObj` within its buffer to `offset`.
* `typedObj` must already be attached. * `typedObj` must already be attached.
*/ */
MOZ_MUST_USE bool SetTypedObjectOffset(JSContext*, unsigned argc, Value* vp); [[nodiscard]] bool SetTypedObjectOffset(JSContext*, unsigned argc, Value* vp);
/* /*
* Usage: ObjectIsTypeDescr(obj) * Usage: ObjectIsTypeDescr(obj)
* *
* True if `obj` is a type object. * True if `obj` is a type object.
*/ */
MOZ_MUST_USE bool ObjectIsTypeDescr(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool ObjectIsTypeDescr(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: ObjectIsTypedObject(obj) * Usage: ObjectIsTypedObject(obj)
* *
* True if `obj` is a transparent or opaque typed object. * True if `obj` is a transparent or opaque typed object.
*/ */
MOZ_MUST_USE bool ObjectIsTypedObject(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool ObjectIsTypedObject(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: ObjectIsOpaqueTypedObject(obj) * Usage: ObjectIsOpaqueTypedObject(obj)
* *
* True if `obj` is an opaque typed object. * True if `obj` is an opaque typed object.
*/ */
MOZ_MUST_USE bool ObjectIsOpaqueTypedObject(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool ObjectIsOpaqueTypedObject(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: ObjectIsTransparentTypedObject(obj) * Usage: ObjectIsTransparentTypedObject(obj)
* *
* True if `obj` is a transparent typed object. * True if `obj` is a transparent typed object.
*/ */
MOZ_MUST_USE bool ObjectIsTransparentTypedObject(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool ObjectIsTransparentTypedObject(JSContext* cx, unsigned argc, Value* vp);
/* Predicates on type descriptor objects. In all cases, 'obj' must be a type descriptor. */ /* Predicates on type descriptor objects. In all cases, 'obj' must be a type descriptor. */
MOZ_MUST_USE bool TypeDescrIsSimpleType(JSContext*, unsigned argc, Value* vp); [[nodiscard]] bool TypeDescrIsSimpleType(JSContext*, unsigned argc, Value* vp);
MOZ_MUST_USE bool TypeDescrIsArrayType(JSContext*, unsigned argc, Value* vp); [[nodiscard]] bool TypeDescrIsArrayType(JSContext*, unsigned argc, Value* vp);
/* /*
* Usage: TypedObjectIsAttached(obj) * Usage: TypedObjectIsAttached(obj)
@@ -798,21 +798,21 @@ MOZ_MUST_USE bool TypeDescrIsArrayType(JSContext*, unsigned argc, Value* vp);
* Given a TypedObject `obj`, returns true if `obj` is * Given a TypedObject `obj`, returns true if `obj` is
* "attached" (i.e., its data pointer is nullptr). * "attached" (i.e., its data pointer is nullptr).
*/ */
MOZ_MUST_USE bool TypedObjectIsAttached(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool TypedObjectIsAttached(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: TypedObjectTypeDescr(obj) * Usage: TypedObjectTypeDescr(obj)
* *
* Given a TypedObject `obj`, returns the object's type descriptor. * Given a TypedObject `obj`, returns the object's type descriptor.
*/ */
MOZ_MUST_USE bool TypedObjectTypeDescr(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool TypedObjectTypeDescr(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: ClampToUint8(v) * Usage: ClampToUint8(v)
* *
* Same as the C function ClampDoubleToUint8. `v` must be a number. * Same as the C function ClampDoubleToUint8. `v` must be a number.
*/ */
MOZ_MUST_USE bool ClampToUint8(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool ClampToUint8(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: GetTypedObjectModule() * Usage: GetTypedObjectModule()
@@ -823,7 +823,7 @@ MOZ_MUST_USE bool ClampToUint8(JSContext* cx, unsigned argc, Value* vp);
* to access them; eventually this should be linked into the module * to access them; eventually this should be linked into the module
* system. * system.
*/ */
MOZ_MUST_USE bool GetTypedObjectModule(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool GetTypedObjectModule(JSContext* cx, unsigned argc, Value* vp);
/* /*
* Usage: Store_int8(targetDatum, targetOffset, value) * Usage: Store_int8(targetDatum, targetOffset, value)
@@ -844,7 +844,7 @@ MOZ_MUST_USE bool GetTypedObjectModule(JSContext* cx, unsigned argc, Value* vp);
#define JS_STORE_SCALAR_CLASS_DEFN(_constant, T, _name) \ #define JS_STORE_SCALAR_CLASS_DEFN(_constant, T, _name) \
class StoreScalar##T { \ class StoreScalar##T { \
public: \ public: \
static MOZ_MUST_USE bool Func(JSContext* cx, unsigned argc, Value* vp); \ [[nodiscard]] static bool Func(JSContext* cx, unsigned argc, Value* vp); \
static const JSJitInfo JitInfo; \ static const JSJitInfo JitInfo; \
}; };
@@ -864,11 +864,11 @@ class StoreScalar##T { \
#define JS_STORE_REFERENCE_CLASS_DEFN(_constant, T, _name) \ #define JS_STORE_REFERENCE_CLASS_DEFN(_constant, T, _name) \
class StoreReference##_name { \ class StoreReference##_name { \
private: \ private: \
static MOZ_MUST_USE bool store(JSContext* cx, T* heap, const Value& v, \ [[nodiscard]] static bool store(JSContext* cx, T* heap, const Value& v, \
TypedObject* obj, jsid id); \ TypedObject* obj, jsid id); \
\ \
public: \ public: \
static MOZ_MUST_USE bool Func(JSContext* cx, unsigned argc, Value* vp); \ [[nodiscard]] static bool Func(JSContext* cx, unsigned argc, Value* vp); \
static const JSJitInfo JitInfo; \ static const JSJitInfo JitInfo; \
}; };
@@ -883,7 +883,7 @@ class StoreReference##_name { \
#define JS_LOAD_SCALAR_CLASS_DEFN(_constant, T, _name) \ #define JS_LOAD_SCALAR_CLASS_DEFN(_constant, T, _name) \
class LoadScalar##T { \ class LoadScalar##T { \
public: \ public: \
static MOZ_MUST_USE bool Func(JSContext* cx, unsigned argc, Value* vp); \ [[nodiscard]] static bool Func(JSContext* cx, unsigned argc, Value* vp); \
static const JSJitInfo JitInfo; \ static const JSJitInfo JitInfo; \
}; };
@@ -901,7 +901,7 @@ class LoadReference##_name { \
static void load(T* heap, MutableHandleValue v); \ static void load(T* heap, MutableHandleValue v); \
\ \
public: \ public: \
static MOZ_MUST_USE bool Func(JSContext* cx, unsigned argc, Value* vp); \ [[nodiscard]] static bool Func(JSContext* cx, unsigned argc, Value* vp); \
static const JSJitInfo JitInfo; \ static const JSJitInfo JitInfo; \
}; };
+1 -1
View File
@@ -23,7 +23,7 @@ class WeakSetObject : public NativeObject
static const JSFunctionSpec methods[]; static const JSFunctionSpec methods[];
static WeakSetObject* create(JSContext* cx, HandleObject proto = nullptr); static WeakSetObject* create(JSContext* cx, HandleObject proto = nullptr);
static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp);
static bool isBuiltinAdd(HandleValue add, JSContext* cx); static bool isBuiltinAdd(HandleValue add, JSContext* cx);
}; };
+4 -4
View File
@@ -49,7 +49,7 @@ CreateCollatorPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
* *
* Usage: collator = intl_Collator(locales, options) * Usage: collator = intl_Collator(locales, options)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_Collator(JSContext* cx, unsigned argc, Value* vp); intl_Collator(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -60,7 +60,7 @@ intl_Collator(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: collations = intl_availableCollations(locale) * Usage: collations = intl_availableCollations(locale)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_availableCollations(JSContext* cx, unsigned argc, Value* vp); intl_availableCollations(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -73,7 +73,7 @@ intl_availableCollations(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: result = intl_CompareStrings(collator, x, y) * Usage: result = intl_CompareStrings(collator, x, y)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_CompareStrings(JSContext* cx, unsigned argc, Value* vp); intl_CompareStrings(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -82,7 +82,7 @@ intl_CompareStrings(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: result = intl_isUpperCaseFirst(locale) * Usage: result = intl_isUpperCaseFirst(locale)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_isUpperCaseFirst(JSContext* cx, unsigned argc, Value* vp); intl_isUpperCaseFirst(JSContext* cx, unsigned argc, Value* vp);
+10 -10
View File
@@ -51,7 +51,7 @@ CreateDateTimeFormatPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
* *
* Usage: dateTimeFormat = intl_DateTimeFormat(locales, options) * Usage: dateTimeFormat = intl_DateTimeFormat(locales, options)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_DateTimeFormat(JSContext* cx, unsigned argc, Value* vp); intl_DateTimeFormat(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -62,7 +62,7 @@ intl_DateTimeFormat(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: calendars = intl_availableCalendars(locale) * Usage: calendars = intl_availableCalendars(locale)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp); intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -72,7 +72,7 @@ intl_availableCalendars(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: calendar = intl_defaultCalendar(locale) * Usage: calendar = intl_defaultCalendar(locale)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_defaultCalendar(JSContext* cx, unsigned argc, Value* vp); intl_defaultCalendar(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -85,7 +85,7 @@ intl_defaultCalendar(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: ianaTimeZone = intl_IsValidTimeZoneName(timeZone) * Usage: ianaTimeZone = intl_IsValidTimeZoneName(timeZone)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_IsValidTimeZoneName(JSContext* cx, unsigned argc, Value* vp); intl_IsValidTimeZoneName(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -94,7 +94,7 @@ intl_IsValidTimeZoneName(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: ianaTimeZone = intl_canonicalizeTimeZone(timeZone) * Usage: ianaTimeZone = intl_canonicalizeTimeZone(timeZone)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_canonicalizeTimeZone(JSContext* cx, unsigned argc, Value* vp); intl_canonicalizeTimeZone(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -102,7 +102,7 @@ intl_canonicalizeTimeZone(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: icuDefaultTimeZone = intl_defaultTimeZone() * Usage: icuDefaultTimeZone = intl_defaultTimeZone()
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_defaultTimeZone(JSContext* cx, unsigned argc, Value* vp); intl_defaultTimeZone(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -110,7 +110,7 @@ intl_defaultTimeZone(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: defaultTimeZoneOffset = intl_defaultTimeZoneOffset() * Usage: defaultTimeZoneOffset = intl_defaultTimeZoneOffset()
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_defaultTimeZoneOffset(JSContext* cx, unsigned argc, Value* vp); intl_defaultTimeZoneOffset(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -121,7 +121,7 @@ intl_defaultTimeZoneOffset(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: pattern = intl_patternForSkeleton(locale, skeleton, hourCycle) * Usage: pattern = intl_patternForSkeleton(locale, skeleton, hourCycle)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp); intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -155,7 +155,7 @@ intl_patternForSkeleton(JSContext* cx, unsigned argc, Value* vp);
* Usage: pattern = intl_patternForStyle(locale, dateStyle, timeStyle, timeZone, * Usage: pattern = intl_patternForStyle(locale, dateStyle, timeStyle, timeZone,
* hour12, hourCycle) * hour12, hourCycle)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_patternForStyle(JSContext* cx, unsigned argc, Value* vp); intl_patternForStyle(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -167,7 +167,7 @@ intl_patternForStyle(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: formatted = intl_FormatDateTime(dateTimeFormat, x, formatToParts) * Usage: formatted = intl_FormatDateTime(dateTimeFormat, x, formatToParts)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp); intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp);
+4 -4
View File
@@ -50,7 +50,7 @@ InitIntlClass(JSContext* cx, JS::Handle<JSObject*> obj);
* *
* NOTE: "calendar" and "locale" properties are *not* added to the object. * NOTE: "calendar" and "locale" properties are *not* added to the object.
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_GetCalendarInfo(JSContext* cx, unsigned argc, JS::Value* vp); intl_GetCalendarInfo(JSContext* cx, unsigned argc, JS::Value* vp);
/** /**
@@ -92,7 +92,7 @@ intl_GetCalendarInfo(JSContext* cx, unsigned argc, JS::Value* vp);
* 'AM' * 'AM'
* ] * ]
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_ComputeDisplayNames(JSContext* cx, unsigned argc, JS::Value* vp); intl_ComputeDisplayNames(JSContext* cx, unsigned argc, JS::Value* vp);
/** /**
@@ -111,7 +111,7 @@ intl_ComputeDisplayNames(JSContext* cx, unsigned argc, JS::Value* vp);
* *
* Usage: result = intl_BestAvailableLocale("Collator", locale, defaultOrNull) * Usage: result = intl_BestAvailableLocale("Collator", locale, defaultOrNull)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_BestAvailableLocale(JSContext* cx, unsigned argc, JS::Value* vp); intl_BestAvailableLocale(JSContext* cx, unsigned argc, JS::Value* vp);
/** /**
@@ -121,7 +121,7 @@ intl_BestAvailableLocale(JSContext* cx, unsigned argc, JS::Value* vp);
* *
* Usage: result = intl_supportedLocaleOrFallback(locale) * Usage: result = intl_supportedLocaleOrFallback(locale)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_supportedLocaleOrFallback(JSContext* cx, unsigned argc, JS::Value* vp); intl_supportedLocaleOrFallback(JSContext* cx, unsigned argc, JS::Value* vp);
} // namespace js } // namespace js
+6 -6
View File
@@ -220,9 +220,9 @@ class MOZ_STACK_CLASS LanguageTag final {
void performComplexLanguageMappings(); void performComplexLanguageMappings();
void performComplexRegionMappings(); void performComplexRegionMappings();
MOZ_MUST_USE bool performVariantMappings(JSContext* cx); [[nodiscard]] bool performVariantMappings(JSContext* cx);
MOZ_MUST_USE bool updateGrandfatheredMappings(JSContext* cx); [[nodiscard]] bool updateGrandfatheredMappings(JSContext* cx);
static const char* replaceTransformExtensionType( static const char* replaceTransformExtensionType(
mozilla::Span<const char> key, mozilla::Span<const char> type); mozilla::Span<const char> key, mozilla::Span<const char> type);
@@ -716,21 +716,21 @@ MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(LanguageTagParser::TokenKind)
* Parse a string as a standalone |language| tag. If |str| is a standalone * Parse a string as a standalone |language| tag. If |str| is a standalone
* language tag, store it in |result| and return true. Otherwise return false. * language tag, store it in |result| and return true. Otherwise return false.
*/ */
MOZ_MUST_USE bool ParseStandaloneLanguageTag(JS::Handle<JSLinearString*> str, [[nodiscard]] bool ParseStandaloneLanguageTag(JS::Handle<JSLinearString*> str,
LanguageSubtag& result); LanguageSubtag& result);
/** /**
* Parse a string as a standalone |script| tag. If |str| is a standalone script * Parse a string as a standalone |script| tag. If |str| is a standalone script
* tag, store it in |result| and return true. Otherwise return false. * tag, store it in |result| and return true. Otherwise return false.
*/ */
MOZ_MUST_USE bool ParseStandaloneScriptTag(JS::Handle<JSLinearString*> str, [[nodiscard]] bool ParseStandaloneScriptTag(JS::Handle<JSLinearString*> str,
ScriptSubtag& result); ScriptSubtag& result);
/** /**
* Parse a string as a standalone |region| tag. If |str| is a standalone region * Parse a string as a standalone |region| tag. If |str| is a standalone region
* tag, store it in |result| and return true. Otherwise return false. * tag, store it in |result| and return true. Otherwise return false.
*/ */
MOZ_MUST_USE bool ParseStandaloneRegionTag(JS::Handle<JSLinearString*> str, [[nodiscard]] bool ParseStandaloneRegionTag(JS::Handle<JSLinearString*> str,
RegionSubtag& result); RegionSubtag& result);
/** /**
@@ -759,7 +759,7 @@ class UnicodeExtensionKeyword final {
void trace(JSTracer* trc); void trace(JSTracer* trc);
}; };
extern MOZ_MUST_USE bool ApplyUnicodeExtensionToTag( [[nodiscard]] extern bool ApplyUnicodeExtensionToTag(
JSContext* cx, LanguageTag& tag, JSContext* cx, LanguageTag& tag,
JS::HandleVector<UnicodeExtensionKeyword> keywords); JS::HandleVector<UnicodeExtensionKeyword> keywords);
+5 -5
View File
@@ -48,14 +48,14 @@ extern JSObject* CreateLocalePrototype(JSContext* cx,
JS::Handle<JSObject*> Intl, JS::Handle<JSObject*> Intl,
JS::Handle<GlobalObject*> global); JS::Handle<GlobalObject*> global);
extern MOZ_MUST_USE bool intl_ValidateAndCanonicalizeLanguageTag(JSContext* cx, [[nodiscard]] extern bool intl_ValidateAndCanonicalizeLanguageTag(JSContext* cx,
unsigned argc, unsigned argc,
Value* vp); Value* vp);
extern MOZ_MUST_USE bool intl_TryValidateAndCanonicalizeLanguageTag( [[nodiscard]] extern bool intl_TryValidateAndCanonicalizeLanguageTag(
JSContext* cx, unsigned argc, Value* vp); JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool intl_ValidateAndCanonicalizeUnicodeExtensionType( [[nodiscard]] extern bool intl_ValidateAndCanonicalizeUnicodeExtensionType(
JSContext* cx, unsigned argc, Value* vp); JSContext* cx, unsigned argc, Value* vp);
} // namespace js } // namespace js
+4 -4
View File
@@ -47,7 +47,7 @@ CreateNumberFormatPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObjec
* *
* Usage: numberFormat = intl_NumberFormat(locales, options) * Usage: numberFormat = intl_NumberFormat(locales, options)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_NumberFormat(JSContext* cx, unsigned argc, Value* vp); intl_NumberFormat(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -57,7 +57,7 @@ intl_NumberFormat(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: defaultNumberingSystem = intl_numberingSystem(locale) * Usage: defaultNumberingSystem = intl_numberingSystem(locale)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_numberingSystem(JSContext* cx, unsigned argc, Value* vp); intl_numberingSystem(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -68,9 +68,9 @@ intl_numberingSystem(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: formatted = intl_FormatNumber(numberFormat, x, formatToParts) * Usage: formatted = intl_FormatNumber(numberFormat, x, formatToParts)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_FormatNumber(JSContext* cx, unsigned argc, Value* vp); intl_FormatNumber(JSContext* cx, unsigned argc, Value* vp);
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
FormatNumeric(JSContext* cx, UNumberFormat* nf, HandleValue x, MutableHandleValue result); FormatNumeric(JSContext* cx, UNumberFormat* nf, HandleValue x, MutableHandleValue result);
} // namespace js } // namespace js
+3 -3
View File
@@ -46,7 +46,7 @@ CreatePluralRulesPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
* *
* Usage: pluralRules = intl_PluralRules(locales, options) * Usage: pluralRules = intl_PluralRules(locales, options)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_PluralRules(JSContext* cx, unsigned argc, Value* vp); intl_PluralRules(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -58,7 +58,7 @@ intl_PluralRules(JSContext* cx, unsigned argc, Value* vp);
* *
* Usage: rule = intl_SelectPluralRule(pluralRules, x) * Usage: rule = intl_SelectPluralRule(pluralRules, x)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_SelectPluralRule(JSContext* cx, unsigned argc, Value* vp); intl_SelectPluralRule(JSContext* cx, unsigned argc, Value* vp);
/** /**
@@ -71,7 +71,7 @@ intl_SelectPluralRule(JSContext* cx, unsigned argc, Value* vp);
* *
* intl_getPluralCategories('pl', 'cardinal'); // ['one', 'few', 'many', 'other'] * intl_getPluralCategories('pl', 'cardinal'); // ['one', 'few', 'many', 'other']
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool
intl_GetPluralCategories(JSContext* cx, unsigned argc, Value* vp); intl_GetPluralCategories(JSContext* cx, unsigned argc, Value* vp);
} // namespace js } // namespace js
+1 -2
View File
@@ -48,8 +48,7 @@ CreateRelativeTimeFormatPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
* *
* Usage: formatted = intl_FormatRelativeTime(relativeTimeFormat, t, unit) * Usage: formatted = intl_FormatRelativeTime(relativeTimeFormat, t, unit)
*/ */
extern MOZ_MUST_USE bool [[nodiscard]] extern bool intl_FormatRelativeTime(JSContext* cx, unsigned argc, Value* vp);
intl_FormatRelativeTime(JSContext* cx, unsigned argc, Value* vp);
} // namespace js } // namespace js
+3 -3
View File
@@ -233,9 +233,9 @@ class SharedIntlData
* Sets |supported| to true if |locale| is supported by the requested Intl * Sets |supported| to true if |locale| is supported by the requested Intl
* service constructor. Otherwise sets |supported| to false. * service constructor. Otherwise sets |supported| to false.
*/ */
MOZ_MUST_USE bool isSupportedLocale(JSContext* cx, SupportedLocaleKind kind, [[nodiscard]] bool isSupportedLocale(JSContext* cx, SupportedLocaleKind kind,
JS::Handle<JSString*> locale, JS::Handle<JSString*> locale,
bool* supported); bool* supported);
private: private:
/** /**
+6 -6
View File
@@ -178,7 +178,7 @@ GetDeflatedUTF8StringLength(JSContext* maybecx, const CharT* chars,
size_t charsLength); size_t charsLength);
template <typename CharT> template <typename CharT>
MOZ_MUST_USE bool [[nodiscard]] bool
DeflateStringToUTF8Buffer(JSContext* maybecx, const CharT* src, size_t srclen, DeflateStringToUTF8Buffer(JSContext* maybecx, const CharT* src, size_t srclen,
char* dst, size_t* dstlenp); char* dst, size_t* dstlenp);
@@ -456,7 +456,7 @@ namespace CType {
TypeCode GetTypeCode(JSObject* typeObj); TypeCode GetTypeCode(JSObject* typeObj);
bool TypesEqual(JSObject* t1, JSObject* t2); bool TypesEqual(JSObject* t1, JSObject* t2);
size_t GetSize(JSObject* obj); size_t GetSize(JSObject* obj);
MOZ_MUST_USE bool GetSafeSize(JSObject* obj, size_t* result); [[nodiscard]] bool GetSafeSize(JSObject* obj, size_t* result);
bool IsSizeDefined(JSObject* obj); bool IsSizeDefined(JSObject* obj);
size_t GetAlignment(JSObject* obj); size_t GetAlignment(JSObject* obj);
ffi_type* GetFFIType(JSContext* cx, JSObject* obj); ffi_type* GetFFIType(JSContext* cx, JSObject* obj);
@@ -480,12 +480,12 @@ namespace ArrayType {
JSObject* GetBaseType(JSObject* obj); JSObject* GetBaseType(JSObject* obj);
size_t GetLength(JSObject* obj); size_t GetLength(JSObject* obj);
MOZ_MUST_USE bool GetSafeLength(JSObject* obj, size_t* result); [[nodiscard]] bool GetSafeLength(JSObject* obj, size_t* result);
UniquePtrFFIType BuildFFIType(JSContext* cx, JSObject* obj); UniquePtrFFIType BuildFFIType(JSContext* cx, JSObject* obj);
} // namespace ArrayType } // namespace ArrayType
namespace StructType { namespace StructType {
MOZ_MUST_USE bool DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj); [[nodiscard]] bool DefineInternal(JSContext* cx, JSObject* typeObj, JSObject* fieldsObj);
const FieldInfoHash* GetFieldInfo(JSObject* obj); const FieldInfoHash* GetFieldInfo(JSObject* obj);
const FieldInfo* LookupField(JSContext* cx, JSObject* obj, JSFlatString* name); const FieldInfo* LookupField(JSContext* cx, JSObject* obj, JSFlatString* name);
@@ -521,9 +521,9 @@ namespace CData {
bool IsCDataProto(JSObject* obj); bool IsCDataProto(JSObject* obj);
// Attached by JSAPI as the function 'ctypes.cast' // Attached by JSAPI as the function 'ctypes.cast'
MOZ_MUST_USE bool Cast(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool Cast(JSContext* cx, unsigned argc, Value* vp);
// Attached by JSAPI as the function 'ctypes.getRuntime' // Attached by JSAPI as the function 'ctypes.getRuntime'
MOZ_MUST_USE bool GetRuntime(JSContext* cx, unsigned argc, Value* vp); [[nodiscard]] bool GetRuntime(JSContext* cx, unsigned argc, Value* vp);
} // namespace CData } // namespace CData
namespace Int64 { namespace Int64 {
+2 -2
View File
@@ -23,14 +23,14 @@ enum LibrarySlot {
namespace Library namespace Library
{ {
MOZ_MUST_USE bool Name(JSContext* cx, unsigned argc, JS::Value* vp); [[nodiscard]] bool Name(JSContext* cx, unsigned argc, JS::Value* vp);
JSObject* Create(JSContext* cx, JS::HandleValue path, const JSCTypesCallbacks* callbacks); JSObject* Create(JSContext* cx, JS::HandleValue path, const JSCTypesCallbacks* callbacks);
bool IsLibrary(JSObject* obj); bool IsLibrary(JSObject* obj);
PRLibrary* GetLibrary(JSObject* obj); PRLibrary* GetLibrary(JSObject* obj);
MOZ_MUST_USE bool Open(JSContext* cx, unsigned argc, JS::Value* vp); [[nodiscard]] bool Open(JSContext* cx, unsigned argc, JS::Value* vp);
} // namespace Library } // namespace Library
} // namespace ctypes } // namespace ctypes
+3 -3
View File
@@ -94,7 +94,7 @@ class Fifo
// Push an element to the back of the queue. This method can take either a // Push an element to the back of the queue. This method can take either a
// |const T&| or a |T&&|. // |const T&| or a |T&&|.
template <typename U> template <typename U>
MOZ_MUST_USE bool pushBack(U&& u) { [[nodiscard]] bool pushBack(U&& u) {
if (!rear_.append(mozilla::Forward<U>(u))) if (!rear_.append(mozilla::Forward<U>(u)))
return false; return false;
if (!fixup()) { if (!fixup()) {
@@ -106,7 +106,7 @@ class Fifo
// Construct a T in-place at the back of the queue. // Construct a T in-place at the back of the queue.
template <typename... Args> template <typename... Args>
MOZ_MUST_USE bool emplaceBack(Args&&... args) { [[nodiscard]] bool emplaceBack(Args&&... args) {
if (!rear_.emplaceBack(mozilla::Forward<Args>(args)...)) if (!rear_.emplaceBack(mozilla::Forward<Args>(args)...))
return false; return false;
if (!fixup()) { if (!fixup()) {
@@ -127,7 +127,7 @@ class Fifo
} }
// Remove the front element from the queue. // Remove the front element from the queue.
MOZ_MUST_USE bool popFront() { [[nodiscard]] bool popFront() {
MOZ_ASSERT(!empty()); MOZ_ASSERT(!empty());
T t(mozilla::Move(front())); T t(mozilla::Move(front()));
front_.popBack(); front_.popBack();
+9 -9
View File
@@ -67,7 +67,7 @@ class InlineTable
return inlNext_ > InlineEntries; return inlNext_ > InlineEntries;
} }
MOZ_MUST_USE bool switchToTable() { [[nodiscard]] bool switchToTable() {
MOZ_ASSERT(inlNext_ == InlineEntries); MOZ_ASSERT(inlNext_ == InlineEntries);
if (table_.initialized()) { if (table_.initialized()) {
@@ -91,7 +91,7 @@ class InlineTable
} }
MOZ_NEVER_INLINE MOZ_NEVER_INLINE
MOZ_MUST_USE bool switchAndAdd(const InlineEntry& entry) { [[nodiscard]] bool switchAndAdd(const InlineEntry& entry) {
if (!switchToTable()) if (!switchToTable())
return false; return false;
@@ -285,7 +285,7 @@ class InlineTable
template <typename KeyInput, template <typename KeyInput,
typename... Args> typename... Args>
MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE
MOZ_MUST_USE bool add(AddPtr& p, KeyInput&& key, Args&&... args) { [[nodiscard]] bool add(AddPtr& p, KeyInput&& key, Args&&... args) {
MOZ_ASSERT(!p); MOZ_ASSERT(!p);
MOZ_ASSERT(keyNonZero(key)); MOZ_ASSERT(keyNonZero(key));
@@ -439,7 +439,7 @@ class InlineMap
this->value = mozilla::Forward<ValueInput>(value); this->value = mozilla::Forward<ValueInput>(value);
} }
MOZ_MUST_USE bool moveTo(Map& map) { [[nodiscard]] bool moveTo(Map& map) {
return map.putNew(mozilla::Move(key), mozilla::Move(value)); return map.putNew(mozilla::Move(key), mozilla::Move(value));
} }
}; };
@@ -531,12 +531,12 @@ class InlineMap
template <typename KeyInput, typename ValueInput> template <typename KeyInput, typename ValueInput>
MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE
MOZ_MUST_USE bool add(AddPtr& p, KeyInput&& key, ValueInput&& value) { [[nodiscard]] bool add(AddPtr& p, KeyInput&& key, ValueInput&& value) {
return impl_.add(p, mozilla::Forward<KeyInput>(key), mozilla::Forward<ValueInput>(value)); return impl_.add(p, mozilla::Forward<KeyInput>(key), mozilla::Forward<ValueInput>(value));
} }
template <typename KeyInput, typename ValueInput> template <typename KeyInput, typename ValueInput>
MOZ_MUST_USE bool put(KeyInput&& key, ValueInput&& value) { [[nodiscard]] bool put(KeyInput&& key, ValueInput&& value) {
AddPtr p = lookupForAdd(key); AddPtr p = lookupForAdd(key);
if (p) { if (p) {
p->value() = mozilla::Forward<ValueInput>(value); p->value() = mozilla::Forward<ValueInput>(value);
@@ -577,7 +577,7 @@ class InlineSet
this->key = mozilla::Forward<TInput>(key); this->key = mozilla::Forward<TInput>(key);
} }
MOZ_MUST_USE bool moveTo(Set& set) { [[nodiscard]] bool moveTo(Set& set) {
return set.putNew(mozilla::Move(key)); return set.putNew(mozilla::Move(key));
} }
}; };
@@ -662,12 +662,12 @@ class InlineSet
template <typename TInput> template <typename TInput>
MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE
MOZ_MUST_USE bool add(AddPtr& p, TInput&& key) { [[nodiscard]] bool add(AddPtr& p, TInput&& key) {
return impl_.add(p, mozilla::Forward<TInput>(key)); return impl_.add(p, mozilla::Forward<TInput>(key));
} }
template <typename TInput> template <typename TInput>
MOZ_MUST_USE bool put(TInput&& key) { [[nodiscard]] bool put(TInput&& key) {
AddPtr p = lookupForAdd(key); AddPtr p = lookupForAdd(key);
return p ? true : add(p, mozilla::Forward<TInput>(key)); return p ? true : add(p, mozilla::Forward<TInput>(key));
} }
+2 -2
View File
@@ -313,7 +313,7 @@ class LifoAlloc
// allocation requests, not necessarily contiguous. Note that this does // allocation requests, not necessarily contiguous. Note that this does
// not guarantee a successful single allocation of N bytes. // not guarantee a successful single allocation of N bytes.
MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE
MOZ_MUST_USE bool ensureUnusedApproximate(size_t n) { [[nodiscard]] bool ensureUnusedApproximate(size_t n) {
AutoFallibleScope fallibleAllocator(this); AutoFallibleScope fallibleAllocator(this);
size_t total = 0; size_t total = 0;
for (BumpChunk* chunk = latest; chunk; chunk = chunk->next()) { for (BumpChunk* chunk = latest; chunk; chunk = chunk->next()) {
@@ -640,7 +640,7 @@ class LifoAllocPolicy
} }
void reportAllocOverflow() const { void reportAllocOverflow() const {
} }
MOZ_MUST_USE bool checkSimulatedOOM() const { [[nodiscard]] bool checkSimulatedOOM() const {
return fb == Infallible || !js::oom::ShouldFailWithOOM(); return fb == Infallible || !js::oom::ShouldFailWithOOM();
} }
}; };
+10 -10
View File
@@ -86,7 +86,7 @@ class OrderedHashTable
OrderedHashTable(AllocPolicy& ap, mozilla::HashCodeScrambler hcs) OrderedHashTable(AllocPolicy& ap, mozilla::HashCodeScrambler hcs)
: hashTable(nullptr), data(nullptr), dataLength(0), ranges(nullptr), alloc(ap), hcs(hcs) {} : hashTable(nullptr), data(nullptr), dataLength(0), ranges(nullptr), alloc(ap), hcs(hcs) {}
MOZ_MUST_USE bool init() { [[nodiscard]] bool init() {
MOZ_ASSERT(!hashTable, "init must be called at most once"); MOZ_ASSERT(!hashTable, "init must be called at most once");
uint32_t buckets = initialBuckets(); uint32_t buckets = initialBuckets();
@@ -153,7 +153,7 @@ class OrderedHashTable
* means the element was not added to the table. * means the element was not added to the table.
*/ */
template <typename ElementInput> template <typename ElementInput>
MOZ_MUST_USE bool put(ElementInput&& element) { [[nodiscard]] bool put(ElementInput&& element) {
HashNumber h = prepareHash(Ops::getKey(element)); HashNumber h = prepareHash(Ops::getKey(element));
if (Data* e = lookup(Ops::getKey(element), h)) { if (Data* e = lookup(Ops::getKey(element), h)) {
e->element = Forward<ElementInput>(element); e->element = Forward<ElementInput>(element);
@@ -224,7 +224,7 @@ class OrderedHashTable
* particular, those Ranges are still live and will see any entries added * particular, those Ranges are still live and will see any entries added
* after a successful clear(). * after a successful clear().
*/ */
MOZ_MUST_USE bool clear() { [[nodiscard]] bool clear() {
if (dataLength != 0) { if (dataLength != 0) {
Data** oldHashTable = hashTable; Data** oldHashTable = hashTable;
Data* oldData = data; Data* oldData = data;
@@ -633,7 +633,7 @@ class OrderedHashTable
* empty elements in data[0:dataLength]. On allocation failure, this * empty elements in data[0:dataLength]. On allocation failure, this
* leaves everything as it was and returns false. * leaves everything as it was and returns false.
*/ */
MOZ_MUST_USE bool rehash(uint32_t newHashShift) { [[nodiscard]] bool rehash(uint32_t newHashShift) {
// If the size of the table is not changing, rehash in place to avoid // If the size of the table is not changing, rehash in place to avoid
// allocating memory. // allocating memory.
if (newHashShift == hashShift) { if (newHashShift == hashShift) {
@@ -746,17 +746,17 @@ class OrderedHashMap
typedef typename Impl::Range Range; typedef typename Impl::Range Range;
OrderedHashMap(AllocPolicy ap, mozilla::HashCodeScrambler hcs) : impl(ap, hcs) {} OrderedHashMap(AllocPolicy ap, mozilla::HashCodeScrambler hcs) : impl(ap, hcs) {}
MOZ_MUST_USE bool init() { return impl.init(); } [[nodiscard]] bool init() { return impl.init(); }
uint32_t count() const { return impl.count(); } uint32_t count() const { return impl.count(); }
bool has(const Key& key) const { return impl.has(key); } bool has(const Key& key) const { return impl.has(key); }
Range all() { return impl.all(); } Range all() { return impl.all(); }
const Entry* get(const Key& key) const { return impl.get(key); } const Entry* get(const Key& key) const { return impl.get(key); }
Entry* get(const Key& key) { return impl.get(key); } Entry* get(const Key& key) { return impl.get(key); }
bool remove(const Key& key, bool* foundp) { return impl.remove(key, foundp); } bool remove(const Key& key, bool* foundp) { return impl.remove(key, foundp); }
MOZ_MUST_USE bool clear() { return impl.clear(); } [[nodiscard]] bool clear() { return impl.clear(); }
template <typename V> template <typename V>
MOZ_MUST_USE bool put(const Key& key, V&& value) { [[nodiscard]] bool put(const Key& key, V&& value) {
return impl.put(Entry(key, Forward<V>(value))); return impl.put(Entry(key, Forward<V>(value)));
} }
@@ -804,13 +804,13 @@ class OrderedHashSet
typedef typename Impl::Range Range; typedef typename Impl::Range Range;
explicit OrderedHashSet(AllocPolicy ap, mozilla::HashCodeScrambler hcs) : impl(ap, hcs) {} explicit OrderedHashSet(AllocPolicy ap, mozilla::HashCodeScrambler hcs) : impl(ap, hcs) {}
MOZ_MUST_USE bool init() { return impl.init(); } [[nodiscard]] bool init() { return impl.init(); }
uint32_t count() const { return impl.count(); } uint32_t count() const { return impl.count(); }
bool has(const T& value) const { return impl.has(value); } bool has(const T& value) const { return impl.has(value); }
Range all() { return impl.all(); } Range all() { return impl.all(); }
MOZ_MUST_USE bool put(const T& value) { return impl.put(value); } [[nodiscard]] bool put(const T& value) { return impl.put(value); }
bool remove(const T& value, bool* foundp) { return impl.remove(value, foundp); } bool remove(const T& value, bool* foundp) { return impl.remove(value, foundp); }
MOZ_MUST_USE bool clear() { return impl.clear(); } [[nodiscard]] bool clear() { return impl.clear(); }
HashNumber hash(const T& value) const { return impl.prepareHash(value); } HashNumber hash(const T& value) const { return impl.prepareHash(value); }
+2 -2
View File
@@ -223,7 +223,7 @@ class PageProtectingVector final
unprotectedBytes = 0; unprotectedBytes = 0;
} }
MOZ_MUST_USE bool reserve(size_t size) { [[nodiscard]] bool reserve(size_t size) {
AutoUnprotect guard; AutoUnprotect guard;
if (size > vector.capacity()) if (size > vector.capacity())
guard.emplace(this); guard.emplace(this);
@@ -237,7 +237,7 @@ class PageProtectingVector final
} }
template<typename U> template<typename U>
MOZ_MUST_USE bool append(const U* values, size_t size) { [[nodiscard]] bool append(const U* values, size_t size) {
bool ret; bool ret;
{ {
AutoUnprotect guard; AutoUnprotect guard;
+2 -2
View File
@@ -34,7 +34,7 @@ class PriorityQueue
: heap(ap) : heap(ap)
{} {}
MOZ_MUST_USE bool reserve(size_t capacity) { [[nodiscard]] bool reserve(size_t capacity) {
return heap.reserve(capacity); return heap.reserve(capacity);
} }
@@ -56,7 +56,7 @@ class PriorityQueue
return highest; return highest;
} }
MOZ_MUST_USE bool insert(const T& v) { [[nodiscard]] bool insert(const T& v) {
if (!heap.append(v)) if (!heap.append(v))
return false; return false;
siftUp(heap.length() - 1); siftUp(heap.length() - 1);
+1 -1
View File
@@ -77,7 +77,7 @@ MergeArrayRuns(T* dst, const T* src, size_t run1, size_t run2, Comparator c)
* arbitrary. * arbitrary.
*/ */
template<typename T, typename Comparator> template<typename T, typename Comparator>
MOZ_MUST_USE bool [[nodiscard]] bool
MergeSort(T* array, size_t nelems, T* scratch, Comparator c) MergeSort(T* array, size_t nelems, T* scratch, Comparator c)
{ {
const size_t INS_SORT_LIMIT = 3; const size_t INS_SORT_LIMIT = 3;
+1 -1
View File
@@ -89,7 +89,7 @@ class SplayTree
return false; return false;
} }
MOZ_MUST_USE bool insert(const T& v) [[nodiscard]] bool insert(const T& v)
{ {
Node* element = allocateNode(v); Node* element = allocateNode(v);
if (!element) if (!element)
+6 -6
View File
@@ -49,7 +49,7 @@ CompileModule(ExclusiveContext* cx, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf, LifoAlloc& alloc, SourceBufferHolder& srcBuf, LifoAlloc& alloc,
ScriptSourceObject** sourceObjectOut = nullptr); ScriptSourceObject** sourceObjectOut = nullptr);
MOZ_MUST_USE bool [[nodiscard]] bool
CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const char16_t* chars, size_t length); CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const char16_t* chars, size_t length);
// //
@@ -64,32 +64,32 @@ CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const char16_t* cha
// Function("/*", "*/x) {") // Function("/*", "*/x) {")
// Function("x){ if (3", "return x;}") // Function("x){ if (3", "return x;}")
// //
MOZ_MUST_USE bool [[nodiscard]] bool
CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun, CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options, const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf, JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd, mozilla::Maybe<uint32_t> parameterListEnd,
HandleScope enclosingScope = nullptr); HandleScope enclosingScope = nullptr);
MOZ_MUST_USE bool [[nodiscard]] bool
CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun, CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options, const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf, JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd); mozilla::Maybe<uint32_t> parameterListEnd);
MOZ_MUST_USE bool [[nodiscard]] bool
CompileStandaloneAsyncFunction(JSContext* cx, MutableHandleFunction fun, CompileStandaloneAsyncFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options, const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf, JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd); mozilla::Maybe<uint32_t> parameterListEnd);
MOZ_MUST_USE bool [[nodiscard]] bool
CompileStandaloneAsyncGenerator(JSContext* cx, MutableHandleFunction fun, CompileStandaloneAsyncGenerator(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options, const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf, JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd); mozilla::Maybe<uint32_t> parameterListEnd);
MOZ_MUST_USE bool [[nodiscard]] bool
CompileAsyncFunctionBody(JSContext* cx, MutableHandleFunction fun, CompileAsyncFunctionBody(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options, const ReadOnlyCompileOptions& options,
Handle<PropertyNameVector> formals, JS::SourceBufferHolder& srcBuf); Handle<PropertyNameVector> formals, JS::SourceBufferHolder& srcBuf);
+2 -2
View File
@@ -64,7 +64,7 @@ class BreakableControl : public NestableControl
BreakableControl(BytecodeEmitter* bce, StatementKind kind); BreakableControl(BytecodeEmitter* bce, StatementKind kind);
MOZ_MUST_USE bool patchBreaks(BytecodeEmitter* bce); [[nodiscard]] bool patchBreaks(BytecodeEmitter* bce);
}; };
template <> template <>
inline bool inline bool
@@ -131,7 +131,7 @@ class LoopControl : public BreakableControl
return canIonOsr_; return canIonOsr_;
} }
MOZ_MUST_USE bool patchBreaksAndContinues(BytecodeEmitter* bce); [[nodiscard]] bool patchBreaksAndContinues(BytecodeEmitter* bce);
}; };
template <> template <>
inline bool inline bool
+6 -6
View File
@@ -144,13 +144,13 @@ class MOZ_RAII OptionalEmitter
Other Other
}; };
MOZ_MUST_USE bool emitJumpShortCircuit(); [[nodiscard]] bool emitJumpShortCircuit();
MOZ_MUST_USE bool emitJumpShortCircuitForCall(); [[nodiscard]] bool emitJumpShortCircuitForCall();
// JSOp is the op code to be emitted, Kind is if we are dealing with a // JSOp is the op code to be emitted, Kind is if we are dealing with a
// reference (in which case we need two elements on the stack) or other value // reference (in which case we need two elements on the stack) or other value
// (which needs one element on the stack) // (which needs one element on the stack)
MOZ_MUST_USE bool emitOptionalJumpTarget(JSOp op, Kind kind = Kind::Other); [[nodiscard]] bool emitOptionalJumpTarget(JSOp op, Kind kind = Kind::Other);
}; };
BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent, BytecodeEmitter::BytecodeEmitter(BytecodeEmitter* parent,
@@ -708,7 +708,7 @@ class NonLocalExitControl
NonLocalExitControl(const NonLocalExitControl&) = delete; NonLocalExitControl(const NonLocalExitControl&) = delete;
MOZ_MUST_USE bool leaveScope(EmitterScope* scope); [[nodiscard]] bool leaveScope(EmitterScope* scope);
public: public:
NonLocalExitControl(BytecodeEmitter* bce, Kind kind) NonLocalExitControl(BytecodeEmitter* bce, Kind kind)
@@ -725,9 +725,9 @@ class NonLocalExitControl
bce_->stackDepth = savedDepth_; bce_->stackDepth = savedDepth_;
} }
MOZ_MUST_USE bool prepareForNonLocalJump(NestableControl* target); [[nodiscard]] bool prepareForNonLocalJump(NestableControl* target);
MOZ_MUST_USE bool prepareForNonLocalJumpToOutermost() { [[nodiscard]] bool prepareForNonLocalJumpToOutermost() {
return prepareForNonLocalJump(nullptr); return prepareForNonLocalJump(nullptr);
} }
}; };
+197 -197
View File
@@ -40,7 +40,7 @@ class CGConstList {
explicit CGConstList(ExclusiveContext* cx) explicit CGConstList(ExclusiveContext* cx)
: vector(cx, ValueVector(cx)) : vector(cx, ValueVector(cx))
{ } { }
MOZ_MUST_USE bool append(const Value& v) { [[nodiscard]] bool append(const Value& v) {
return vector.append(v); return vector.append(v);
} }
size_t length() const { return vector.length(); } size_t length() const { return vector.length(); }
@@ -75,7 +75,7 @@ struct CGTryNoteList {
Vector<JSTryNote> list; Vector<JSTryNote> list;
explicit CGTryNoteList(ExclusiveContext* cx) : list(cx) {} explicit CGTryNoteList(ExclusiveContext* cx) : list(cx) {}
MOZ_MUST_USE bool append(JSTryNoteKind kind, uint32_t stackDepth, size_t start, size_t end); [[nodiscard]] bool append(JSTryNoteKind kind, uint32_t stackDepth, size_t start, size_t end);
size_t length() const { return list.length(); } size_t length() const { return list.length(); }
void finish(TryNoteArray* array); void finish(TryNoteArray* array);
}; };
@@ -97,7 +97,7 @@ struct CGScopeNoteList {
Vector<CGScopeNote> list; Vector<CGScopeNote> list;
explicit CGScopeNoteList(ExclusiveContext* cx) : list(cx) {} explicit CGScopeNoteList(ExclusiveContext* cx) : list(cx) {}
MOZ_MUST_USE bool append(uint32_t scopeIndex, uint32_t offset, bool inPrologue, [[nodiscard]] bool append(uint32_t scopeIndex, uint32_t offset, bool inPrologue,
uint32_t parent); uint32_t parent);
void recordEnd(uint32_t index, uint32_t offset, bool inPrologue); void recordEnd(uint32_t index, uint32_t offset, bool inPrologue);
size_t length() const { return list.length(); } size_t length() const { return list.length(); }
@@ -110,7 +110,7 @@ struct CGYieldAndAwaitOffsetList {
uint32_t numAwaits; uint32_t numAwaits;
explicit CGYieldAndAwaitOffsetList(ExclusiveContext* cx) : list(cx), numYields(0), numAwaits(0) {} explicit CGYieldAndAwaitOffsetList(ExclusiveContext* cx) : list(cx), numYields(0), numAwaits(0) {}
MOZ_MUST_USE bool append(uint32_t offset) { return list.append(offset); } [[nodiscard]] bool append(uint32_t offset) { return list.append(offset); }
size_t length() const { return list.length(); } size_t length() const { return list.length(); }
void finish(YieldAndAwaitOffsetArray& array, uint32_t prologueLength); void finish(YieldAndAwaitOffsetArray& array, uint32_t prologueLength);
}; };
@@ -264,7 +264,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
TokenPos bodyPosition, EmitterMode emitterMode = Normal, TokenPos bodyPosition, EmitterMode emitterMode = Normal,
FieldInitializers fieldInitializers = FieldInitializers::Invalid()); FieldInitializers fieldInitializers = FieldInitializers::Invalid());
MOZ_MUST_USE bool init(); [[nodiscard]] bool init();
template <typename T> template <typename T>
T* findInnermostNestableControl() const; T* findInnermostNestableControl() const;
@@ -300,7 +300,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
Scope* innermostScope() const; Scope* innermostScope() const;
MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE
MOZ_MUST_USE bool makeAtomIndex(JSAtom* atom, uint32_t* indexp) { [[nodiscard]] bool makeAtomIndex(JSAtom* atom, uint32_t* indexp) {
MOZ_ASSERT(atomIndices); MOZ_ASSERT(atomIndices);
AtomIndexMap::AddPtr p = atomIndices->lookupForAdd(atom); AtomIndexMap::AddPtr p = atomIndices->lookupForAdd(atom);
if (p) { if (p) {
@@ -317,16 +317,16 @@ struct MOZ_STACK_CLASS BytecodeEmitter
} }
bool isInLoop(); bool isInLoop();
MOZ_MUST_USE bool checkSingletonContext(); [[nodiscard]] bool checkSingletonContext();
// Check whether our function is in a run-once context (a toplevel // Check whether our function is in a run-once context (a toplevel
// run-one script or a run-once lambda). // run-one script or a run-once lambda).
MOZ_MUST_USE bool checkRunOnceContext(); [[nodiscard]] bool checkRunOnceContext();
bool needsImplicitThis(); bool needsImplicitThis();
MOZ_MUST_USE bool maybeSetDisplayURL(); [[nodiscard]] bool maybeSetDisplayURL();
MOZ_MUST_USE bool maybeSetSourceMap(); [[nodiscard]] bool maybeSetSourceMap();
void tellDebuggerAboutCompiledScript(ExclusiveContext* cx); void tellDebuggerAboutCompiledScript(ExclusiveContext* cx);
inline TokenStream& tokenStream(); inline TokenStream& tokenStream();
@@ -383,29 +383,29 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// statement, we define useless code as code with no side effects, because // statement, we define useless code as code with no side effects, because
// the main effect, the value left on the stack after the code executes, // the main effect, the value left on the stack after the code executes,
// will be discarded by a pop bytecode. // will be discarded by a pop bytecode.
MOZ_MUST_USE bool checkSideEffects(ParseNode* pn, bool* answer); [[nodiscard]] bool checkSideEffects(ParseNode* pn, bool* answer);
#ifdef DEBUG #ifdef DEBUG
MOZ_MUST_USE bool checkStrictOrSloppy(JSOp op); [[nodiscard]] bool checkStrictOrSloppy(JSOp op);
#endif #endif
// Append a new source note of the given type (and therefore size) to the // Append a new source note of the given type (and therefore size) to the
// notes dynamic array, updating noteCount. Return the new note's index // notes dynamic array, updating noteCount. Return the new note's index
// within the array pointed at by current->notes as outparam. // within the array pointed at by current->notes as outparam.
MOZ_MUST_USE bool newSrcNote(SrcNoteType type, unsigned* indexp = nullptr); [[nodiscard]] bool newSrcNote(SrcNoteType type, unsigned* indexp = nullptr);
MOZ_MUST_USE bool newSrcNote2(SrcNoteType type, ptrdiff_t offset, unsigned* indexp = nullptr); [[nodiscard]] bool newSrcNote2(SrcNoteType type, ptrdiff_t offset, unsigned* indexp = nullptr);
MOZ_MUST_USE bool newSrcNote3(SrcNoteType type, ptrdiff_t offset1, ptrdiff_t offset2, [[nodiscard]] bool newSrcNote3(SrcNoteType type, ptrdiff_t offset1, ptrdiff_t offset2,
unsigned* indexp = nullptr); unsigned* indexp = nullptr);
void copySrcNotes(jssrcnote* destination, uint32_t nsrcnotes); void copySrcNotes(jssrcnote* destination, uint32_t nsrcnotes);
MOZ_MUST_USE bool setSrcNoteOffset(unsigned index, unsigned which, ptrdiff_t offset); [[nodiscard]] bool setSrcNoteOffset(unsigned index, unsigned which, ptrdiff_t offset);
// NB: this function can add at most one extra extended delta note. // NB: this function can add at most one extra extended delta note.
MOZ_MUST_USE bool addToSrcNoteDelta(jssrcnote* sn, ptrdiff_t delta); [[nodiscard]] bool addToSrcNoteDelta(jssrcnote* sn, ptrdiff_t delta);
// Finish taking source notes in cx's notePool. If successful, the final // Finish taking source notes in cx's notePool. If successful, the final
// source note count is stored in the out outparam. // source note count is stored in the out outparam.
MOZ_MUST_USE bool finishTakingSrcNotes(uint32_t* out); [[nodiscard]] bool finishTakingSrcNotes(uint32_t* out);
// Control whether emitTree emits a line number note. // Control whether emitTree emits a line number note.
enum EmitLineNumberNote { enum EmitLineNumberNote {
@@ -414,242 +414,242 @@ struct MOZ_STACK_CLASS BytecodeEmitter
}; };
// Emit code for the tree rooted at pn. // Emit code for the tree rooted at pn.
MOZ_MUST_USE bool emitTree(ParseNode* pn, ValueUsage valueUsage = ValueUsage::WantValue, [[nodiscard]] bool emitTree(ParseNode* pn, ValueUsage valueUsage = ValueUsage::WantValue,
EmitLineNumberNote emitLineNote = EMIT_LINENOTE); EmitLineNumberNote emitLineNote = EMIT_LINENOTE);
// Emit code for the optional tree rooted at pn. // Emit code for the optional tree rooted at pn.
MOZ_MUST_USE bool emitOptionalTree(ParseNode* pn, [[nodiscard]] bool emitOptionalTree(ParseNode* pn,
OptionalEmitter& oe, OptionalEmitter& oe,
ValueUsage valueUsage = ValueUsage::WantValue); ValueUsage valueUsage = ValueUsage::WantValue);
// Emit code for the tree rooted at pn with its own TDZ cache. // Emit code for the tree rooted at pn with its own TDZ cache.
MOZ_MUST_USE bool emitTreeInBranch(ParseNode* pn, [[nodiscard]] bool emitTreeInBranch(ParseNode* pn,
ValueUsage valueUsage = ValueUsage::WantValue); ValueUsage valueUsage = ValueUsage::WantValue);
// Emit global, eval, or module code for tree rooted at body. Always // Emit global, eval, or module code for tree rooted at body. Always
// encompasses the entire source. // encompasses the entire source.
MOZ_MUST_USE bool emitScript(ParseNode* body); [[nodiscard]] bool emitScript(ParseNode* body);
// Emit function code for the tree rooted at body. // Emit function code for the tree rooted at body.
MOZ_MUST_USE bool emitFunctionScript(FunctionNode* funNode); [[nodiscard]] bool emitFunctionScript(FunctionNode* funNode);
void updateDepth(ptrdiff_t target); void updateDepth(ptrdiff_t target);
MOZ_MUST_USE bool updateLineNumberNotes(uint32_t offset); [[nodiscard]] bool updateLineNumberNotes(uint32_t offset);
MOZ_MUST_USE bool updateSourceCoordNotes(uint32_t offset); [[nodiscard]] bool updateSourceCoordNotes(uint32_t offset);
JSOp strictifySetNameOp(JSOp op); JSOp strictifySetNameOp(JSOp op);
MOZ_MUST_USE bool emitCheck(JSOp op, ptrdiff_t delta, ptrdiff_t* offset); [[nodiscard]] bool emitCheck(JSOp op, ptrdiff_t delta, ptrdiff_t* offset);
// Emit one bytecode. // Emit one bytecode.
MOZ_MUST_USE bool emit1(JSOp op); [[nodiscard]] bool emit1(JSOp op);
// Emit two bytecodes, an opcode (op) with a byte of immediate operand // Emit two bytecodes, an opcode (op) with a byte of immediate operand
// (op1). // (op1).
MOZ_MUST_USE bool emit2(JSOp op, uint8_t op1); [[nodiscard]] bool emit2(JSOp op, uint8_t op1);
// Emit three bytecodes, an opcode with two bytes of immediate operands. // Emit three bytecodes, an opcode with two bytes of immediate operands.
MOZ_MUST_USE bool emit3(JSOp op, jsbytecode op1, jsbytecode op2); [[nodiscard]] bool emit3(JSOp op, jsbytecode op1, jsbytecode op2);
// Helper to emit JSOP_DUPAT. The argument is the value's depth on the // Helper to emit JSOP_DUPAT. The argument is the value's depth on the
// JS stack, as measured from the top. // JS stack, as measured from the top.
MOZ_MUST_USE bool emitDupAt(unsigned slotFromTop); [[nodiscard]] bool emitDupAt(unsigned slotFromTop);
// Helper to emit JSOP_POP or JSOP_POPN. // Helper to emit JSOP_POP or JSOP_POPN.
MOZ_MUST_USE bool emitPopN(unsigned n); [[nodiscard]] bool emitPopN(unsigned n);
// Helper to emit JSOP_SWAP or JSOP_UNPICK. // Helper to emit JSOP_SWAP or JSOP_UNPICK.
MOZ_MUST_USE bool emitUnpickN(unsigned n); [[nodiscard]] bool emitUnpickN(unsigned n);
// Helper to emit JSOP_CHECKISOBJ. // Helper to emit JSOP_CHECKISOBJ.
MOZ_MUST_USE bool emitCheckIsObj(CheckIsObjectKind kind); [[nodiscard]] bool emitCheckIsObj(CheckIsObjectKind kind);
// Helper to emit JSOP_CHECKISCALLABLE. // Helper to emit JSOP_CHECKISCALLABLE.
MOZ_MUST_USE bool emitCheckIsCallable(CheckIsCallableKind kind); [[nodiscard]] bool emitCheckIsCallable(CheckIsCallableKind kind);
// Emit a bytecode followed by an uint16 immediate operand stored in // Emit a bytecode followed by an uint16 immediate operand stored in
// big-endian order. // big-endian order.
MOZ_MUST_USE bool emitUint16Operand(JSOp op, uint32_t operand); [[nodiscard]] bool emitUint16Operand(JSOp op, uint32_t operand);
// Emit a bytecode followed by an uint32 immediate operand. // Emit a bytecode followed by an uint32 immediate operand.
MOZ_MUST_USE bool emitUint32Operand(JSOp op, uint32_t operand); [[nodiscard]] bool emitUint32Operand(JSOp op, uint32_t operand);
// Emit (1 + extra) bytecodes, for N bytes of op and its immediate operand. // Emit (1 + extra) bytecodes, for N bytes of op and its immediate operand.
MOZ_MUST_USE bool emitN(JSOp op, size_t extra, ptrdiff_t* offset = nullptr); [[nodiscard]] bool emitN(JSOp op, size_t extra, ptrdiff_t* offset = nullptr);
MOZ_MUST_USE bool emitNumberOp(double dval); [[nodiscard]] bool emitNumberOp(double dval);
MOZ_MUST_USE bool emitBigIntOp(BigInt* bigint); [[nodiscard]] bool emitBigIntOp(BigInt* bigint);
MOZ_MUST_USE bool emitThisLiteral(ThisLiteral* pn); [[nodiscard]] bool emitThisLiteral(ThisLiteral* pn);
MOZ_MUST_USE bool emitGetFunctionThis(ParseNode* pn); [[nodiscard]] bool emitGetFunctionThis(ParseNode* pn);
MOZ_MUST_USE bool emitGetFunctionThis(const mozilla::Maybe<uint32_t>& offset); [[nodiscard]] bool emitGetFunctionThis(const mozilla::Maybe<uint32_t>& offset);
MOZ_MUST_USE bool emitGetThisForSuperBase(UnaryNode* superBase); [[nodiscard]] bool emitGetThisForSuperBase(UnaryNode* superBase);
MOZ_MUST_USE bool emitSetThis(BinaryNode* setThisNode); [[nodiscard]] bool emitSetThis(BinaryNode* setThisNode);
MOZ_MUST_USE bool emitCheckDerivedClassConstructorReturn(); [[nodiscard]] bool emitCheckDerivedClassConstructorReturn();
// Handle jump opcodes and jump targets. // Handle jump opcodes and jump targets.
MOZ_MUST_USE bool emitJumpTarget(JumpTarget* target); [[nodiscard]] bool emitJumpTarget(JumpTarget* target);
MOZ_MUST_USE bool emitJumpNoFallthrough(JSOp op, JumpList* jump); [[nodiscard]] bool emitJumpNoFallthrough(JSOp op, JumpList* jump);
MOZ_MUST_USE bool emitJump(JSOp op, JumpList* jump); [[nodiscard]] bool emitJump(JSOp op, JumpList* jump);
MOZ_MUST_USE bool emitBackwardJump(JSOp op, JumpTarget target, JumpList* jump, [[nodiscard]] bool emitBackwardJump(JSOp op, JumpTarget target, JumpList* jump,
JumpTarget* fallthrough); JumpTarget* fallthrough);
void patchJumpsToTarget(JumpList jump, JumpTarget target); void patchJumpsToTarget(JumpList jump, JumpTarget target);
MOZ_MUST_USE bool emitJumpTargetAndPatch(JumpList jump); [[nodiscard]] bool emitJumpTargetAndPatch(JumpList jump);
MOZ_MUST_USE bool emitCall(JSOp op, uint16_t argc, [[nodiscard]] bool emitCall(JSOp op, uint16_t argc,
const mozilla::Maybe<uint32_t>& sourceCoordOffset); const mozilla::Maybe<uint32_t>& sourceCoordOffset);
MOZ_MUST_USE bool emitCall(JSOp op, uint16_t argc, ParseNode* pn = nullptr); [[nodiscard]] bool emitCall(JSOp op, uint16_t argc, ParseNode* pn = nullptr);
MOZ_MUST_USE bool emitCallIncDec(UnaryNode* incDec); [[nodiscard]] bool emitCallIncDec(UnaryNode* incDec);
MOZ_MUST_USE bool emitLoopHead(ParseNode* nextpn, JumpTarget* top); [[nodiscard]] bool emitLoopHead(ParseNode* nextpn, JumpTarget* top);
MOZ_MUST_USE bool emitLoopEntry(ParseNode* nextpn, JumpList entryJump); [[nodiscard]] bool emitLoopEntry(ParseNode* nextpn, JumpList entryJump);
MOZ_MUST_USE bool emitGoto(NestableControl* target, JumpList* jumplist, [[nodiscard]] bool emitGoto(NestableControl* target, JumpList* jumplist,
SrcNoteType noteType = SRC_NULL); SrcNoteType noteType = SRC_NULL);
MOZ_MUST_USE bool emitIndex32(JSOp op, uint32_t index); [[nodiscard]] bool emitIndex32(JSOp op, uint32_t index);
MOZ_MUST_USE bool emitIndexOp(JSOp op, uint32_t index); [[nodiscard]] bool emitIndexOp(JSOp op, uint32_t index);
MOZ_MUST_USE bool emitAtomOp(JSAtom* atom, JSOp op); [[nodiscard]] bool emitAtomOp(JSAtom* atom, JSOp op);
MOZ_MUST_USE bool emitAtomOp(uint32_t atomIndex, JSOp op); [[nodiscard]] bool emitAtomOp(uint32_t atomIndex, JSOp op);
MOZ_MUST_USE bool emitArrayLiteral(ListNode* array); [[nodiscard]] bool emitArrayLiteral(ListNode* array);
MOZ_MUST_USE bool emitArray(ParseNode* arrayHead, uint32_t count, JSOp op); [[nodiscard]] bool emitArray(ParseNode* arrayHead, uint32_t count, JSOp op);
MOZ_MUST_USE bool emitArrayComp(ListNode* pn); [[nodiscard]] bool emitArrayComp(ListNode* pn);
MOZ_MUST_USE bool emitInternedScopeOp(uint32_t index, JSOp op); [[nodiscard]] bool emitInternedScopeOp(uint32_t index, JSOp op);
MOZ_MUST_USE bool emitInternedObjectOp(uint32_t index, JSOp op); [[nodiscard]] bool emitInternedObjectOp(uint32_t index, JSOp op);
MOZ_MUST_USE bool emitObjectOp(ObjectBox* objbox, JSOp op); [[nodiscard]] bool emitObjectOp(ObjectBox* objbox, JSOp op);
MOZ_MUST_USE bool emitObjectPairOp(ObjectBox* objbox1, ObjectBox* objbox2, JSOp op); [[nodiscard]] bool emitObjectPairOp(ObjectBox* objbox1, ObjectBox* objbox2, JSOp op);
MOZ_MUST_USE bool emitRegExp(uint32_t index); [[nodiscard]] bool emitRegExp(uint32_t index);
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitFunction(FunctionNode* funNode, [[nodiscard]] MOZ_NEVER_INLINE bool emitFunction(FunctionNode* funNode,
bool needsProto = false, bool needsProto = false,
ListNode* classContentsIfConstructor = nullptr); ListNode* classContentsIfConstructor = nullptr);
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitObject(ListNode* objNode); [[nodiscard]] MOZ_NEVER_INLINE bool emitObject(ListNode* objNode);
MOZ_MUST_USE bool replaceNewInitWithNewObject(JSObject* obj, ptrdiff_t offset); [[nodiscard]] bool replaceNewInitWithNewObject(JSObject* obj, ptrdiff_t offset);
MOZ_MUST_USE bool emitHoistedFunctionsInList(ListNode* stmtList); [[nodiscard]] bool emitHoistedFunctionsInList(ListNode* stmtList);
MOZ_MUST_USE bool emitPropertyList(ListNode* obj, PropertyEmitter& pe, [[nodiscard]] bool emitPropertyList(ListNode* obj, PropertyEmitter& pe,
PropListType type); PropListType type);
enum class FieldPlacement { Instance, Static }; enum class FieldPlacement { Instance, Static };
FieldInitializers setupFieldInitializers(ListNode* classMembers, FieldPlacement placement); FieldInitializers setupFieldInitializers(ListNode* classMembers, FieldPlacement placement);
MOZ_MUST_USE bool emitCreateFieldKeys(ListNode* obj, FieldPlacement placement); [[nodiscard]] bool emitCreateFieldKeys(ListNode* obj, FieldPlacement placement);
MOZ_MUST_USE bool emitCreateFieldInitializers(ClassEmitter& ce, ListNode* obj, FieldPlacement placement); [[nodiscard]] bool emitCreateFieldInitializers(ClassEmitter& ce, ListNode* obj, FieldPlacement placement);
const FieldInitializers& findFieldInitializersForCall(); const FieldInitializers& findFieldInitializersForCall();
MOZ_MUST_USE bool emitInitializeInstanceFields(); [[nodiscard]] bool emitInitializeInstanceFields();
MOZ_MUST_USE bool emitInitializeStaticFields(ListNode* classMembers); [[nodiscard]] bool emitInitializeStaticFields(ListNode* classMembers);
// To catch accidental misuse, emitUint16Operand/emit3 assert that they are // To catch accidental misuse, emitUint16Operand/emit3 assert that they are
// not used to unconditionally emit JSOP_GETLOCAL. Variable access should // not used to unconditionally emit JSOP_GETLOCAL. Variable access should
// instead be emitted using EmitVarOp. In special cases, when the caller // instead be emitted using EmitVarOp. In special cases, when the caller
// definitely knows that a given local slot is unaliased, this function may be // definitely knows that a given local slot is unaliased, this function may be
// used as a non-asserting version of emitUint16Operand. // used as a non-asserting version of emitUint16Operand.
MOZ_MUST_USE bool emitLocalOp(JSOp op, uint32_t slot); [[nodiscard]] bool emitLocalOp(JSOp op, uint32_t slot);
MOZ_MUST_USE bool emitArgOp(JSOp op, uint16_t slot); [[nodiscard]] bool emitArgOp(JSOp op, uint16_t slot);
MOZ_MUST_USE bool emitEnvCoordOp(JSOp op, EnvironmentCoordinate ec); [[nodiscard]] bool emitEnvCoordOp(JSOp op, EnvironmentCoordinate ec);
MOZ_MUST_USE bool emitGetNameAtLocation(JSAtom* name, const NameLocation& loc); [[nodiscard]] bool emitGetNameAtLocation(JSAtom* name, const NameLocation& loc);
MOZ_MUST_USE bool emitGetName(JSAtom* name) { [[nodiscard]] bool emitGetName(JSAtom* name) {
return emitGetNameAtLocation(name, lookupName(name)); return emitGetNameAtLocation(name, lookupName(name));
} }
MOZ_MUST_USE bool emitGetName(ParseNode* pn); [[nodiscard]] bool emitGetName(ParseNode* pn);
MOZ_MUST_USE bool emitTDZCheckIfNeeded(JSAtom* name, const NameLocation& loc); [[nodiscard]] bool emitTDZCheckIfNeeded(JSAtom* name, const NameLocation& loc);
MOZ_MUST_USE bool emitNameIncDec(UnaryNode* incDec); [[nodiscard]] bool emitNameIncDec(UnaryNode* incDec);
MOZ_MUST_USE bool emitDeclarationList(ListNode* declList); [[nodiscard]] bool emitDeclarationList(ListNode* declList);
MOZ_MUST_USE bool emitSingleDeclaration(ParseNode* declList, ParseNode* decl, [[nodiscard]] bool emitSingleDeclaration(ParseNode* declList, ParseNode* decl,
ParseNode* initializer); ParseNode* initializer);
MOZ_MUST_USE bool emitNewInit(JSProtoKey key); [[nodiscard]] bool emitNewInit(JSProtoKey key);
MOZ_MUST_USE bool emitSingletonInitialiser(ParseNode* pn); [[nodiscard]] bool emitSingletonInitialiser(ParseNode* pn);
MOZ_MUST_USE bool emitPrepareIteratorResult(); [[nodiscard]] bool emitPrepareIteratorResult();
MOZ_MUST_USE bool emitFinishIteratorResult(bool done); [[nodiscard]] bool emitFinishIteratorResult(bool done);
MOZ_MUST_USE bool iteratorResultShape(unsigned* shape); [[nodiscard]] bool iteratorResultShape(unsigned* shape);
MOZ_MUST_USE bool emitToIteratorResult(bool done); [[nodiscard]] bool emitToIteratorResult(bool done);
MOZ_MUST_USE bool emitGetDotGeneratorInInnermostScope() { [[nodiscard]] bool emitGetDotGeneratorInInnermostScope() {
return emitGetDotGeneratorInScope(*innermostEmitterScope()); return emitGetDotGeneratorInScope(*innermostEmitterScope());
} }
MOZ_MUST_USE bool emitGetDotGeneratorInScope(EmitterScope& currentScope); [[nodiscard]] bool emitGetDotGeneratorInScope(EmitterScope& currentScope);
MOZ_MUST_USE bool emitInitialYield(UnaryNode* yieldNode); [[nodiscard]] bool emitInitialYield(UnaryNode* yieldNode);
MOZ_MUST_USE bool emitYield(UnaryNode* yieldNode); [[nodiscard]] bool emitYield(UnaryNode* yieldNode);
MOZ_MUST_USE bool emitYieldOp(JSOp op); [[nodiscard]] bool emitYieldOp(JSOp op);
MOZ_MUST_USE bool emitYieldStar(ParseNode* iter); [[nodiscard]] bool emitYieldStar(ParseNode* iter);
MOZ_MUST_USE bool emitAwaitInInnermostScope() { [[nodiscard]] bool emitAwaitInInnermostScope() {
return emitAwaitInScope(*innermostEmitterScope()); return emitAwaitInScope(*innermostEmitterScope());
} }
MOZ_MUST_USE bool emitAwaitInInnermostScope(UnaryNode* awaitNode); [[nodiscard]] bool emitAwaitInInnermostScope(UnaryNode* awaitNode);
MOZ_MUST_USE bool emitAwaitInScope(EmitterScope& currentScope); [[nodiscard]] bool emitAwaitInScope(EmitterScope& currentScope);
MOZ_MUST_USE bool emitPropLHS(PropertyAccess* prop); [[nodiscard]] bool emitPropLHS(PropertyAccess* prop);
MOZ_MUST_USE bool emitPropIncDec(UnaryNode* incDec); [[nodiscard]] bool emitPropIncDec(UnaryNode* incDec);
MOZ_MUST_USE bool emitAsyncWrapperLambda(unsigned index, bool isArrow); [[nodiscard]] bool emitAsyncWrapperLambda(unsigned index, bool isArrow);
MOZ_MUST_USE bool emitAsyncWrapper(unsigned index, bool needsHomeObject, bool isArrow, [[nodiscard]] bool emitAsyncWrapper(unsigned index, bool needsHomeObject, bool isArrow,
bool isStarGenerator); bool isStarGenerator);
MOZ_MUST_USE bool emitComputedPropertyName(UnaryNode* computedPropName); [[nodiscard]] bool emitComputedPropertyName(UnaryNode* computedPropName);
// Emit bytecode to put operands for a JSOP_GETELEM/CALLELEM/SETELEM/DELELEM // Emit bytecode to put operands for a JSOP_GETELEM/CALLELEM/SETELEM/DELELEM
// opcode onto the stack in the right order. In the case of SETELEM, the // opcode onto the stack in the right order. In the case of SETELEM, the
// value to be assigned must already be pushed. // value to be assigned must already be pushed.
enum class EmitElemOption { Get, Set, Call, IncDec, CompoundAssign, Ref }; enum class EmitElemOption { Get, Set, Call, IncDec, CompoundAssign, Ref };
MOZ_MUST_USE bool emitElemOperands(PropertyByValue* elem, EmitElemOption opts); [[nodiscard]] bool emitElemOperands(PropertyByValue* elem, EmitElemOption opts);
MOZ_MUST_USE bool emitElemObjAndKey(PropertyByValue* elem, bool isSuper, ElemOpEmitter& eoe); [[nodiscard]] bool emitElemObjAndKey(PropertyByValue* elem, bool isSuper, ElemOpEmitter& eoe);
MOZ_MUST_USE bool emitElemOpBase(JSOp op); [[nodiscard]] bool emitElemOpBase(JSOp op);
MOZ_MUST_USE bool emitElemIncDec(UnaryNode* incDec); [[nodiscard]] bool emitElemIncDec(UnaryNode* incDec);
MOZ_MUST_USE bool emitCatch(TernaryNode* catchNode); [[nodiscard]] bool emitCatch(TernaryNode* catchNode);
MOZ_MUST_USE bool emitIf(TernaryNode* ifNode); [[nodiscard]] bool emitIf(TernaryNode* ifNode);
MOZ_MUST_USE bool emitWith(BinaryNode* withNode); [[nodiscard]] bool emitWith(BinaryNode* withNode);
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLabeledStatement(const LabeledStatement* pn); [[nodiscard]] MOZ_NEVER_INLINE bool emitLabeledStatement(const LabeledStatement* pn);
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLexicalScope(LexicalScopeNode* lexicalScope); [[nodiscard]] MOZ_NEVER_INLINE bool emitLexicalScope(LexicalScopeNode* lexicalScope);
MOZ_MUST_USE bool emitLexicalScopeBody(ParseNode* body, [[nodiscard]] bool emitLexicalScopeBody(ParseNode* body,
EmitLineNumberNote emitLineNote = EMIT_LINENOTE); EmitLineNumberNote emitLineNote = EMIT_LINENOTE);
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitSwitch(SwitchStatement* switchStmt); [[nodiscard]] MOZ_NEVER_INLINE bool emitSwitch(SwitchStatement* switchStmt);
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitTry(TryNode* tryNode); [[nodiscard]] MOZ_NEVER_INLINE bool emitTry(TryNode* tryNode);
// emitDestructuringLHSRef emits the lhs expression's reference. // emitDestructuringLHSRef emits the lhs expression's reference.
// If the lhs expression is object property |OBJ.prop|, it emits |OBJ|. // If the lhs expression is object property |OBJ.prop|, it emits |OBJ|.
// If it's object element |OBJ[ELEM]|, it emits |OBJ| and |ELEM|. // If it's object element |OBJ[ELEM]|, it emits |OBJ| and |ELEM|.
// If there's nothing to evaluate for the reference, it emits nothing. // If there's nothing to evaluate for the reference, it emits nothing.
// |emitted| parameter receives the number of values pushed onto the stack. // |emitted| parameter receives the number of values pushed onto the stack.
MOZ_MUST_USE bool emitDestructuringLHSRef(ParseNode* target, size_t* emitted); [[nodiscard]] bool emitDestructuringLHSRef(ParseNode* target, size_t* emitted);
// emitSetOrInitializeDestructuring assumes the lhs expression's reference // emitSetOrInitializeDestructuring assumes the lhs expression's reference
// and the to-be-destructured value has been pushed on the stack. It emits // and the to-be-destructured value has been pushed on the stack. It emits
// code to destructure a single lhs expression (either a name or a compound // code to destructure a single lhs expression (either a name or a compound
// []/{} expression). // []/{} expression).
MOZ_MUST_USE bool emitSetOrInitializeDestructuring(ParseNode* target, DestructuringFlavor flav); [[nodiscard]] bool emitSetOrInitializeDestructuring(ParseNode* target, DestructuringFlavor flav);
// emitDestructuringObjRestExclusionSet emits the property exclusion set // emitDestructuringObjRestExclusionSet emits the property exclusion set
// for the rest-property in an object pattern. // for the rest-property in an object pattern.
MOZ_MUST_USE bool emitDestructuringObjRestExclusionSet(ListNode* pattern); [[nodiscard]] bool emitDestructuringObjRestExclusionSet(ListNode* pattern);
// emitDestructuringOps assumes the to-be-destructured value has been // emitDestructuringOps assumes the to-be-destructured value has been
// pushed on the stack and emits code to destructure each part of a [] or // pushed on the stack and emits code to destructure each part of a [] or
// {} lhs expression. // {} lhs expression.
MOZ_MUST_USE bool emitDestructuringOps(ListNode* pattern, DestructuringFlavor flav); [[nodiscard]] bool emitDestructuringOps(ListNode* pattern, DestructuringFlavor flav);
MOZ_MUST_USE bool emitDestructuringOpsArray(ListNode* pattern, DestructuringFlavor flav); [[nodiscard]] bool emitDestructuringOpsArray(ListNode* pattern, DestructuringFlavor flav);
MOZ_MUST_USE bool emitDestructuringOpsObject(ListNode* pattern, DestructuringFlavor flav); [[nodiscard]] bool emitDestructuringOpsObject(ListNode* pattern, DestructuringFlavor flav);
typedef bool typedef bool
(*DestructuringDeclEmitter)(BytecodeEmitter* bce, ParseNode* pn); (*DestructuringDeclEmitter)(BytecodeEmitter* bce, ParseNode* pn);
// Throw a TypeError if the value atop the stack isn't convertible to an // Throw a TypeError if the value atop the stack isn't convertible to an
// object, with no overall effect on the stack. // object, with no overall effect on the stack.
MOZ_MUST_USE bool emitRequireObjectCoercible(); [[nodiscard]] bool emitRequireObjectCoercible();
enum class CopyOption { enum class CopyOption {
Filtered, Unfiltered Filtered, Unfiltered
@@ -658,27 +658,27 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// Calls either the |CopyDataProperties| or the // Calls either the |CopyDataProperties| or the
// |CopyDataPropertiesUnfiltered| intrinsic function, consumes three (or // |CopyDataPropertiesUnfiltered| intrinsic function, consumes three (or
// two in the latter case) elements from the stack. // two in the latter case) elements from the stack.
MOZ_MUST_USE bool emitCopyDataProperties(CopyOption option); [[nodiscard]] bool emitCopyDataProperties(CopyOption option);
// emitIterator expects the iterable to already be on the stack. // emitIterator expects the iterable to already be on the stack.
// It will replace that stack value with the corresponding iterator // It will replace that stack value with the corresponding iterator
MOZ_MUST_USE bool emitIterator(); [[nodiscard]] bool emitIterator();
MOZ_MUST_USE bool emitAsyncIterator(); [[nodiscard]] bool emitAsyncIterator();
// XXX currently used only by OptionalEmitter, research still required // XXX currently used only by OptionalEmitter, research still required
// to identify when this was introduced in m-c. // to identify when this was introduced in m-c.
MOZ_MUST_USE bool emitPushNotUndefinedOrNull(); [[nodiscard]] bool emitPushNotUndefinedOrNull();
// Pops iterator from the top of the stack. Pushes the result of |.next()| // Pops iterator from the top of the stack. Pushes the result of |.next()|
// onto the stack. // onto the stack.
MOZ_MUST_USE bool emitIteratorNext(ParseNode* pn, IteratorKind kind = IteratorKind::Sync, [[nodiscard]] bool emitIteratorNext(ParseNode* pn, IteratorKind kind = IteratorKind::Sync,
bool allowSelfHosted = false); bool allowSelfHosted = false);
MOZ_MUST_USE bool emitIteratorCloseInScope(EmitterScope& currentScope, [[nodiscard]] bool emitIteratorCloseInScope(EmitterScope& currentScope,
IteratorKind iterKind = IteratorKind::Sync, IteratorKind iterKind = IteratorKind::Sync,
CompletionKind completionKind = CompletionKind::Normal, CompletionKind completionKind = CompletionKind::Normal,
bool allowSelfHosted = false); bool allowSelfHosted = false);
MOZ_MUST_USE bool emitIteratorCloseInInnermostScope(IteratorKind iterKind = IteratorKind::Sync, [[nodiscard]] bool emitIteratorCloseInInnermostScope(IteratorKind iterKind = IteratorKind::Sync,
CompletionKind completionKind = CompletionKind::Normal, CompletionKind completionKind = CompletionKind::Normal,
bool allowSelfHosted = false) { bool allowSelfHosted = false) {
return emitIteratorCloseInScope(*innermostEmitterScope(), iterKind, completionKind, return emitIteratorCloseInScope(*innermostEmitterScope(), iterKind, completionKind,
@@ -686,7 +686,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
} }
template <typename InnerEmitter> template <typename InnerEmitter>
MOZ_MUST_USE bool wrapWithDestructuringIteratorCloseTryNote(int32_t iterDepth, [[nodiscard]] bool wrapWithDestructuringIteratorCloseTryNote(int32_t iterDepth,
InnerEmitter emitter); InnerEmitter emitter);
// Check if the value on top of the stack is "undefined". If so, replace // Check if the value on top of the stack is "undefined". If so, replace
@@ -694,114 +694,114 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// |pattern| is a lhs node of the default expression. If it's an // |pattern| is a lhs node of the default expression. If it's an
// identifier and |defaultExpr| is an anonymous function, |SetFunctionName| // identifier and |defaultExpr| is an anonymous function, |SetFunctionName|
// is called at compile time. // is called at compile time.
MOZ_MUST_USE bool emitDefault(ParseNode* defaultExpr, ParseNode* pattern); [[nodiscard]] bool emitDefault(ParseNode* defaultExpr, ParseNode* pattern);
MOZ_MUST_USE bool setOrEmitSetFunName(ParseNode* maybeFun, HandleAtom name); [[nodiscard]] bool setOrEmitSetFunName(ParseNode* maybeFun, HandleAtom name);
MOZ_MUST_USE bool setFunName(JSFunction* fun, JSAtom* name); [[nodiscard]] bool setFunName(JSFunction* fun, JSAtom* name);
MOZ_MUST_USE bool emitSetClassConstructorName(JSAtom* name); [[nodiscard]] bool emitSetClassConstructorName(JSAtom* name);
MOZ_MUST_USE bool emitSetFunctionNameFromStack(uint8_t offset); [[nodiscard]] bool emitSetFunctionNameFromStack(uint8_t offset);
MOZ_MUST_USE bool emitInitializer(ParseNode* initializer, ParseNode* pattern); [[nodiscard]] bool emitInitializer(ParseNode* initializer, ParseNode* pattern);
MOZ_MUST_USE bool emitCallSiteObject(CallSiteNode* callSiteObj); [[nodiscard]] bool emitCallSiteObject(CallSiteNode* callSiteObj);
MOZ_MUST_USE bool emitTemplateString(ListNode* templateString); [[nodiscard]] bool emitTemplateString(ListNode* templateString);
MOZ_MUST_USE bool emitAssignmentOrInit(ParseNodeKind kind, JSOp compoundOp, [[nodiscard]] bool emitAssignmentOrInit(ParseNodeKind kind, JSOp compoundOp,
ParseNode* lhs, ParseNode* rhs); ParseNode* lhs, ParseNode* rhs);
MOZ_MUST_USE bool emitShortCircuitAssignment(ParseNodeKind kind, JSOp op, [[nodiscard]] bool emitShortCircuitAssignment(ParseNodeKind kind, JSOp op,
ParseNode* lhs, ParseNode* rhs); ParseNode* lhs, ParseNode* rhs);
MOZ_MUST_USE bool emitReturn(UnaryNode* returnNode); [[nodiscard]] bool emitReturn(UnaryNode* returnNode);
MOZ_MUST_USE bool emitStatement(UnaryNode* exprStmt); [[nodiscard]] bool emitStatement(UnaryNode* exprStmt);
MOZ_MUST_USE bool emitStatementList(ListNode* stmtList); [[nodiscard]] bool emitStatementList(ListNode* stmtList);
MOZ_MUST_USE bool emitDeleteName(UnaryNode* deleteNode); [[nodiscard]] bool emitDeleteName(UnaryNode* deleteNode);
MOZ_MUST_USE bool emitDeleteProperty(UnaryNode* deleteNode); [[nodiscard]] bool emitDeleteProperty(UnaryNode* deleteNode);
MOZ_MUST_USE bool emitDeleteElement(UnaryNode* deleteNode); [[nodiscard]] bool emitDeleteElement(UnaryNode* deleteNode);
MOZ_MUST_USE bool emitDeleteExpression(UnaryNode* deleteNode); [[nodiscard]] bool emitDeleteExpression(UnaryNode* deleteNode);
// Optional methods which emit Optional Jump Target // Optional methods which emit Optional Jump Target
MOZ_MUST_USE bool emitOptionalChain(UnaryNode* optionalChain, [[nodiscard]] bool emitOptionalChain(UnaryNode* optionalChain,
ValueUsage valueUsage); ValueUsage valueUsage);
MOZ_MUST_USE bool emitCalleeAndThisForOptionalChain(UnaryNode* optionalChain, [[nodiscard]] bool emitCalleeAndThisForOptionalChain(UnaryNode* optionalChain,
ParseNode* callNode, ParseNode* callNode,
CallOrNewEmitter& cone); CallOrNewEmitter& cone);
MOZ_MUST_USE bool emitDeleteOptionalChain(UnaryNode* deleteNode); [[nodiscard]] bool emitDeleteOptionalChain(UnaryNode* deleteNode);
// Optional methods which emit a shortCircuit jump. They need to be called by // Optional methods which emit a shortCircuit jump. They need to be called by
// a method which emits an Optional Jump Target, see below. // a method which emits an Optional Jump Target, see below.
MOZ_MUST_USE bool emitOptionalDotExpression(PropertyAccessBase* prop, [[nodiscard]] bool emitOptionalDotExpression(PropertyAccessBase* prop,
PropOpEmitter& poe, bool isSuper, PropOpEmitter& poe, bool isSuper,
OptionalEmitter& oe); OptionalEmitter& oe);
MOZ_MUST_USE bool emitOptionalElemExpression(PropertyByValueBase* elem, [[nodiscard]] bool emitOptionalElemExpression(PropertyByValueBase* elem,
ElemOpEmitter& eoe, bool isSuper, ElemOpEmitter& eoe, bool isSuper,
OptionalEmitter& oe); OptionalEmitter& oe);
MOZ_MUST_USE bool emitOptionalCall(BinaryNode* callNode, [[nodiscard]] bool emitOptionalCall(BinaryNode* callNode,
OptionalEmitter& oe, OptionalEmitter& oe,
ValueUsage valueUsage); ValueUsage valueUsage);
MOZ_MUST_USE bool emitDeletePropertyInOptChain(PropertyAccessBase* propExpr, [[nodiscard]] bool emitDeletePropertyInOptChain(PropertyAccessBase* propExpr,
OptionalEmitter& oe); OptionalEmitter& oe);
MOZ_MUST_USE bool emitDeleteElementInOptChain(PropertyByValueBase* elemExpr, [[nodiscard]] bool emitDeleteElementInOptChain(PropertyByValueBase* elemExpr,
OptionalEmitter& oe); OptionalEmitter& oe);
// |op| must be JSOP_TYPEOF or JSOP_TYPEOFEXPR. // |op| must be JSOP_TYPEOF or JSOP_TYPEOFEXPR.
MOZ_MUST_USE bool emitTypeof(UnaryNode* typeofNode, JSOp op); [[nodiscard]] bool emitTypeof(UnaryNode* typeofNode, JSOp op);
MOZ_MUST_USE bool emitUnary(UnaryNode* unaryNode); [[nodiscard]] bool emitUnary(UnaryNode* unaryNode);
MOZ_MUST_USE bool emitRightAssociative(ListNode* node); [[nodiscard]] bool emitRightAssociative(ListNode* node);
MOZ_MUST_USE bool emitLeftAssociative(ListNode* node); [[nodiscard]] bool emitLeftAssociative(ListNode* node);
MOZ_MUST_USE bool emitLogical(ListNode* node); [[nodiscard]] bool emitLogical(ListNode* node);
MOZ_MUST_USE bool emitSequenceExpr(ListNode* node, [[nodiscard]] bool emitSequenceExpr(ListNode* node,
ValueUsage valueUsage = ValueUsage::WantValue); ValueUsage valueUsage = ValueUsage::WantValue);
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitIncOrDec(UnaryNode* incDec); [[nodiscard]] MOZ_NEVER_INLINE bool emitIncOrDec(UnaryNode* incDec);
MOZ_MUST_USE bool emitConditionalExpression(ConditionalExpression& conditional, [[nodiscard]] bool emitConditionalExpression(ConditionalExpression& conditional,
ValueUsage valueUsage = ValueUsage::WantValue); ValueUsage valueUsage = ValueUsage::WantValue);
MOZ_MUST_USE bool isRestParameter(ParseNode* pn); [[nodiscard]] bool isRestParameter(ParseNode* pn);
MOZ_MUST_USE bool emitOptimizeSpread(ParseNode* arg0, JumpList* jmp, bool* emitted); [[nodiscard]] bool emitOptimizeSpread(ParseNode* arg0, JumpList* jmp, bool* emitted);
MOZ_MUST_USE ParseNode* getCoordNode(ParseNode* callNode, ParseNode* calleeNode, [[nodiscard]] ParseNode* getCoordNode(ParseNode* callNode, ParseNode* calleeNode,
ListNode* argsList); ListNode* argsList);
MOZ_MUST_USE bool emitArguments(ListNode* argsList, bool isCall, bool isSpread, [[nodiscard]] bool emitArguments(ListNode* argsList, bool isCall, bool isSpread,
CallOrNewEmitter& cone); CallOrNewEmitter& cone);
MOZ_MUST_USE bool emitCallOrNew(BinaryNode* pn, [[nodiscard]] bool emitCallOrNew(BinaryNode* pn,
ValueUsage valueUsage = ValueUsage::WantValue); ValueUsage valueUsage = ValueUsage::WantValue);
MOZ_MUST_USE bool emitCalleeAndThis(ParseNode* callNode, [[nodiscard]] bool emitCalleeAndThis(ParseNode* callNode,
ParseNode* calleeNode, ParseNode* calleeNode,
CallOrNewEmitter& cone); CallOrNewEmitter& cone);
MOZ_MUST_USE bool emitOptionalCalleeAndThis(ParseNode* callNode, [[nodiscard]] bool emitOptionalCalleeAndThis(ParseNode* callNode,
ParseNode* calleeNode, ParseNode* calleeNode,
CallOrNewEmitter& cone, CallOrNewEmitter& cone,
OptionalEmitter& oe); OptionalEmitter& oe);
MOZ_MUST_USE bool emitSelfHostedCallFunction(BinaryNode* callNode); [[nodiscard]] bool emitSelfHostedCallFunction(BinaryNode* callNode);
MOZ_MUST_USE bool emitSelfHostedResumeGenerator(BinaryNode* callNode); [[nodiscard]] bool emitSelfHostedResumeGenerator(BinaryNode* callNode);
MOZ_MUST_USE bool emitSelfHostedForceInterpreter(ParseNode* pn); [[nodiscard]] bool emitSelfHostedForceInterpreter(ParseNode* pn);
MOZ_MUST_USE bool emitSelfHostedAllowContentIter(BinaryNode* callNode); [[nodiscard]] bool emitSelfHostedAllowContentIter(BinaryNode* callNode);
MOZ_MUST_USE bool emitComprehensionFor(ForNode* forNode); [[nodiscard]] bool emitComprehensionFor(ForNode* forNode);
MOZ_MUST_USE bool emitComprehensionForIn(ForNode* forNode); [[nodiscard]] bool emitComprehensionForIn(ForNode* forNode);
MOZ_MUST_USE bool emitComprehensionForInOrOfVariables(ParseNode* pn, bool* lexicalScope); [[nodiscard]] bool emitComprehensionForInOrOfVariables(ParseNode* pn, bool* lexicalScope);
MOZ_MUST_USE bool emitComprehensionForOf(ForNode* forNode); [[nodiscard]] bool emitComprehensionForOf(ForNode* forNode);
MOZ_MUST_USE bool emitDo(BinaryNode* doNode); [[nodiscard]] bool emitDo(BinaryNode* doNode);
MOZ_MUST_USE bool emitWhile(BinaryNode* whileNode); [[nodiscard]] bool emitWhile(BinaryNode* whileNode);
MOZ_MUST_USE bool emitFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope = nullptr); [[nodiscard]] bool emitFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope = nullptr);
MOZ_MUST_USE bool emitCStyleFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope); [[nodiscard]] bool emitCStyleFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope);
MOZ_MUST_USE bool emitForIn(ForNode* forNode, const EmitterScope* headLexicalEmitterScope); [[nodiscard]] bool emitForIn(ForNode* forNode, const EmitterScope* headLexicalEmitterScope);
MOZ_MUST_USE bool emitForOf(ForNode* forNode, const EmitterScope* headLexicalEmitterScope); [[nodiscard]] bool emitForOf(ForNode* forNode, const EmitterScope* headLexicalEmitterScope);
MOZ_MUST_USE bool emitInitializeForInOrOfTarget(TernaryNode* forHead); [[nodiscard]] bool emitInitializeForInOrOfTarget(TernaryNode* forHead);
MOZ_MUST_USE bool emitBreak(PropertyName* label); [[nodiscard]] bool emitBreak(PropertyName* label);
MOZ_MUST_USE bool emitContinue(PropertyName* label); [[nodiscard]] bool emitContinue(PropertyName* label);
MOZ_MUST_USE bool emitFunctionFormalParameters(ListNode* paramsBody); [[nodiscard]] bool emitFunctionFormalParameters(ListNode* paramsBody);
MOZ_MUST_USE bool emitInitializeFunctionSpecialNames(); [[nodiscard]] bool emitInitializeFunctionSpecialNames();
MOZ_MUST_USE bool emitLexicalInitialization(NameNode* pn); [[nodiscard]] bool emitLexicalInitialization(NameNode* pn);
MOZ_MUST_USE bool emitLexicalInitialization(JSAtom* name); [[nodiscard]] bool emitLexicalInitialization(JSAtom* name);
// Emit bytecode for the spread operator. // Emit bytecode for the spread operator.
// //
@@ -811,9 +811,9 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// |.next()| and put the results into the I-th element of array with // |.next()| and put the results into the I-th element of array with
// incrementing I, then push the result I (it will be original I + // incrementing I, then push the result I (it will be original I +
// iteration count). The stack after iteration will look like |ARRAY INDEX|. // iteration count). The stack after iteration will look like |ARRAY INDEX|.
MOZ_MUST_USE bool emitSpread(bool allowSelfHosted = false); [[nodiscard]] bool emitSpread(bool allowSelfHosted = false);
MOZ_MUST_USE bool emitClass(ClassNode* classNode); [[nodiscard]] bool emitClass(ClassNode* classNode);
}; };
class MOZ_RAII AutoCheckUnstableEmitterScope { class MOZ_RAII AutoCheckUnstableEmitterScope {
Loaded 100 of 358 files, more files were not shown because too many files have changed in this diff. Show more