diff options
author | Moonchild <moonchild@palemoon.org> | 2023-11-04 20:06:50 +0100 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2023-11-08 13:48:12 +0100 |
commit | 706d07b3d560955745a7dd4addb0ea52ac18d94b (patch) | |
tree | 581db1c66c37f92bf7759aae1ef45acc7ad38201 /js/src/vm | |
parent | eb7be8c637b7b382161d009b302ae9713470c553 (diff) | |
download | uxp-706d07b3d560955745a7dd4addb0ea52ac18d94b.tar.gz |
Issue #2342: Use [[nodiscard]] in /js
Diffstat (limited to 'js/src/vm')
27 files changed, 281 insertions, 281 deletions
diff --git a/js/src/vm/ArgumentsObject.h b/js/src/vm/ArgumentsObject.h index 63dc044b0f..46ca2976e6 100644 --- a/js/src/vm/ArgumentsObject.h +++ b/js/src/vm/ArgumentsObject.h @@ -173,7 +173,7 @@ class ArgumentsObject : public NativeObject return data()->rareData; } - MOZ_MUST_USE bool createRareData(JSContext* cx); + [[nodiscard]] bool createRareData(JSContext* cx); RareArgumentsData* getOrCreateRareData(JSContext* cx) { if (!data()->rareData && !createRareData(cx)) diff --git a/js/src/vm/ArrayBufferObject.cpp b/js/src/vm/ArrayBufferObject.cpp index 6ace034adb..79db90ac74 100644 --- a/js/src/vm/ArrayBufferObject.cpp +++ b/js/src/vm/ArrayBufferObject.cpp @@ -548,7 +548,7 @@ class js::WasmArrayRawBuffer } #endif - MOZ_MUST_USE bool growToSizeInPlace(uint32_t oldSize, uint32_t newSize) { + [[nodiscard]] bool growToSizeInPlace(uint32_t oldSize, uint32_t newSize) { MOZ_ASSERT(newSize >= oldSize); MOZ_ASSERT_IF(maxSize(), newSize <= maxSize().value()); MOZ_ASSERT(newSize <= mappedSize()); diff --git a/js/src/vm/ArrayBufferObject.h b/js/src/vm/ArrayBufferObject.h index f4010c6c77..31aae59d06 100644 --- a/js/src/vm/ArrayBufferObject.h +++ b/js/src/vm/ArrayBufferObject.h @@ -339,16 +339,16 @@ class ArrayBufferObject : public ArrayBufferObjectMaybeShared // WebAssembly support: static ArrayBufferObject* createForWasm(JSContext* cx, uint32_t initialSize, mozilla::Maybe<uint32_t> maxSize); - static MOZ_MUST_USE bool prepareForAsmJS(JSContext* cx, Handle<ArrayBufferObject*> buffer, + [[nodiscard]] static bool prepareForAsmJS(JSContext* cx, Handle<ArrayBufferObject*> buffer, bool needGuard); size_t wasmMappedSize() const; mozilla::Maybe<uint32_t> wasmMaxSize() const; - static MOZ_MUST_USE bool wasmGrowToSizeInPlace(uint32_t newSize, + [[nodiscard]] static bool wasmGrowToSizeInPlace(uint32_t newSize, Handle<ArrayBufferObject*> oldBuf, MutableHandle<ArrayBufferObject*> newBuf, JSContext* cx); #ifndef WASM_HUGE_MEMORY - static MOZ_MUST_USE bool wasmMovingGrowToSize(uint32_t newSize, + [[nodiscard]] static bool wasmMovingGrowToSize(uint32_t newSize, Handle<ArrayBufferObject*> oldBuf, MutableHandle<ArrayBufferObject*> newBuf, JSContext* cx); diff --git a/js/src/vm/AsyncFunction.cpp b/js/src/vm/AsyncFunction.cpp index 676ad87fdc..b1d0a111db 100644 --- a/js/src/vm/AsyncFunction.cpp +++ b/js/src/vm/AsyncFunction.cpp @@ -50,8 +50,8 @@ GlobalObject::initAsyncFunction(JSContext* cx, Handle<GlobalObject*> global) return true; } -static MOZ_MUST_USE bool AsyncFunctionStart(JSContext* cx, Handle<PromiseObject*> resultPromise, - HandleValue generatorVal); +[[nodiscard]] static bool AsyncFunctionStart(JSContext* cx, Handle<PromiseObject*> resultPromise, + HandleValue generatorVal); #define UNWRAPPED_ASYNC_WRAPPED_SLOT 1 #define WRAPPED_ASYNC_UNWRAPPED_SLOT 0 @@ -184,7 +184,7 @@ AsyncFunctionResume(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleV } // Async Functions proposal 2.2 steps 3-8. -static MOZ_MUST_USE bool +[[nodiscard]] static bool AsyncFunctionStart(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue generatorVal) { return AsyncFunctionResume(cx, resultPromise, generatorVal, ResumeKind::Normal, UndefinedHandleValue); @@ -194,7 +194,7 @@ AsyncFunctionStart(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleVa // Implemented in js/src/builtin/Promise.cpp // Async Functions proposal 2.4. -MOZ_MUST_USE bool +[[nodiscard]] bool js::AsyncFunctionAwaitedFulfilled(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue generatorVal, HandleValue value) { @@ -205,7 +205,7 @@ js::AsyncFunctionAwaitedFulfilled(JSContext* cx, Handle<PromiseObject*> resultPr } // Async Functions proposal 2.5. -MOZ_MUST_USE bool +[[nodiscard]] bool js::AsyncFunctionAwaitedRejected(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue generatorVal, HandleValue reason) { diff --git a/js/src/vm/AsyncFunction.h b/js/src/vm/AsyncFunction.h index d1f9a44da1..47e7674ed1 100644 --- a/js/src/vm/AsyncFunction.h +++ b/js/src/vm/AsyncFunction.h @@ -26,11 +26,11 @@ WrapAsyncFunctionWithProto(JSContext* cx, HandleFunction unwrapped, HandleObject JSObject* WrapAsyncFunction(JSContext* cx, HandleFunction unwrapped); -MOZ_MUST_USE bool +[[nodiscard]] bool AsyncFunctionAwaitedFulfilled(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue generatorVal, HandleValue value); -MOZ_MUST_USE bool +[[nodiscard]] bool AsyncFunctionAwaitedRejected(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue generatorVal, HandleValue reason); diff --git a/js/src/vm/AsyncIteration.cpp b/js/src/vm/AsyncIteration.cpp index 49fdf7b8d6..fb74d7c7b7 100644 --- a/js/src/vm/AsyncIteration.cpp +++ b/js/src/vm/AsyncIteration.cpp @@ -128,7 +128,7 @@ js::GetUnwrappedAsyncGenerator(JSFunction* wrapped) } // Async Iteration proposal 4.1.1 Await Fulfilled Functions. -MOZ_MUST_USE bool +[[nodiscard]] bool js::AsyncGeneratorAwaitedFulfilled(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value) { @@ -136,7 +136,7 @@ js::AsyncGeneratorAwaitedFulfilled(JSContext* cx, Handle<AsyncGeneratorObject*> } // Async Iteration proposal 4.1.2 Await Rejected Functions. -MOZ_MUST_USE bool +[[nodiscard]] bool js::AsyncGeneratorAwaitedRejected(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue reason) { @@ -144,7 +144,7 @@ js::AsyncGeneratorAwaitedRejected(JSContext* cx, Handle<AsyncGeneratorObject*> a } // Async Iteration proposal 11.4.3.7 step 8.d-e. -MOZ_MUST_USE bool +[[nodiscard]] bool js::AsyncGeneratorYieldReturnAwaitedFulfilled(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value) @@ -153,7 +153,7 @@ js::AsyncGeneratorYieldReturnAwaitedFulfilled(JSContext* cx, } // Async Iteration proposal 11.4.3.7 step 8.d-e. -MOZ_MUST_USE bool +[[nodiscard]] bool js::AsyncGeneratorYieldReturnAwaitedRejected(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue reason) @@ -329,7 +329,7 @@ AsyncGeneratorObject::createRequest(JSContext* cx, Handle<AsyncGeneratorObject*> return request; } -static MOZ_MUST_USE bool +[[nodiscard]] static bool InternalEnqueue(JSContext* cx, HandleArrayObject queue, HandleValue val) { uint32_t length; @@ -346,7 +346,7 @@ InternalEnqueue(JSContext* cx, HandleArrayObject queue, HandleValue val) return SetLengthProperty(cx, queue, length + 1); } -static MOZ_MUST_USE bool +[[nodiscard]] static bool InternalDequeue(JSContext* cx, HandleArrayObject queue, MutableHandleValue val) { uint32_t length; @@ -376,7 +376,7 @@ InternalDequeue(JSContext* cx, HandleArrayObject queue, MutableHandleValue val) return SetLengthProperty(cx, queue, newlength); } -/* static */ MOZ_MUST_USE bool +[[nodiscard]] /* static */ bool AsyncGeneratorObject::enqueueRequest(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, Handle<AsyncGeneratorRequest*> request) { @@ -456,7 +456,7 @@ AsyncGeneratorRequest::create(JSContext* cx, CompletionKind completionKind, } // Async Iteration proposal 11.4.3.2 AsyncGeneratorStart steps 5.d-g. -static MOZ_MUST_USE bool +[[nodiscard]] static bool AsyncGeneratorReturned(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value) { @@ -471,7 +471,7 @@ AsyncGeneratorReturned(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, } // Async Iteration proposal 11.4.3.2 AsyncGeneratorStart steps 5.d, f. -static MOZ_MUST_USE bool +[[nodiscard]] static bool AsyncGeneratorThrown(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj) { // Step 5.d. @@ -492,7 +492,7 @@ AsyncGeneratorThrown(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj) // Async Iteration proposal 11.4.3.7 (partially). // Most steps are done in generator. -static MOZ_MUST_USE bool +[[nodiscard]] static bool AsyncGeneratorYield(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value) { // Step 5 is done in bytecode. @@ -510,7 +510,7 @@ AsyncGeneratorYield(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, Ha // Async Iteration proposal 11.4.3.5 AsyncGeneratorResumeNext // steps 12-14, 16-20. // Execution context switching is handled in generator. -MOZ_MUST_USE bool +[[nodiscard]] bool js::AsyncGeneratorResume(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, CompletionKind completionKind, HandleValue argument) { @@ -578,7 +578,7 @@ static const JSFunctionSpec async_generator_methods[] = { JS_FS_END }; -/* static */ MOZ_MUST_USE bool +[[nodiscard]] /* static */ bool GlobalObject::initAsyncGenerators(JSContext* cx, Handle<GlobalObject*> global) { if (global->getReservedSlot(ASYNC_ITERATOR_PROTO).isObject()) diff --git a/js/src/vm/AsyncIteration.h b/js/src/vm/AsyncIteration.h index d3deb90b1a..cda309e619 100644 --- a/js/src/vm/AsyncIteration.h +++ b/js/src/vm/AsyncIteration.h @@ -35,17 +35,17 @@ GetWrappedAsyncGenerator(JSFunction* unwrapped); JSFunction* GetUnwrappedAsyncGenerator(JSFunction* wrapped); -MOZ_MUST_USE bool +[[nodiscard]] bool AsyncGeneratorAwaitedFulfilled(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value); -MOZ_MUST_USE bool +[[nodiscard]] bool AsyncGeneratorAwaitedRejected(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue reason); -MOZ_MUST_USE bool +[[nodiscard]] bool AsyncGeneratorYieldReturnAwaitedFulfilled(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value); -MOZ_MUST_USE bool +[[nodiscard]] bool AsyncGeneratorYieldReturnAwaitedRejected(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue reason); @@ -209,7 +209,7 @@ class AsyncGeneratorObject : public NativeObject return &getFixedSlot(Slot_Generator).toObject().as<GeneratorObject>(); } - static MOZ_MUST_USE bool + [[nodiscard]] static bool enqueueRequest(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, Handle<AsyncGeneratorRequest*> request); @@ -287,7 +287,7 @@ class AsyncFromSyncIteratorObject : public NativeObject } }; -MOZ_MUST_USE bool +[[nodiscard]] bool AsyncGeneratorResume(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, CompletionKind completionKind, HandleValue argument); diff --git a/js/src/vm/BigIntType.h b/js/src/vm/BigIntType.h index 693f8bf36c..c46e6b98c4 100644 --- a/js/src/vm/BigIntType.h +++ b/js/src/vm/BigIntType.h @@ -223,10 +223,10 @@ class BigInt final : public js::gc::TenuredCell { static size_t calculateMaximumCharactersRequired(HandleBigInt x, unsigned radix); - static MOZ_MUST_USE bool calculateMaximumDigitsRequired(js::ExclusiveContext* cx, - uint8_t radix, - size_t charCount, - size_t* result); + [[nodiscard]] static bool calculateMaximumDigitsRequired(js::ExclusiveContext* cx, + uint8_t radix, + size_t charCount, + size_t* result); static bool absoluteDivWithDigitDivisor( js::ExclusiveContext* cx, Handle<BigInt*> x, Digit divisor, diff --git a/js/src/vm/Debugger.h b/js/src/vm/Debugger.h index 56a6318ba9..e44cb908fd 100644 --- a/js/src/vm/Debugger.h +++ b/js/src/vm/Debugger.h @@ -110,7 +110,7 @@ class DebuggerWeakMap : private WeakMap<HeapPtr<UnbarrieredKey>, HeapPtr<JSObjec using Base::all; using Base::trace; - MOZ_MUST_USE bool init(uint32_t len = 16) { + [[nodiscard]] bool init(uint32_t len = 16) { return Base::init(len) && zoneCounts.init(); } @@ -166,7 +166,7 @@ class DebuggerWeakMap : private WeakMap<HeapPtr<UnbarrieredKey>, HeapPtr<JSObjec Base::assertEntriesNotAboutToBeFinalized(); } - MOZ_MUST_USE bool incZoneCount(JS::Zone* zone) { + [[nodiscard]] bool incZoneCount(JS::Zone* zone) { CountMap::Ptr p = zoneCounts.lookupWithDefault(zone, 0); if (!p) return false; @@ -219,7 +219,7 @@ class MOZ_RAII EvalOptions { ~EvalOptions(); const char* filename() const { return filename_; } unsigned lineno() const { return lineno_; } - MOZ_MUST_USE bool setFilename(JSContext* cx, const char* filename); + [[nodiscard]] bool setFilename(JSContext* cx, const char* filename); void setLineno(unsigned lineno) { lineno_ = lineno; } }; @@ -391,7 +391,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> static const size_t DEFAULT_MAX_LOG_LENGTH = 5000; - MOZ_MUST_USE bool appendAllocationSite(JSContext* cx, HandleObject obj, HandleSavedFrame frame, + [[nodiscard]] bool appendAllocationSite(JSContext* cx, HandleObject obj, HandleSavedFrame frame, double when); /* @@ -417,7 +417,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * debuggee's compartment. The given debuggee global must be observed by at * least one Debugger that is enabled and tracking allocations. */ - static MOZ_MUST_USE bool addAllocationsTracking(JSContext* cx, Handle<GlobalObject*> debuggee); + [[nodiscard]] static bool addAllocationsTracking(JSContext* cx, Handle<GlobalObject*> debuggee); /* * Remove allocations tracking for objects allocated within the given @@ -429,7 +429,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> /* * Add or remove allocations tracking for all debuggees. */ - MOZ_MUST_USE bool addAllocationsTrackingForAllDebuggees(JSContext* cx); + [[nodiscard]] bool addAllocationsTrackingForAllDebuggees(JSContext* cx); void removeAllocationsTrackingForAllDebuggees(); /* @@ -495,7 +495,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> class ScriptQuery; class ObjectQuery; - MOZ_MUST_USE bool addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> obj); + [[nodiscard]] bool addDebuggeeGlobal(JSContext* cx, Handle<GlobalObject*> obj); void removeDebuggeeGlobal(FreeOp* fop, GlobalObject* global, WeakGlobalObjectSet::Enum* debugEnum); @@ -586,8 +586,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger> static const Class class_; private: - static MOZ_MUST_USE bool getHookImpl(JSContext* cx, CallArgs& args, Debugger& dbg, Hook which); - static MOZ_MUST_USE bool setHookImpl(JSContext* cx, CallArgs& args, Debugger& dbg, Hook which); + [[nodiscard]] static bool getHookImpl(JSContext* cx, CallArgs& args, Debugger& dbg, Hook which); + [[nodiscard]] static bool setHookImpl(JSContext* cx, CallArgs& args, Debugger& dbg, Hook which); static bool getEnabled(JSContext* cx, unsigned argc, Value* vp); static bool setEnabled(JSContext* cx, unsigned argc, Value* vp); @@ -656,15 +656,15 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * compute it ourselves from |frame|. */ using DebuggerFrameVector = GCVector<DebuggerFrame*>; - static MOZ_MUST_USE bool getDebuggerFrames(AbstractFramePtr frame, + [[nodiscard]] static bool getDebuggerFrames(AbstractFramePtr frame, MutableHandle<DebuggerFrameVector> frames); public: - static MOZ_MUST_USE bool ensureExecutionObservabilityOfOsrFrame(JSContext* cx, + [[nodiscard]] static bool ensureExecutionObservabilityOfOsrFrame(JSContext* cx, InterpreterFrame* frame); // Public for DebuggerScript_setBreakpoint. - static MOZ_MUST_USE bool ensureExecutionObservabilityOfScript(JSContext* cx, JSScript* script); + [[nodiscard]] static bool ensureExecutionObservabilityOfScript(JSContext* cx, JSScript* script); // Whether the Debugger instance needs to observe all non-AOT JS // execution of its debugees. @@ -679,30 +679,30 @@ class Debugger : private mozilla::LinkedListElement<Debugger> IsObserving observesCoverage() const; private: - static MOZ_MUST_USE bool ensureExecutionObservabilityOfFrame(JSContext* cx, + [[nodiscard]] static bool ensureExecutionObservabilityOfFrame(JSContext* cx, AbstractFramePtr frame); - static MOZ_MUST_USE bool ensureExecutionObservabilityOfCompartment(JSContext* cx, + [[nodiscard]] static bool ensureExecutionObservabilityOfCompartment(JSContext* cx, JSCompartment* comp); static bool hookObservesAllExecution(Hook which); - MOZ_MUST_USE bool updateObservesAllExecutionOnDebuggees(JSContext* cx, IsObserving observing); - MOZ_MUST_USE bool updateObservesCoverageOnDebuggees(JSContext* cx, IsObserving observing); + [[nodiscard]] bool updateObservesAllExecutionOnDebuggees(JSContext* cx, IsObserving observing); + [[nodiscard]] bool updateObservesCoverageOnDebuggees(JSContext* cx, IsObserving observing); void updateObservesAsmJSOnDebuggees(IsObserving observing); JSObject* getHook(Hook hook) const; bool hasAnyLiveHooks(JSRuntime* rt) const; - static MOZ_MUST_USE bool slowPathCheckNoExecute(JSContext* cx, HandleScript script); + [[nodiscard]] static bool slowPathCheckNoExecute(JSContext* cx, HandleScript script); static JSTrapStatus slowPathOnEnterFrame(JSContext* cx, AbstractFramePtr frame); - static MOZ_MUST_USE bool slowPathOnLeaveFrame(JSContext* cx, AbstractFramePtr frame, + [[nodiscard]] static bool slowPathOnLeaveFrame(JSContext* cx, AbstractFramePtr frame, jsbytecode* pc, bool ok); static JSTrapStatus slowPathOnDebuggerStatement(JSContext* cx, AbstractFramePtr frame); static JSTrapStatus slowPathOnExceptionUnwind(JSContext* cx, AbstractFramePtr frame); static void slowPathOnNewScript(JSContext* cx, HandleScript script); static void slowPathOnNewWasmInstance(JSContext* cx, Handle<WasmInstanceObject*> wasmInstance); static void slowPathOnNewGlobalObject(JSContext* cx, Handle<GlobalObject*> global); - static MOZ_MUST_USE bool slowPathOnLogAllocationSite(JSContext* cx, HandleObject obj, + [[nodiscard]] static bool slowPathOnLogAllocationSite(JSContext* cx, HandleObject obj, HandleSavedFrame frame, double when, GlobalObject::DebuggerVector& dbgs); static void slowPathPromiseHook(JSContext* cx, Hook hook, HandleObject promise); @@ -768,10 +768,10 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * Gets a Debugger.Frame object. If maybeIter is non-null, we eagerly copy * its data if we need to make a new Debugger.Frame. */ - MOZ_MUST_USE bool getScriptFrameWithIter(JSContext* cx, AbstractFramePtr frame, + [[nodiscard]] bool getScriptFrameWithIter(JSContext* cx, AbstractFramePtr frame, const ScriptFrameIter* maybeIter, MutableHandleValue vp); - MOZ_MUST_USE bool getScriptFrameWithIter(JSContext* cx, AbstractFramePtr frame, + [[nodiscard]] bool getScriptFrameWithIter(JSContext* cx, AbstractFramePtr frame, const ScriptFrameIter* maybeIter, MutableHandleDebuggerFrame result); @@ -779,7 +779,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> static inline Debugger* fromOnNewGlobalObjectWatchersLink(JSCList* link); - static MOZ_MUST_USE bool replaceFrameGuts(JSContext* cx, AbstractFramePtr from, + [[nodiscard]] static bool replaceFrameGuts(JSContext* cx, AbstractFramePtr from, AbstractFramePtr to, ScriptFrameIter& iter); @@ -787,7 +787,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> Debugger(JSContext* cx, NativeObject* dbg); ~Debugger(); - MOZ_MUST_USE bool init(JSContext* cx); + [[nodiscard]] bool init(JSContext* cx); inline const js::GCPtrNativeObject& toJSObject() const; inline js::GCPtrNativeObject& toJSObjectRef(); static inline Debugger* fromJSObject(const JSObject* obj); @@ -816,14 +816,14 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * them and returns true. If not, it returns false. */ static void markIncomingCrossCompartmentEdges(JSTracer* tracer); - static MOZ_MUST_USE bool markAllIteratively(GCMarker* trc); + [[nodiscard]] static bool markAllIteratively(GCMarker* trc); static void markAll(JSTracer* trc); static void sweepAll(FreeOp* fop); static void detachAllDebuggersFromGlobal(FreeOp* fop, GlobalObject* global); static void findZoneEdges(JS::Zone* v, gc::ZoneComponentFinder& finder); // Checks it the current compartment is allowed to execute code. - static inline MOZ_MUST_USE bool checkNoExecute(JSContext* cx, HandleScript script); + [[nodiscard]] static inline bool checkNoExecute(JSContext* cx, HandleScript script); /* * JSTrapStatus Overview @@ -883,19 +883,19 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * throw, or vice versa: we can redirect to a complete copy of the * alternative path, containing its own call to onLeaveFrame.) */ - static inline MOZ_MUST_USE bool onLeaveFrame(JSContext* cx, AbstractFramePtr frame, + [[nodiscard]] static inline bool onLeaveFrame(JSContext* cx, AbstractFramePtr frame, jsbytecode* pc, bool ok); static inline void onNewScript(JSContext* cx, HandleScript script); static inline void onNewWasmInstance(JSContext* cx, Handle<WasmInstanceObject*> wasmInstance); static inline void onNewGlobalObject(JSContext* cx, Handle<GlobalObject*> global); - static inline MOZ_MUST_USE bool onLogAllocationSite(JSContext* cx, JSObject* obj, + [[nodiscard]] static inline bool onLogAllocationSite(JSContext* cx, JSObject* obj, HandleSavedFrame frame, double when); static JSTrapStatus onTrap(JSContext* cx, MutableHandleValue vp); static JSTrapStatus onSingleStep(JSContext* cx, MutableHandleValue vp); - static MOZ_MUST_USE bool handleBaselineOsr(JSContext* cx, InterpreterFrame* from, + [[nodiscard]] static bool handleBaselineOsr(JSContext* cx, InterpreterFrame* from, jit::BaselineFrame* to); - static MOZ_MUST_USE bool handleIonBailout(JSContext* cx, jit::RematerializedFrame* from, + [[nodiscard]] static bool handleIonBailout(JSContext* cx, jit::RematerializedFrame* from, jit::BaselineFrame* to); static void handleUnrecoverableIonBailoutError(JSContext* cx, jit::RematerializedFrame* frame); static void propagateForcedReturn(JSContext* cx, AbstractFramePtr frame, HandleValue rval); @@ -917,8 +917,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * or create a Debugger.Environment object for the given Env. On success, * store the Environment object in *vp and return true. */ - MOZ_MUST_USE bool wrapEnvironment(JSContext* cx, Handle<Env*> env, MutableHandleValue vp); - MOZ_MUST_USE bool wrapEnvironment(JSContext* cx, Handle<Env*> env, + [[nodiscard]] bool wrapEnvironment(JSContext* cx, Handle<Env*> env, MutableHandleValue vp); + [[nodiscard]] bool wrapEnvironment(JSContext* cx, Handle<Env*> env, MutableHandleDebuggerEnvironment result); /* @@ -941,8 +941,8 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * unaccessible uninitialized binding, this produces a plain object of the * form { uninitialized: true }. */ - MOZ_MUST_USE bool wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp); - MOZ_MUST_USE bool wrapDebuggeeObject(JSContext* cx, HandleObject obj, + [[nodiscard]] bool wrapDebuggeeValue(JSContext* cx, MutableHandleValue vp); + [[nodiscard]] bool wrapDebuggeeObject(JSContext* cx, HandleObject obj, MutableHandleDebuggerObject result); /* @@ -972,9 +972,9 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * debugger compartment--mirror symmetry. But compartment wrapping always * happens in the target compartment--rotational symmetry.) */ - MOZ_MUST_USE bool unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp); - MOZ_MUST_USE bool unwrapDebuggeeObject(JSContext* cx, MutableHandleObject obj); - MOZ_MUST_USE bool unwrapPropertyDescriptor(JSContext* cx, HandleObject obj, + [[nodiscard]] bool unwrapDebuggeeValue(JSContext* cx, MutableHandleValue vp); + [[nodiscard]] bool unwrapDebuggeeObject(JSContext* cx, MutableHandleObject obj); + [[nodiscard]] bool unwrapPropertyDescriptor(JSContext* cx, HandleObject obj, MutableHandle<PropertyDescriptor> desc); /* @@ -983,7 +983,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * Use this if you have already access to a frame pointer without having * to incur the cost of walking the stack. */ - MOZ_MUST_USE bool getScriptFrame(JSContext* cx, AbstractFramePtr frame, MutableHandleValue vp) { + [[nodiscard]] bool getScriptFrame(JSContext* cx, AbstractFramePtr frame, MutableHandleValue vp) { return getScriptFrameWithIter(cx, frame, nullptr, vp); } @@ -995,11 +995,11 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * frame, in which case the cost of walking the stack has already been * paid. */ - MOZ_MUST_USE bool getScriptFrame(JSContext* cx, const ScriptFrameIter& iter, + [[nodiscard]] bool getScriptFrame(JSContext* cx, const ScriptFrameIter& iter, MutableHandleValue vp) { return getScriptFrameWithIter(cx, iter.abstractFramePtr(), &iter, vp); } - MOZ_MUST_USE bool getScriptFrame(JSContext* cx, const ScriptFrameIter& iter, + [[nodiscard]] bool getScriptFrame(JSContext* cx, const ScriptFrameIter& iter, MutableHandleDebuggerFrame result); @@ -1018,7 +1018,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * and |value|. |value| should be the return value or exception value, not * wrapped as a debuggee value. |cx| must be in the debugger compartment. */ - MOZ_MUST_USE bool newCompletionValue(JSContext* cx, JSTrapStatus status, const Value& value, + [[nodiscard]] bool newCompletionValue(JSContext* cx, JSTrapStatus status, const Value& value, MutableHandleValue result); /* @@ -1033,7 +1033,7 @@ class Debugger : private mozilla::LinkedListElement<Debugger> * pending exception. (This ordinarily returns true even if the ok argument * is false.) */ - MOZ_MUST_USE bool receiveCompletionValue(mozilla::Maybe<AutoCompartment>& ac, bool ok, + [[nodiscard]] bool receiveCompletionValue(mozilla::Maybe<AutoCompartment>& ac, bool ok, HandleValue val, MutableHandleValue vp); @@ -1094,19 +1094,19 @@ class DebuggerEnvironment : public NativeObject HandleNativeObject debugger); DebuggerEnvironmentType type() const; - MOZ_MUST_USE bool getParent(JSContext* cx, MutableHandleDebuggerEnvironment result) const; - MOZ_MUST_USE bool getObject(JSContext* cx, MutableHandleDebuggerObject result) const; - MOZ_MUST_USE bool getCallee(JSContext* cx, MutableHandleDebuggerObject result) const; + [[nodiscard]] bool getParent(JSContext* cx, MutableHandleDebuggerEnvironment result) const; + [[nodiscard]] bool getObject(JSContext* cx, MutableHandleDebuggerObject result) const; + [[nodiscard]] bool getCallee(JSContext* cx, MutableHandleDebuggerObject result) const; bool isDebuggee() const; bool isOptimized() const; - static MOZ_MUST_USE bool getNames(JSContext* cx, HandleDebuggerEnvironment environment, + [[nodiscard]] static bool getNames(JSContext* cx, HandleDebuggerEnvironment environment, MutableHandle<IdVector> result); - static MOZ_MUST_USE bool find(JSContext* cx, HandleDebuggerEnvironment environment, + [[nodiscard]] static bool find(JSContext* cx, HandleDebuggerEnvironment environment, HandleId id, MutableHandleDebuggerEnvironment result); - static MOZ_MUST_USE bool getVariable(JSContext* cx, HandleDebuggerEnvironment environment, + [[nodiscard]] static bool getVariable(JSContext* cx, HandleDebuggerEnvironment environment, HandleId id, MutableHandleValue result); - static MOZ_MUST_USE bool setVariable(JSContext* cx, HandleDebuggerEnvironment environment, + [[nodiscard]] static bool setVariable(JSContext* cx, HandleDebuggerEnvironment environment, HandleId id, HandleValue value); private: @@ -1125,19 +1125,19 @@ class DebuggerEnvironment : public NativeObject bool requireDebuggee(JSContext* cx) const; - static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool typeGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool parentGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool objectGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool calleeGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool inspectableGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool optimizedOutGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool typeGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool parentGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool objectGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool calleeGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool inspectableGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool optimizedOutGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool namesMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool findMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool getVariableMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool setVariableMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool namesMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool findMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool getVariableMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool setVariableMethod(JSContext* cx, unsigned argc, Value* vp); }; enum class DebuggerFrameType { @@ -1168,22 +1168,22 @@ class DebuggerFrame : public NativeObject static DebuggerFrame* create(JSContext* cx, HandleObject proto, AbstractFramePtr referent, const ScriptFrameIter* maybeIter, HandleNativeObject debugger); - static MOZ_MUST_USE bool getCallee(JSContext* cx, HandleDebuggerFrame frame, + [[nodiscard]] static bool getCallee(JSContext* cx, HandleDebuggerFrame frame, MutableHandleDebuggerObject result); - static MOZ_MUST_USE bool getIsConstructing(JSContext* cx, HandleDebuggerFrame frame, + [[nodiscard]] static bool getIsConstructing(JSContext* cx, HandleDebuggerFrame frame, bool& result); - static MOZ_MUST_USE bool getEnvironment(JSContext* cx, HandleDebuggerFrame frame, + [[nodiscard]] static bool getEnvironment(JSContext* cx, HandleDebuggerFrame frame, MutableHandleDebuggerEnvironment result); static bool getIsGenerator(HandleDebuggerFrame frame); - static MOZ_MUST_USE bool getOffset(JSContext* cx, HandleDebuggerFrame frame, size_t& result); - static MOZ_MUST_USE bool getOlder(JSContext* cx, HandleDebuggerFrame frame, + [[nodiscard]] static bool getOffset(JSContext* cx, HandleDebuggerFrame frame, size_t& result); + [[nodiscard]] static bool getOlder(JSContext* cx, HandleDebuggerFrame frame, MutableHandleDebuggerFrame result); - static MOZ_MUST_USE bool getThis(JSContext* cx, HandleDebuggerFrame frame, + [[nodiscard]] static bool getThis(JSContext* cx, HandleDebuggerFrame frame, MutableHandleValue result); static DebuggerFrameType getType(HandleDebuggerFrame frame); static DebuggerFrameImplementation getImplementation(HandleDebuggerFrame frame); - static MOZ_MUST_USE bool eval(JSContext* cx, HandleDebuggerFrame frame, + [[nodiscard]] static bool eval(JSContext* cx, HandleDebuggerFrame frame, mozilla::Range<const char16_t> chars, HandleObject bindings, const EvalOptions& options, JSTrapStatus& status, MutableHandleValue value); @@ -1197,24 +1197,24 @@ class DebuggerFrame : public NativeObject static const JSFunctionSpec methods_[]; static AbstractFramePtr getReferent(HandleDebuggerFrame frame); - static MOZ_MUST_USE bool getScriptFrameIter(JSContext* cx, HandleDebuggerFrame frame, + [[nodiscard]] static bool getScriptFrameIter(JSContext* cx, HandleDebuggerFrame frame, mozilla::Maybe<ScriptFrameIter>& result); - static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool calleeGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool constructingGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool environmentGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool generatorGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool liveGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool offsetGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool olderGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool thisGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool typeGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool implementationGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool calleeGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool constructingGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool environmentGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool generatorGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool liveGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool offsetGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool olderGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool thisGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool typeGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool implementationGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool evalMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool evalWithBindingsMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool evalMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool evalWithBindingsMethod(JSContext* cx, unsigned argc, Value* vp); Debugger* owner() const; }; @@ -1229,75 +1229,75 @@ class DebuggerObject : public NativeObject HandleNativeObject debugger); // Properties - static MOZ_MUST_USE bool getClassName(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getClassName(JSContext* cx, HandleDebuggerObject object, MutableHandleString result); - static MOZ_MUST_USE bool getGlobal(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getGlobal(JSContext* cx, HandleDebuggerObject object, MutableHandleDebuggerObject result); - static MOZ_MUST_USE bool getParameterNames(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getParameterNames(JSContext* cx, HandleDebuggerObject object, MutableHandle<StringVector> result); - static MOZ_MUST_USE bool getBoundTargetFunction(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getBoundTargetFunction(JSContext* cx, HandleDebuggerObject object, MutableHandleDebuggerObject result); - static MOZ_MUST_USE bool getBoundThis(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getBoundThis(JSContext* cx, HandleDebuggerObject object, MutableHandleValue result); - static MOZ_MUST_USE bool getBoundArguments(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getBoundArguments(JSContext* cx, HandleDebuggerObject object, MutableHandle<ValueVector> result); - static MOZ_MUST_USE bool getAllocationSite(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getAllocationSite(JSContext* cx, HandleDebuggerObject object, MutableHandleObject result); - static MOZ_MUST_USE bool getErrorMessageName(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getErrorMessageName(JSContext* cx, HandleDebuggerObject object, MutableHandleString result); - static MOZ_MUST_USE bool getErrorNotes(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getErrorNotes(JSContext* cx, HandleDebuggerObject object, MutableHandleValue result); - static MOZ_MUST_USE bool getErrorLineNumber(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getErrorLineNumber(JSContext* cx, HandleDebuggerObject object, MutableHandleValue result); - static MOZ_MUST_USE bool getErrorColumnNumber(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getErrorColumnNumber(JSContext* cx, HandleDebuggerObject object, MutableHandleValue result); - static MOZ_MUST_USE bool getScriptedProxyTarget(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getScriptedProxyTarget(JSContext* cx, HandleDebuggerObject object, MutableHandleDebuggerObject result); - static MOZ_MUST_USE bool getScriptedProxyHandler(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getScriptedProxyHandler(JSContext* cx, HandleDebuggerObject object, MutableHandleDebuggerObject result); - static MOZ_MUST_USE bool getPromiseValue(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getPromiseValue(JSContext* cx, HandleDebuggerObject object, MutableHandleValue result); - static MOZ_MUST_USE bool getPromiseReason(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getPromiseReason(JSContext* cx, HandleDebuggerObject object, MutableHandleValue result); // Methods - static MOZ_MUST_USE bool isExtensible(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool isExtensible(JSContext* cx, HandleDebuggerObject object, bool& result); - static MOZ_MUST_USE bool isSealed(JSContext* cx, HandleDebuggerObject object, bool& result); - static MOZ_MUST_USE bool isFrozen(JSContext* cx, HandleDebuggerObject object, bool& result); - static MOZ_MUST_USE bool getPrototypeOf(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool isSealed(JSContext* cx, HandleDebuggerObject object, bool& result); + [[nodiscard]] static bool isFrozen(JSContext* cx, HandleDebuggerObject object, bool& result); + [[nodiscard]] static bool getPrototypeOf(JSContext* cx, HandleDebuggerObject object, MutableHandleDebuggerObject result); - static MOZ_MUST_USE bool getOwnPropertyNames(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getOwnPropertyNames(JSContext* cx, HandleDebuggerObject object, MutableHandle<IdVector> result); - static MOZ_MUST_USE bool getOwnPropertySymbols(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getOwnPropertySymbols(JSContext* cx, HandleDebuggerObject object, MutableHandle<IdVector> result); - static MOZ_MUST_USE bool getOwnPropertyDescriptor(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool getOwnPropertyDescriptor(JSContext* cx, HandleDebuggerObject object, HandleId id, MutableHandle<PropertyDescriptor> desc); - static MOZ_MUST_USE bool preventExtensions(JSContext* cx, HandleDebuggerObject object); - static MOZ_MUST_USE bool seal(JSContext* cx, HandleDebuggerObject object); - static MOZ_MUST_USE bool freeze(JSContext* cx, HandleDebuggerObject object); - static MOZ_MUST_USE bool defineProperty(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool preventExtensions(JSContext* cx, HandleDebuggerObject object); + [[nodiscard]] static bool seal(JSContext* cx, HandleDebuggerObject object); + [[nodiscard]] static bool freeze(JSContext* cx, HandleDebuggerObject object); + [[nodiscard]] static bool defineProperty(JSContext* cx, HandleDebuggerObject object, HandleId id, Handle<PropertyDescriptor> desc); - static MOZ_MUST_USE bool defineProperties(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool defineProperties(JSContext* cx, HandleDebuggerObject object, Handle<IdVector> ids, Handle<PropertyDescriptorVector> descs); - static MOZ_MUST_USE bool deleteProperty(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool deleteProperty(JSContext* cx, HandleDebuggerObject object, HandleId id, ObjectOpResult& result); - static MOZ_MUST_USE bool call(JSContext* cx, HandleDebuggerObject object, HandleValue thisv, + [[nodiscard]] static bool call(JSContext* cx, HandleDebuggerObject object, HandleValue thisv, Handle<ValueVector> args, MutableHandleValue result); - static MOZ_MUST_USE bool forceLexicalInitializationByName(JSContext* cx, + [[nodiscard]] static bool forceLexicalInitializationByName(JSContext* cx, HandleDebuggerObject object, HandleId id, bool& result); - static MOZ_MUST_USE bool executeInGlobal(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool executeInGlobal(JSContext* cx, HandleDebuggerObject object, mozilla::Range<const char16_t> chars, HandleObject bindings, const EvalOptions& options, JSTrapStatus& status, MutableHandleValue value); - static MOZ_MUST_USE bool makeDebuggeeValue(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool makeDebuggeeValue(JSContext* cx, HandleDebuggerObject object, HandleValue value, MutableHandleValue result); - static MOZ_MUST_USE bool unsafeDereference(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool unsafeDereference(JSContext* cx, HandleDebuggerObject object, MutableHandleObject result); - static MOZ_MUST_USE bool unwrap(JSContext* cx, HandleDebuggerObject object, + [[nodiscard]] static bool unwrap(JSContext* cx, HandleDebuggerObject object, MutableHandleDebuggerObject result); // Infallible properties @@ -1338,68 +1338,68 @@ class DebuggerObject : public NativeObject PromiseObject* promise() const; - static MOZ_MUST_USE bool requireGlobal(JSContext* cx, HandleDebuggerObject object); - static MOZ_MUST_USE bool requirePromise(JSContext* cx, HandleDebuggerObject object); + [[nodiscard]] static bool requireGlobal(JSContext* cx, HandleDebuggerObject object); + [[nodiscard]] static bool requirePromise(JSContext* cx, HandleDebuggerObject object); - static MOZ_MUST_USE bool construct(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool construct(JSContext* cx, unsigned argc, Value* vp); // JSNative properties - static MOZ_MUST_USE bool callableGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool isBoundFunctionGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool isArrowFunctionGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool protoGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool classGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool nameGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool displayNameGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool parameterNamesGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool scriptGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool environmentGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool boundTargetFunctionGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool boundThisGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool boundArgumentsGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool globalGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool allocationSiteGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool errorMessageNameGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool errorNotesGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool errorLineNumberGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool errorColumnNumberGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool isProxyGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool proxyTargetGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool proxyHandlerGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool isPromiseGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseStateGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseValueGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseReasonGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseLifetimeGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseTimeToResolutionGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseAllocationSiteGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseResolutionSiteGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseIDGetter(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool promiseDependentPromisesGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool callableGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool isBoundFunctionGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool isArrowFunctionGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool protoGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool classGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool nameGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool displayNameGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool parameterNamesGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool scriptGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool environmentGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool boundTargetFunctionGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool boundThisGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool boundArgumentsGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool globalGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool allocationSiteGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool errorMessageNameGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool errorNotesGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool errorLineNumberGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool errorColumnNumberGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool isProxyGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool proxyTargetGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool proxyHandlerGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool isPromiseGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseStateGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseValueGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseReasonGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseLifetimeGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseTimeToResolutionGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseAllocationSiteGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseResolutionSiteGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseIDGetter(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool promiseDependentPromisesGetter(JSContext* cx, unsigned argc, Value* vp); // JSNative methods - static MOZ_MUST_USE bool isExtensibleMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool isSealedMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool isFrozenMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool getOwnPropertyNamesMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool getOwnPropertySymbolsMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool getOwnPropertyDescriptorMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool preventExtensionsMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool sealMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool freezeMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool definePropertyMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool definePropertiesMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool deletePropertyMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool callMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool applyMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool asEnvironmentMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool forceLexicalInitializationByNameMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool executeInGlobalMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool executeInGlobalWithBindingsMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool makeDebuggeeValueMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool unsafeDereferenceMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool unwrapMethod(JSContext* cx, unsigned argc, Value* vp); - static MOZ_MUST_USE bool getErrorReport(JSContext* cx, HandleObject maybeError, + [[nodiscard]] static bool isExtensibleMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool isSealedMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool isFrozenMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool getOwnPropertyNamesMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool getOwnPropertySymbolsMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool getOwnPropertyDescriptorMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool preventExtensionsMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool sealMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool freezeMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool definePropertyMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool definePropertiesMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool deletePropertyMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool callMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool applyMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool asEnvironmentMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool forceLexicalInitializationByNameMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool executeInGlobalMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool executeInGlobalWithBindingsMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool makeDebuggeeValueMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool unsafeDereferenceMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool unwrapMethod(JSContext* cx, unsigned argc, Value* vp); + [[nodiscard]] static bool getErrorReport(JSContext* cx, HandleObject maybeError, JSErrorReport*& report); }; @@ -1557,7 +1557,7 @@ Debugger::onLogAllocationSite(JSContext* cx, JSObject* obj, HandleSavedFrame fra return Debugger::slowPathOnLogAllocationSite(cx, hobj, frame, when, *dbgs); } -MOZ_MUST_USE bool ReportObjectRequired(JSContext* cx); +[[nodiscard]] bool ReportObjectRequired(JSContext* cx); } /* namespace js */ diff --git a/js/src/vm/EnvironmentObject.h b/js/src/vm/EnvironmentObject.h index a74018047a..b38ba15a93 100644 --- a/js/src/vm/EnvironmentObject.h +++ b/js/src/vm/EnvironmentObject.h @@ -1083,35 +1083,35 @@ FindScriptOrModulePrivateForScript(JSScript* script); ModuleEnvironmentObject* GetModuleEnvironmentForScript(JSScript* script); -MOZ_MUST_USE bool +[[nodiscard]] bool GetThisValueForDebuggerMaybeOptimizedOut(JSContext* cx, AbstractFramePtr frame, jsbytecode* pc, MutableHandleValue res); -MOZ_MUST_USE bool +[[nodiscard]] bool CheckVarNameConflict(JSContext* cx, Handle<LexicalEnvironmentObject*> lexicalEnv, HandlePropertyName name); -MOZ_MUST_USE bool +[[nodiscard]] bool CheckCanDeclareGlobalBinding(JSContext* cx, Handle<GlobalObject*> global, HandlePropertyName name, bool isFunction); -MOZ_MUST_USE bool +[[nodiscard]] bool CheckLexicalNameConflict(JSContext* cx, Handle<LexicalEnvironmentObject*> lexicalEnv, HandleObject varObj, HandlePropertyName name); -MOZ_MUST_USE bool +[[nodiscard]] bool CheckGlobalDeclarationConflicts(JSContext* cx, HandleScript script, Handle<LexicalEnvironmentObject*> lexicalEnv, HandleObject varObj); -MOZ_MUST_USE bool +[[nodiscard]] bool CheckEvalDeclarationConflicts(JSContext* cx, HandleScript script, HandleObject envChain, HandleObject varObj); -MOZ_MUST_USE bool +[[nodiscard]] bool InitFunctionEnvironmentObjects(JSContext* cx, AbstractFramePtr frame); -MOZ_MUST_USE bool +[[nodiscard]] bool PushVarEnvironmentObject(JSContext* cx, HandleScope scope, AbstractFramePtr frame); #ifdef DEBUG diff --git a/js/src/vm/ErrorReporting.h b/js/src/vm/ErrorReporting.h index ed061e6428..96f3ef6f49 100644 --- a/js/src/vm/ErrorReporting.h +++ b/js/src/vm/ErrorReporting.h @@ -81,7 +81,7 @@ ReportCompileError(ErrorMetadata&& metadata, UniquePtr<JSErrorNotes> notes, * This function DOES NOT respect an existing werror option. If the caller * wishes such option to be respected, it must do so itself. */ -extern MOZ_MUST_USE bool +[[nodiscard]] extern bool ReportCompileWarning(JSContext* cx, ErrorMetadata&& metadata, UniquePtr<JSErrorNotes> notes, unsigned flags, unsigned errorNumber, va_list args); diff --git a/js/src/vm/GeneratorObject.cpp b/js/src/vm/GeneratorObject.cpp index f0718c0f86..4c789e1da8 100644 --- a/js/src/vm/GeneratorObject.cpp +++ b/js/src/vm/GeneratorObject.cpp @@ -371,7 +371,7 @@ GlobalObject::initStarGenerators(JSContext* cx, Handle<GlobalObject*> global) return true; } -MOZ_MUST_USE bool +[[nodiscard]] bool js::CheckStarGeneratorResumptionValue(JSContext* cx, HandleValue v) { // yield/return value should be an Object. diff --git a/js/src/vm/GeneratorObject.h b/js/src/vm/GeneratorObject.h index c717d25e66..d5d7e7dbc2 100644 --- a/js/src/vm/GeneratorObject.h +++ b/js/src/vm/GeneratorObject.h @@ -226,7 +226,7 @@ bool GeneratorThrowOrClose(JSContext* cx, AbstractFramePtr frame, Handle<Generat HandleValue val, uint32_t resumeKind); void SetReturnValueForClosingGenerator(JSContext* cx, AbstractFramePtr frame); -MOZ_MUST_USE bool +[[nodiscard]] bool CheckStarGeneratorResumptionValue(JSContext* cx, HandleValue v); } // namespace js diff --git a/js/src/vm/NativeObject.h b/js/src/vm/NativeObject.h index 86977d109f..56c9ba7f09 100644 --- a/js/src/vm/NativeObject.h +++ b/js/src/vm/NativeObject.h @@ -515,7 +515,7 @@ class NativeObject : public ShapedObject */ bool setSlotSpan(ExclusiveContext* cx, uint32_t span); - static MOZ_MUST_USE bool toDictionaryMode(ExclusiveContext* cx, HandleNativeObject obj); + [[nodiscard]] static bool toDictionaryMode(ExclusiveContext* cx, HandleNativeObject obj); private: friend class TenuringTracer; @@ -614,13 +614,13 @@ class NativeObject : public ShapedObject } public: - static MOZ_MUST_USE bool generateOwnShape(ExclusiveContext* cx, HandleNativeObject obj, + [[nodiscard]] static bool generateOwnShape(ExclusiveContext* cx, HandleNativeObject obj, Shape* newShape = nullptr) { return replaceWithNewEquivalentShape(cx, obj, obj->lastProperty(), newShape); } - static MOZ_MUST_USE bool shadowingShapeChange(ExclusiveContext* cx, HandleNativeObject obj, + [[nodiscard]] static bool shadowingShapeChange(ExclusiveContext* cx, HandleNativeObject obj, const Shape& shape); static bool clearFlag(ExclusiveContext* cx, HandleNativeObject obj, BaseShape::Flag flag); @@ -794,7 +794,7 @@ class NativeObject : public ShapedObject unsigned flags, ShapeTable::Entry* entry, bool allowDictionary, const AutoKeepShapeTables& keep); - static MOZ_MUST_USE bool fillInAfterSwap(JSContext* cx, HandleNativeObject obj, + [[nodiscard]] static bool fillInAfterSwap(JSContext* cx, HandleNativeObject obj, const Vector<Value>& values, void* priv); public: diff --git a/js/src/vm/Printer.h b/js/src/vm/Printer.h index 60f1a62716..9f96e6f16d 100644 --- a/js/src/vm/Printer.h +++ b/js/src/vm/Printer.h @@ -83,14 +83,14 @@ class Sprinter final : public GenericPrinter size_t size; // size of buffer allocated at base ptrdiff_t offset; // offset of next free char in buffer - MOZ_MUST_USE bool realloc_(size_t newSize); + [[nodiscard]] bool realloc_(size_t newSize); public: explicit Sprinter(ExclusiveContext* cx, bool shouldReportOOM = true); ~Sprinter(); // Initialize this sprinter, returns false on error. - MOZ_MUST_USE bool init(); + [[nodiscard]] bool init(); void checkInvariants() const; @@ -114,7 +114,7 @@ class Sprinter final : public GenericPrinter // Format the given format/arguments as if by JS_vsmprintf, then put it. // Return true on success, else return false and report an error (typically // OOM). - MOZ_MUST_USE bool jsprintf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3); + [[nodiscard]] bool jsprintf(const char* fmt, ...) MOZ_FORMAT_PRINTF(2, 3); // Prints a formatted string into the buffer. virtual int vprintf(const char* fmt, va_list ap) override; @@ -142,7 +142,7 @@ class Fprinter final : public GenericPrinter ~Fprinter(); // Initialize this printer, returns false on error. - MOZ_MUST_USE bool init(const char* path); + [[nodiscard]] bool init(const char* path); void init(FILE* fp); bool isInitialized() const { return file_ != nullptr; diff --git a/js/src/vm/RegExpObject.h b/js/src/vm/RegExpObject.h index 5247731112..a251511dd6 100644 --- a/js/src/vm/RegExpObject.h +++ b/js/src/vm/RegExpObject.h @@ -460,7 +460,7 @@ class RegExpObject : public NativeObject static bool isOriginalFlagGetter(JSNative native, RegExpFlag* mask); - static MOZ_MUST_USE bool getShared(JSContext* cx, Handle<RegExpObject*> regexp, + [[nodiscard]] static bool getShared(JSContext* cx, Handle<RegExpObject*> regexp, MutableHandleRegExpShared shared); bool hasShared() { @@ -483,7 +483,7 @@ class RegExpObject : public NativeObject void initAndZeroLastIndex(HandleAtom source, RegExpFlag flags, ExclusiveContext* cx); #ifdef DEBUG - static MOZ_MUST_USE bool dumpBytecode(JSContext* cx, Handle<RegExpObject*> regexp, + [[nodiscard]] static bool dumpBytecode(JSContext* cx, Handle<RegExpObject*> regexp, bool match_only, HandleLinearString input); #endif @@ -492,7 +492,7 @@ class RegExpObject : public NativeObject * Precondition: the syntax for |source| has already been validated. * Side effect: sets the private field. */ - static MOZ_MUST_USE bool createShared(JSContext* cx, Handle<RegExpObject*> regexp, + [[nodiscard]] static bool createShared(JSContext* cx, Handle<RegExpObject*> regexp, MutableHandleRegExpShared shared); PreBarriered<RegExpShared*>& sharedRef() { diff --git a/js/src/vm/SavedFrame.h b/js/src/vm/SavedFrame.h index 6995cbb359..2981b9e4a3 100644 --- a/js/src/vm/SavedFrame.h +++ b/js/src/vm/SavedFrame.h @@ -157,7 +157,7 @@ class SavedFrame : public NativeObject { private: static SavedFrame* create(JSContext* cx); - static MOZ_MUST_USE bool finishSavedFrameInit(JSContext* cx, HandleObject ctor, HandleObject proto); + [[nodiscard]] static bool finishSavedFrameInit(JSContext* cx, HandleObject ctor, HandleObject proto); void initFromLookup(HandleLookup lookup); void initSource(JSAtom* source); void initLine(uint32_t line); @@ -228,7 +228,7 @@ struct ReconstructedSavedFramePrincipals : public JSPrincipals this->refcount = 1; } - MOZ_MUST_USE bool write(JSContext* cx, JSStructuredCloneWriter* writer) override { + [[nodiscard]] bool write(JSContext* cx, JSStructuredCloneWriter* writer) override { MOZ_ASSERT(false, "ReconstructedSavedFramePrincipals should never be exposed to embedders"); return false; } @@ -311,8 +311,8 @@ class ConcreteStackFrame<SavedFrame> : public BaseStackFrame { bool isSystem() const override; - MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, - MutableHandleObject outSavedFrameStack) + [[nodiscard]] bool constructSavedFrameStack(JSContext* cx, + MutableHandleObject outSavedFrameStack) const override; }; diff --git a/js/src/vm/SavedStacks.cpp b/js/src/vm/SavedStacks.cpp index 59b3e6bd14..10f147cf13 100644 --- a/js/src/vm/SavedStacks.cpp +++ b/js/src/vm/SavedStacks.cpp @@ -600,7 +600,7 @@ GetFirstSubsumedSavedFrame(JSContext* cx, HandleObject savedFrame, return GetFirstSubsumedFrame(cx, frame, selfHosted, skippedAsync); } -static MOZ_MUST_USE bool +[[nodiscard]] static bool SavedFrame_checkThis(JSContext* cx, CallArgs& args, const char* fnName, MutableHandleObject frame) { diff --git a/js/src/vm/SavedStacks.h b/js/src/vm/SavedStacks.h index 3ea6c40874..b757f7ebdd 100644 --- a/js/src/vm/SavedStacks.h +++ b/js/src/vm/SavedStacks.h @@ -161,11 +161,11 @@ class SavedStacks { creatingSavedFrame(false) { } - MOZ_MUST_USE bool init(); + [[nodiscard]] bool init(); bool initialized() const { return frames.initialized(); } - MOZ_MUST_USE bool saveCurrentStack(JSContext* cx, MutableHandleSavedFrame frame, + [[nodiscard]] bool saveCurrentStack(JSContext* cx, MutableHandleSavedFrame frame, JS::StackCapture&& capture = JS::StackCapture(JS::AllFrames())); - MOZ_MUST_USE bool copyAsyncStack(JSContext* cx, HandleObject asyncStack, + [[nodiscard]] bool copyAsyncStack(JSContext* cx, HandleObject asyncStack, HandleString asyncCause, MutableHandleSavedFrame adoptedStack, uint32_t maxFrameCount = 0); @@ -218,10 +218,10 @@ class SavedStacks { } }; - MOZ_MUST_USE bool insertFrames(JSContext* cx, FrameIter& iter, + [[nodiscard]] bool insertFrames(JSContext* cx, FrameIter& iter, MutableHandleSavedFrame frame, JS::StackCapture&& capture); - MOZ_MUST_USE bool adoptAsyncStack(JSContext* cx, HandleSavedFrame asyncStack, + [[nodiscard]] bool adoptAsyncStack(JSContext* cx, HandleSavedFrame asyncStack, HandleString asyncCause, MutableHandleSavedFrame adoptedStack, uint32_t maxFrameCount); @@ -291,7 +291,7 @@ class SavedStacks { using PCLocationMap = GCHashMap<PCKey, LocationValue, PCLocationHasher, SystemAllocPolicy>; PCLocationMap pcLocationMap; - MOZ_MUST_USE bool getLocation(JSContext* cx, const FrameIter& iter, + [[nodiscard]] bool getLocation(JSContext* cx, const FrameIter& iter, MutableHandle<LocationValue> locationp); }; diff --git a/js/src/vm/Shape.h b/js/src/vm/Shape.h index bb813997f0..b1f3476312 100644 --- a/js/src/vm/Shape.h +++ b/js/src/vm/Shape.h @@ -654,9 +654,9 @@ class Shape : public gc::TenuredCell static inline Shape* search(ExclusiveContext* cx, Shape* start, jsid id); template<MaybeAdding Adding = MaybeAdding::NotAdding> - static inline MOZ_MUST_USE bool search(ExclusiveContext* cx, Shape* start, jsid id, - const AutoKeepShapeTables&, - Shape** pshape, ShapeTable::Entry** pentry); + [[nodiscard]] static inline bool search(ExclusiveContext* cx, Shape* start, jsid id, + const AutoKeepShapeTables&, + Shape** pshape, ShapeTable::Entry** pentry); static inline Shape* searchNoHashify(Shape* start, jsid id); @@ -694,7 +694,7 @@ class Shape : public gc::TenuredCell bool makeOwnBaseShape(ExclusiveContext* cx); - MOZ_ALWAYS_INLINE MOZ_MUST_USE bool maybeCreateTableForLookup(ExclusiveContext* cx); + [[nodiscard]] MOZ_ALWAYS_INLINE bool maybeCreateTableForLookup(ExclusiveContext* cx); public: bool hasTable() const { return base()->hasTable(); } @@ -707,7 +707,7 @@ class Shape : public gc::TenuredCell } template <typename T> - MOZ_MUST_USE ShapeTable* ensureTableForDictionary(ExclusiveContext* cx, const T& nogc) { + [[nodiscard]] ShapeTable* ensureTableForDictionary(ExclusiveContext* cx, const T& nogc) { MOZ_ASSERT(inDictionary()); if (ShapeTable* table = maybeTable(nogc)) return table; diff --git a/js/src/vm/SharedImmutableStringsCache-inl.h b/js/src/vm/SharedImmutableStringsCache-inl.h index da05444d7e..6d46179f6b 100644 --- a/js/src/vm/SharedImmutableStringsCache-inl.h +++ b/js/src/vm/SharedImmutableStringsCache-inl.h @@ -11,7 +11,7 @@ namespace js { template <typename IntoOwnedChars> -MOZ_MUST_USE mozilla::Maybe<SharedImmutableString> +[[nodiscard]] mozilla::Maybe<SharedImmutableString> SharedImmutableStringsCache::getOrCreate(const char* chars, size_t length, IntoOwnedChars intoOwnedChars) { @@ -40,7 +40,7 @@ SharedImmutableStringsCache::getOrCreate(const char* chars, size_t length, } template <typename IntoOwnedTwoByteChars> -MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString> +[[nodiscard]] mozilla::Maybe<SharedImmutableTwoByteString> SharedImmutableStringsCache::getOrCreate(const char16_t* chars, size_t length, IntoOwnedTwoByteChars intoOwnedTwoByteChars) { MOZ_ASSERT(inner_); diff --git a/js/src/vm/SharedImmutableStringsCache.cpp b/js/src/vm/SharedImmutableStringsCache.cpp index 186fc4f490..8711fb9b41 100644 --- a/js/src/vm/SharedImmutableStringsCache.cpp +++ b/js/src/vm/SharedImmutableStringsCache.cpp @@ -91,7 +91,7 @@ SharedImmutableTwoByteString::clone() const return SharedImmutableTwoByteString(string_.clone()); } -MOZ_MUST_USE mozilla::Maybe<SharedImmutableString> +[[nodiscard]] mozilla::Maybe<SharedImmutableString> SharedImmutableStringsCache::getOrCreate(OwnedChars&& chars, size_t length) { OwnedChars owned(mozilla::Move(chars)); @@ -99,13 +99,13 @@ SharedImmutableStringsCache::getOrCreate(OwnedChars&& chars, size_t length) return getOrCreate(owned.get(), length, [&]() { return mozilla::Move(owned); }); } -MOZ_MUST_USE mozilla::Maybe<SharedImmutableString> +[[nodiscard]] mozilla::Maybe<SharedImmutableString> SharedImmutableStringsCache::getOrCreate(const char* chars, size_t length) { return getOrCreate(chars, length, [&]() { return DuplicateString(chars, length); }); } -MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString> +[[nodiscard]] mozilla::Maybe<SharedImmutableTwoByteString> SharedImmutableStringsCache::getOrCreate(OwnedTwoByteChars&& chars, size_t length) { OwnedTwoByteChars owned(mozilla::Move(chars)); @@ -113,7 +113,7 @@ SharedImmutableStringsCache::getOrCreate(OwnedTwoByteChars&& chars, size_t lengt return getOrCreate(owned.get(), length, [&]() { return mozilla::Move(owned); }); } -MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString> +[[nodiscard]] mozilla::Maybe<SharedImmutableTwoByteString> SharedImmutableStringsCache::getOrCreate(const char16_t* chars, size_t length) { return getOrCreate(chars, length, [&]() { return DuplicateString(chars, length); }); diff --git a/js/src/vm/SharedImmutableStringsCache.h b/js/src/vm/SharedImmutableStringsCache.h index bbde5f631e..b4bec63da6 100644 --- a/js/src/vm/SharedImmutableStringsCache.h +++ b/js/src/vm/SharedImmutableStringsCache.h @@ -65,7 +65,7 @@ class SharedImmutableStringsCache * returned. */ template <typename IntoOwnedChars> - MOZ_MUST_USE mozilla::Maybe<SharedImmutableString> + [[nodiscard]] mozilla::Maybe<SharedImmutableString> getOrCreate(const char* chars, size_t length, IntoOwnedChars intoOwnedChars); /** @@ -75,7 +75,7 @@ class SharedImmutableStringsCache * On success, `Some` is returned. In the case of OOM failure, `Nothing` is * returned. */ - MOZ_MUST_USE mozilla::Maybe<SharedImmutableString> + [[nodiscard]] mozilla::Maybe<SharedImmutableString> getOrCreate(OwnedChars&& chars, size_t length); /** @@ -86,7 +86,7 @@ class SharedImmutableStringsCache * On success, `Some` is returned. In the case of OOM failure, `Nothing` is * returned. */ - MOZ_MUST_USE mozilla::Maybe<SharedImmutableString> + [[nodiscard]] mozilla::Maybe<SharedImmutableString> getOrCreate(const char* chars, size_t length); /** @@ -108,7 +108,7 @@ class SharedImmutableStringsCache * returned. */ template <typename IntoOwnedTwoByteChars> - MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString> + [[nodiscard]] mozilla::Maybe<SharedImmutableTwoByteString> getOrCreate(const char16_t* chars, size_t length, IntoOwnedTwoByteChars intoOwnedTwoByteChars); /** @@ -118,7 +118,7 @@ class SharedImmutableStringsCache * On success, `Some` is returned. In the case of OOM failure, `Nothing` is * returned. */ - MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString> + [[nodiscard]] mozilla::Maybe<SharedImmutableTwoByteString> getOrCreate(OwnedTwoByteChars&& chars, size_t length); /** @@ -129,7 +129,7 @@ class SharedImmutableStringsCache * On success, `Some` is returned. In the case of OOM failure, `Nothing` is * returned. */ - MOZ_MUST_USE mozilla::Maybe<SharedImmutableTwoByteString> + [[nodiscard]] mozilla::Maybe<SharedImmutableTwoByteString> getOrCreate(const char16_t* chars, size_t length); size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { diff --git a/js/src/vm/StringBuffer.h b/js/src/vm/StringBuffer.h index 502a3bc6f6..3bda9fc72f 100644 --- a/js/src/vm/StringBuffer.h +++ b/js/src/vm/StringBuffer.h @@ -67,7 +67,7 @@ class StringBuffer return cb.ref<TwoByteCharBuffer>(); } - MOZ_MUST_USE bool inflateChars(); + [[nodiscard]] bool inflateChars(); public: explicit StringBuffer(ExclusiveContext* cx) @@ -92,12 +92,12 @@ class StringBuffer else twoByteChars().clear(); } - MOZ_MUST_USE bool reserve(size_t len) { + [[nodiscard]] bool reserve(size_t len) { if (len > reserved_) reserved_ = len; return isLatin1() ? latin1Chars().reserve(len) : twoByteChars().reserve(len); } - MOZ_MUST_USE bool resize(size_t len) { + [[nodiscard]] bool resize(size_t len) { return isLatin1() ? latin1Chars().resize(len) : twoByteChars().resize(len); } bool empty() const { @@ -110,7 +110,7 @@ class StringBuffer return isLatin1() ? latin1Chars()[idx] : twoByteChars()[idx]; } - MOZ_MUST_USE bool ensureTwoByteChars() { + [[nodiscard]] bool ensureTwoByteChars() { if (isLatin1() && !inflateChars()) return false; @@ -120,7 +120,7 @@ class StringBuffer return true; } - MOZ_MUST_USE bool append(const char16_t c) { + [[nodiscard]] bool append(const char16_t c) { if (isLatin1()) { if (c <= JSString::MAX_LATIN1_CHAR) return latin1Chars().append(Latin1Char(c)); @@ -129,10 +129,10 @@ class StringBuffer } return twoByteChars().append(c); } - MOZ_MUST_USE bool append(Latin1Char c) { + [[nodiscard]] bool append(Latin1Char c) { return isLatin1() ? latin1Chars().append(c) : twoByteChars().append(c); } - MOZ_MUST_USE bool append(char c) { + [[nodiscard]] bool append(char c) { return append(Latin1Char(c)); } @@ -141,37 +141,37 @@ class StringBuffer return twoByteChars(); } - inline MOZ_MUST_USE bool append(const char16_t* begin, const char16_t* end); + [[nodiscard]] inline bool append(const char16_t* begin, const char16_t* end); - MOZ_MUST_USE bool append(const char16_t* chars, size_t len) { + [[nodiscard]] bool append(const char16_t* chars, size_t len) { return append(chars, chars + len); } - MOZ_MUST_USE bool append(const Latin1Char* begin, const Latin1Char* end) { + [[nodiscard]] bool append(const Latin1Char* begin, const Latin1Char* end) { return isLatin1() ? latin1Chars().append(begin, end) : twoByteChars().append(begin, end); } - MOZ_MUST_USE bool append(const Latin1Char* chars, size_t len) { + [[nodiscard]] bool append(const Latin1Char* chars, size_t len) { return append(chars, chars + len); } - MOZ_MUST_USE bool append(const JS::ConstCharPtr chars, size_t len) { + [[nodiscard]] bool append(const JS::ConstCharPtr chars, size_t len) { return append(chars.get(), chars.get() + len); } - MOZ_MUST_USE bool appendN(Latin1Char c, size_t n) { + [[nodiscard]] bool appendN(Latin1Char c, size_t n) { return isLatin1() ? latin1Chars().appendN(c, n) : twoByteChars().appendN(c, n); } - inline MOZ_MUST_USE bool append(JSString* str); - inline MOZ_MUST_USE bool append(JSLinearString* str); - inline MOZ_MUST_USE bool appendSubstring(JSString* base, size_t off, size_t len); - inline MOZ_MUST_USE bool appendSubstring(JSLinearString* base, size_t off, size_t len); + [[nodiscard]] inline bool append(JSString* str); + [[nodiscard]] inline bool append(JSLinearString* str); + [[nodiscard]] inline bool appendSubstring(JSString* base, size_t off, size_t len); + [[nodiscard]] inline bool appendSubstring(JSLinearString* base, size_t off, size_t len); - MOZ_MUST_USE bool append(const char* chars, size_t len) { + [[nodiscard]] bool append(const char* chars, size_t len) { return append(reinterpret_cast<const Latin1Char*>(chars), len); } template <size_t ArrayLength> - MOZ_MUST_USE bool append(const char (&array)[ArrayLength]) { + [[nodiscard]] bool append(const char (&array)[ArrayLength]) { return append(array, ArrayLength - 1); /* No trailing '\0'. */ } diff --git a/js/src/vm/TypeInference.h b/js/src/vm/TypeInference.h index 58c606912c..b66509d1e8 100644 --- a/js/src/vm/TypeInference.h +++ b/js/src/vm/TypeInference.h @@ -843,14 +843,14 @@ public: DPAConstraintInfo(const DPAConstraintInfo&) = delete; void operator=(const DPAConstraintInfo&) = delete; - MOZ_MUST_USE bool addProtoConstraint(JSObject* proto, jsid id) { + [[nodiscard]] bool addProtoConstraint(JSObject* proto, jsid id) { return protoConstraints_.emplaceBack(proto, id); } - MOZ_MUST_USE bool addInliningConstraint(JSScript* caller, JSScript* callee) { + [[nodiscard]] bool addInliningConstraint(JSScript* caller, JSScript* callee) { return inliningConstraints_.emplaceBack(caller, callee); } - MOZ_MUST_USE bool finishConstraints(JSContext* cx, ObjectGroup* group); + [[nodiscard]] bool finishConstraints(JSContext* cx, ObjectGroup* group); }; bool diff --git a/js/src/vm/TypedArrayObject.h b/js/src/vm/TypedArrayObject.h index 8b4b0b5092..8ff820b916 100644 --- a/js/src/vm/TypedArrayObject.h +++ b/js/src/vm/TypedArrayObject.h @@ -316,7 +316,7 @@ class TypedArrayObject : public NativeObject bool convertForSideEffect(JSContext* cx, HandleValue v) const; }; -MOZ_MUST_USE bool TypedArray_bufferGetter(JSContext* cx, unsigned argc, Value* vp); +[[nodiscard]] bool TypedArray_bufferGetter(JSContext* cx, unsigned argc, Value* vp); extern TypedArrayObject* TypedArrayCreateWithTemplate(JSContext* cx, HandleObject templateObj, int32_t len); diff --git a/js/src/vm/Xdr.h b/js/src/vm/Xdr.h index 419b0dc86b..e21448e1e2 100644 --- a/js/src/vm/Xdr.h +++ b/js/src/vm/Xdr.h @@ -426,14 +426,14 @@ class XDRIncrementalEncoder : public XDREncoder AutoXDRTree::Key getTopLevelTreeKey() const override; AutoXDRTree::Key getTreeKey(JSFunction* fun) const override; - MOZ_MUST_USE bool init(); + [[nodiscard]] bool init(); void createOrReplaceSubTree(AutoXDRTree* child) override; void endSubTree() override; // Append the content collected during the incremental encoding into the // buffer given as argument. - MOZ_MUST_USE bool linearize(JS::TranscodeBuffer& buffer); + [[nodiscard]] bool linearize(JS::TranscodeBuffer& buffer); }; } /* namespace js */ |