summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2023-11-04 20:06:50 +0100
committerMoonchild <moonchild@palemoon.org>2023-11-08 13:48:12 +0100
commit706d07b3d560955745a7dd4addb0ea52ac18d94b (patch)
tree581db1c66c37f92bf7759aae1ef45acc7ad38201
parenteb7be8c637b7b382161d009b302ae9713470c553 (diff)
downloaduxp-706d07b3d560955745a7dd4addb0ea52ac18d94b.tar.gz
Issue #2342: Use [[nodiscard]] in /js
-rw-r--r--js/public/HashTable.h32
-rw-r--r--js/public/RootingAPI.h2
-rw-r--r--js/public/UbiNode.h22
-rw-r--r--js/public/UbiNodeCensus.h22
-rw-r--r--js/public/UbiNodeDominatorTree.h18
-rw-r--r--js/public/UbiNodePostOrder.h10
-rw-r--r--js/public/UbiNodeShortestPaths.h4
-rw-r--r--js/public/Utility.h4
-rw-r--r--js/src/builtin/AtomicsObject.h34
-rw-r--r--js/src/builtin/Eval.h6
-rw-r--r--js/src/builtin/MapObject.cpp6
-rw-r--r--js/src/builtin/MapObject.h110
-rw-r--r--js/src/builtin/Object.h26
-rw-r--r--js/src/builtin/Profilers.h20
-rw-r--r--js/src/builtin/Promise.cpp138
-rw-r--r--js/src/builtin/Promise.h36
-rw-r--r--js/src/builtin/Reflect.h4
-rw-r--r--js/src/builtin/ReflectParse.cpp168
-rw-r--r--js/src/builtin/RegExp.h56
-rw-r--r--js/src/builtin/Stream.cpp294
-rw-r--r--js/src/builtin/Stream.h58
-rw-r--r--js/src/builtin/SymbolObject.h20
-rw-r--r--js/src/builtin/TestingFunctions.h6
-rw-r--r--js/src/builtin/TypedObject.h118
-rw-r--r--js/src/builtin/WeakSetObject.h2
-rw-r--r--js/src/builtin/intl/Collator.h8
-rw-r--r--js/src/builtin/intl/DateTimeFormat.h20
-rw-r--r--js/src/builtin/intl/IntlObject.h8
-rw-r--r--js/src/builtin/intl/LanguageTag.h12
-rw-r--r--js/src/builtin/intl/Locale.h10
-rw-r--r--js/src/builtin/intl/NumberFormat.h8
-rw-r--r--js/src/builtin/intl/PluralRules.h6
-rw-r--r--js/src/builtin/intl/RelativeTimeFormat.h3
-rw-r--r--js/src/builtin/intl/SharedIntlData.h6
-rw-r--r--js/src/ctypes/CTypes.h12
-rw-r--r--js/src/ctypes/Library.h4
-rw-r--r--js/src/ds/Fifo.h6
-rw-r--r--js/src/ds/InlineTable.h18
-rw-r--r--js/src/ds/LifoAlloc.h4
-rw-r--r--js/src/ds/OrderedHashTable.h20
-rw-r--r--js/src/ds/PageProtectingVector.h4
-rw-r--r--js/src/ds/PriorityQueue.h4
-rw-r--r--js/src/ds/Sort.h2
-rw-r--r--js/src/ds/SplayTree.h2
-rw-r--r--js/src/frontend/BytecodeCompiler.h12
-rw-r--r--js/src/frontend/BytecodeControlStructures.h4
-rw-r--r--js/src/frontend/BytecodeEmitter.cpp12
-rw-r--r--js/src/frontend/BytecodeEmitter.h394
-rw-r--r--js/src/frontend/CallOrNewEmitter.cpp4
-rw-r--r--js/src/frontend/CallOrNewEmitter.h38
-rw-r--r--js/src/frontend/DefaultEmitter.h6
-rw-r--r--js/src/frontend/ElemOpEmitter.h36
-rw-r--r--js/src/frontend/EmitterScope.h42
-rw-r--r--js/src/frontend/FoldConstants.h4
-rw-r--r--js/src/frontend/ForOfLoopControl.h10
-rw-r--r--js/src/frontend/FullParseHandler.h42
-rw-r--r--js/src/frontend/FunctionEmitter.h70
-rw-r--r--js/src/frontend/IfEmitter.h16
-rw-r--r--js/src/frontend/LexicalScopeEmitter.h8
-rw-r--r--js/src/frontend/NameFunctions.h2
-rw-r--r--js/src/frontend/NameOpEmitter.h28
-rw-r--r--js/src/frontend/ObjectEmitter.h78
-rw-r--r--js/src/frontend/ParseNode.h12
-rw-r--r--js/src/frontend/Parser.cpp2
-rw-r--r--js/src/frontend/Parser.h50
-rw-r--r--js/src/frontend/PropOpEmitter.h36
-rw-r--r--js/src/frontend/SwitchEmitter.h30
-rw-r--r--js/src/frontend/SyntaxParseHandler.h34
-rw-r--r--js/src/frontend/TDZCheckCache.h4
-rw-r--r--js/src/frontend/TokenKind.h16
-rw-r--r--js/src/frontend/TokenStream.h42
-rw-r--r--js/src/frontend/TryEmitter.h16
-rw-r--r--js/src/gc/GCRuntime.h32
-rw-r--r--js/src/gc/GCTrace.h4
-rw-r--r--js/src/gc/Heap.h2
-rw-r--r--js/src/gc/Marking.h18
-rw-r--r--js/src/gc/Nursery.h8
-rw-r--r--js/src/gc/NurseryAwareHashMap.h4
-rw-r--r--js/src/gc/Statistics.h6
-rw-r--r--js/src/gc/StoreBuffer.h6
-rw-r--r--js/src/gc/Zone.h12
-rw-r--r--js/src/irregexp/InfallibleVector.h5
-rw-r--r--js/src/jit/AliasAnalysis.h2
-rw-r--r--js/src/jit/AliasAnalysisShared.h2
-rw-r--r--js/src/jit/AlignmentMaskAnalysis.h2
-rw-r--r--js/src/jit/BacktrackingAllocator.h80
-rw-r--r--js/src/jit/Bailouts.h2
-rw-r--r--js/src/jit/BaselineBailouts.cpp16
-rw-r--r--js/src/jit/BaselineCacheIR.cpp6
-rw-r--r--js/src/jit/BaselineCompiler.h70
-rw-r--r--js/src/jit/BaselineDebugModeOSR.h2
-rw-r--r--js/src/jit/BaselineFrame.h12
-rw-r--r--js/src/jit/BaselineFrameInfo.h2
-rw-r--r--js/src/jit/BaselineIC.h126
-rw-r--r--js/src/jit/BaselineInspector.h12
-rw-r--r--js/src/jit/BaselineJIT.h2
-rw-r--r--js/src/jit/BitSet.h2
-rw-r--r--js/src/jit/BytecodeAnalysis.h2
-rw-r--r--js/src/jit/CacheIR.h16
-rw-r--r--js/src/jit/CodeGenerator.h12
-rw-r--r--js/src/jit/EdgeCaseAnalysis.h2
-rw-r--r--js/src/jit/EffectiveAddressAnalysis.h4
-rw-r--r--js/src/jit/ExecutableAllocator.h4
-rw-r--r--js/src/jit/FixedList.h4
-rw-r--r--js/src/jit/FlowAliasAnalysis.h36
-rw-r--r--js/src/jit/FoldLinearArithConstants.h3
-rw-r--r--js/src/jit/InstructionReordering.h3
-rw-r--r--js/src/jit/Ion.h10
-rw-r--r--js/src/jit/IonAnalysis.cpp2
-rw-r--r--js/src/jit/IonAnalysis.h48
-rw-r--r--js/src/jit/IonBuilder.h454
-rw-r--r--js/src/jit/IonCaches.h202
-rw-r--r--js/src/jit/IonCode.h6
-rw-r--r--js/src/jit/JitAllocPolicy.h8
-rw-r--r--js/src/jit/JitCompartment.h18
-rw-r--r--js/src/jit/JitFrameIterator.h16
-rw-r--r--js/src/jit/JitcodeMap.h52
-rw-r--r--js/src/jit/LICM.h2
-rw-r--r--js/src/jit/LIR.h38
-rw-r--r--js/src/jit/LoopUnroller.h3
-rw-r--r--js/src/jit/Lowering.h8
-rw-r--r--js/src/jit/MIR.h172
-rw-r--r--js/src/jit/MIRGenerator.h4
-rw-r--r--js/src/jit/MIRGraph.h32
-rw-r--r--js/src/jit/MacroAssembler.h30
-rw-r--r--js/src/jit/MoveResolver.h6
-rw-r--r--js/src/jit/OptimizationTracking.h28
-rw-r--r--js/src/jit/PcScriptCache.h4
-rw-r--r--js/src/jit/PerfSpewer.h10
-rw-r--r--js/src/jit/ProcessExecutableMemory.cpp2
-rw-r--r--js/src/jit/ProcessExecutableMemory.h4
-rw-r--r--js/src/jit/RangeAnalysis.h24
-rw-r--r--js/src/jit/Recover.h104
-rw-r--r--js/src/jit/RegisterAllocator.h14
-rw-r--r--js/src/jit/RematerializedFrame.h12
-rw-r--r--js/src/jit/Safepoints.h12
-rw-r--r--js/src/jit/ScalarReplacement.h3
-rw-r--r--js/src/jit/SharedIC.h104
-rw-r--r--js/src/jit/Sink.h3
-rw-r--r--js/src/jit/Snapshots.h4
-rw-r--r--js/src/jit/StupidAllocator.h4
-rw-r--r--js/src/jit/TypePolicy.h124
-rw-r--r--js/src/jit/VMFunctions.h106
-rw-r--r--js/src/jit/ValueNumbering.h44
-rw-r--r--js/src/jit/shared/CodeGenerator-shared.cpp2
-rw-r--r--js/src/jit/shared/CodeGenerator-shared.h3
-rw-r--r--js/src/jit/x64/BaseAssembler-x64.h28
-rw-r--r--js/src/jit/x86-shared/AssemblerBuffer-x86-shared.h3
-rw-r--r--js/src/jit/x86-shared/BaseAssembler-x86-shared.h20
-rw-r--r--js/src/jsapi.cpp2
-rw-r--r--js/src/jsapi.h18
-rw-r--r--js/src/jscntxt.h2
-rw-r--r--js/src/jscompartment.h20
-rw-r--r--js/src/jsfriendapi.h4
-rw-r--r--js/src/jsnum.h42
-rw-r--r--js/src/jsobj.cpp4
-rw-r--r--js/src/jsobj.h4
-rw-r--r--js/src/jsobjinlines.h2
-rw-r--r--js/src/jsopcode.cpp8
-rw-r--r--js/src/jsopcode.h4
-rw-r--r--js/src/jsscript.cpp6
-rw-r--r--js/src/jsscript.h4
-rw-r--r--js/src/jsstr.cpp4
-rw-r--r--js/src/jsstr.h4
-rw-r--r--js/src/shell/js.cpp18
-rw-r--r--js/src/threading/Thread.h4
-rw-r--r--js/src/vm/ArgumentsObject.h2
-rw-r--r--js/src/vm/ArrayBufferObject.cpp2
-rw-r--r--js/src/vm/ArrayBufferObject.h6
-rw-r--r--js/src/vm/AsyncFunction.cpp10
-rw-r--r--js/src/vm/AsyncFunction.h4
-rw-r--r--js/src/vm/AsyncIteration.cpp24
-rw-r--r--js/src/vm/AsyncIteration.h12
-rw-r--r--js/src/vm/BigIntType.h8
-rw-r--r--js/src/vm/Debugger.h344
-rw-r--r--js/src/vm/EnvironmentObject.h16
-rw-r--r--js/src/vm/ErrorReporting.h2
-rw-r--r--js/src/vm/GeneratorObject.cpp2
-rw-r--r--js/src/vm/GeneratorObject.h2
-rw-r--r--js/src/vm/NativeObject.h8
-rw-r--r--js/src/vm/Printer.h8
-rw-r--r--js/src/vm/RegExpObject.h6
-rw-r--r--js/src/vm/SavedFrame.h8
-rw-r--r--js/src/vm/SavedStacks.cpp2
-rw-r--r--js/src/vm/SavedStacks.h12
-rw-r--r--js/src/vm/Shape.h10
-rw-r--r--js/src/vm/SharedImmutableStringsCache-inl.h4
-rw-r--r--js/src/vm/SharedImmutableStringsCache.cpp8
-rw-r--r--js/src/vm/SharedImmutableStringsCache.h12
-rw-r--r--js/src/vm/StringBuffer.h38
-rw-r--r--js/src/vm/TypeInference.h6
-rw-r--r--js/src/vm/TypedArrayObject.h2
-rw-r--r--js/src/vm/Xdr.h4
-rw-r--r--js/src/wasm/AsmJS.cpp14
-rw-r--r--js/src/wasm/AsmJS.h2
-rw-r--r--js/src/wasm/WasmBaselineCompile.cpp123
-rw-r--r--js/src/wasm/WasmBinaryFormat.h108
-rw-r--r--js/src/wasm/WasmBinaryIterator.h158
-rw-r--r--js/src/wasm/WasmBinaryToAST.cpp3
-rw-r--r--js/src/wasm/WasmBinaryToExperimentalText.h2
-rw-r--r--js/src/wasm/WasmBinaryToText.h3
-rw-r--r--js/src/wasm/WasmCode.h3
-rw-r--r--js/src/wasm/WasmGenerator.h51
-rw-r--r--js/src/wasm/WasmInstance.h5
-rw-r--r--js/src/wasm/WasmIonCompile.h3
-rw-r--r--js/src/wasm/WasmJS.h2
-rw-r--r--js/src/wasm/WasmSignalHandlers.h2
-rw-r--r--js/src/wasm/WasmTextToBinary.h3
-rw-r--r--js/src/wasm/WasmTextUtils.cpp4
-rw-r--r--js/src/wasm/WasmTextUtils.h5
-rw-r--r--js/src/wasm/WasmTypes.h2
-rw-r--r--js/xpconnect/loader/mozJSComponentLoader.cpp2
212 files changed, 2963 insertions, 2959 deletions
diff --git a/js/public/HashTable.h b/js/public/HashTable.h
index d0f7dba41f..ab04a2c7b1 100644
--- a/js/public/HashTable.h
+++ b/js/public/HashTable.h
@@ -88,7 +88,7 @@ class HashMap
// HashMap construction is fallible (due to OOM); thus the user must call
// init after constructing a HashMap and check the return value.
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(); }
// Return whether the given lookup value is present in the map. E.g.:
@@ -151,19 +151,19 @@ class HashMap
}
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,
mozilla::Forward<KeyInput>(k),
mozilla::Forward<ValueInput>(v));
}
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());
}
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,
mozilla::Forward<KeyInput>(k),
mozilla::Forward<ValueInput>(v));
@@ -232,7 +232,7 @@ class HashMap
// Overwrite existing value with v. Return false on oom.
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);
if (p) {
p->value() = mozilla::Forward<ValueInput>(v);
@@ -243,7 +243,7 @@ class HashMap
// Like put, but assert that the given key is not already present.
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));
}
@@ -341,7 +341,7 @@ class HashSet
// HashSet construction is fallible (due to OOM); thus the user must call
// init after constructing a HashSet and check the return value.
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(); }
// 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); }
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));
}
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));
}
@@ -471,19 +471,19 @@ class HashSet
// Add |u| if it is not present already. Return false on oom.
template <typename U>
- MOZ_MUST_USE bool put(U&& u) {
+ [[nodiscard]] bool put(U&& u) {
AddPtr p = lookupForAdd(u);
return p ? true : add(p, mozilla::Forward<U>(u));
}
// Like put, but assert that the given key is not already present.
template <typename U>
- MOZ_MUST_USE bool putNew(U&& u) {
+ [[nodiscard]] bool putNew(U&& u) {
return impl.putNew(u, mozilla::Forward<U>(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));
}
@@ -1277,7 +1277,7 @@ class HashTable : private AllocPolicy
#endif
{}
- MOZ_MUST_USE bool init(uint32_t length)
+ [[nodiscard]] bool init(uint32_t length)
{
MOZ_ASSERT(!initialized());
@@ -1775,7 +1775,7 @@ class HashTable : private AllocPolicy
}
template <typename... Args>
- MOZ_MUST_USE bool add(AddPtr& p, Args&&... args)
+ [[nodiscard]] bool add(AddPtr& p, Args&&... args)
{
mozilla::ReentrancyGuard g(*this);
MOZ_ASSERT(table);
@@ -1828,7 +1828,7 @@ class HashTable : private AllocPolicy
// Note: |l| may be alias arguments in |args|, so this function must take
// care not to use |l| after moving |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())
return false;
@@ -1846,7 +1846,7 @@ class HashTable : private AllocPolicy
// Note: |l| may be a reference to a piece of |u|, so this function
// must take care not to use |l| after moving |u|.
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.
if (p.isValid())
diff --git a/js/public/RootingAPI.h b/js/public/RootingAPI.h
index e03bc56fb7..15fa304147 100644
--- a/js/public/RootingAPI.h
+++ b/js/public/RootingAPI.h
@@ -1274,7 +1274,7 @@ class MutableWrappedPtrOperations<UniquePtr<T, D>, Container>
UniquePtr<T, D>& uniquePtr() { return static_cast<Container*>(this)->get(); }
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); }
};
diff --git a/js/public/UbiNode.h b/js/public/UbiNode.h
index 3df3a4840b..fb01ea1484 100644
--- a/js/public/UbiNode.h
+++ b/js/public/UbiNode.h
@@ -285,7 +285,7 @@ class BaseStackFrame {
// simplifies the principals check into the boolean isSystem() state. This
// is fine because we only expose JS::ubi::Stack to devtools and chrome
// code, and not to the web platform.
- virtual MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx,
+ [[nodiscard]] virtual bool constructSavedFrameStack(JSContext* cx,
MutableHandleObject outSavedFrameStack)
const = 0;
@@ -416,7 +416,7 @@ class StackFrame {
StackFrame parent() const { return base()->parent(); }
bool isSystem() const { return base()->isSystem(); }
bool isSelfHosted(JSContext* cx) const { return base()->isSelfHosted(cx); }
- MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx,
+ [[nodiscard]] bool constructSavedFrameStack(JSContext* cx,
MutableHandleObject outSavedFrameStack) const {
return base()->constructSavedFrameStack(cx, outSavedFrameStack);
}
@@ -449,7 +449,7 @@ class ConcreteStackFrame<void> : public BaseStackFrame {
uint64_t identifier() const override { return 0; }
void trace(JSTracer* trc) override { }
- MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, MutableHandleObject out)
+ [[nodiscard]] bool constructSavedFrameStack(JSContext* cx, MutableHandleObject out)
const override
{
out.set(nullptr);
@@ -465,7 +465,7 @@ class ConcreteStackFrame<void> : public BaseStackFrame {
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,
JS::ubi::StackFrame& frame,
MutableHandleObject outSavedFrameStack);
@@ -628,7 +628,7 @@ class JS_PUBLIC_API(Base) {
// Otherwise, place nullptr in the out parameter. Caller maintains ownership
// of the out parameter. True is returned on success, false is returned on
// OOM.
- virtual MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName)
+ [[nodiscard]] virtual bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName)
const
{
outName.reset(nullptr);
@@ -778,7 +778,7 @@ class Node {
JS::Zone* zone() const { return base()->zone(); }
JSCompartment* compartment() const { return base()->compartment(); }
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);
}
@@ -981,12 +981,12 @@ class MOZ_STACK_CLASS JS_PUBLIC_API(RootList) {
RootList(JSContext* cx, Maybe<AutoCheckCannotGC>& noGC, bool wantNames = false);
// Find all GC roots.
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
// 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
// compartments.
- MOZ_MUST_USE bool init(HandleObject debuggees);
+ [[nodiscard]] bool init(HandleObject debuggees);
// Returns true if the RootList has been initialized successfully, false
// 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
// true, you must pass an edgeName. The RootList does not take ownership of
// 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;
- MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName)
+ [[nodiscard]] bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName)
const override;
Size size(mozilla::MallocSizeOf mallocSizeOf) const override;
diff --git a/js/public/UbiNodeCensus.h b/js/public/UbiNodeCensus.h
index 6fa739dac1..17db00dc0c 100644
--- a/js/public/UbiNodeCensus.h
+++ b/js/public/UbiNodeCensus.h
@@ -104,14 +104,14 @@ struct CountType {
// Implement the 'count' method for counts returned by this CountType
// instance's 'newCount' method.
- virtual MOZ_MUST_USE bool count(CountBase& count,
- mozilla::MallocSizeOf mallocSizeOf,
- const Node& node) = 0;
+ [[nodiscard]] virtual bool count(CountBase& count,
+ mozilla::MallocSizeOf mallocSizeOf,
+ const Node& node) = 0;
// Implement the 'report' method for counts returned by this CountType
// instance's 'newCount' method.
- virtual MOZ_MUST_USE bool report(JSContext* cx, CountBase& count,
- MutableHandleValue report) = 0;
+ [[nodiscard]] virtual bool report(JSContext* cx, CountBase& count,
+ MutableHandleValue report) = 0;
};
using CountTypePtr = js::UniquePtr<CountType>;
@@ -135,7 +135,7 @@ class CountBase {
{ }
// 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_++;
auto id = node.identifier();
@@ -158,7 +158,7 @@ class CountBase {
// Construct a JavaScript object reporting the counts recorded in this
// count, and store it in |report|. Return true on success, or false on
// failure.
- MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) {
+ [[nodiscard]] bool report(JSContext* cx, MutableHandleValue report) {
return type.report(cx, *this, report);
}
@@ -202,7 +202,7 @@ struct Census {
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
@@ -219,14 +219,14 @@ class CensusHandler {
mallocSizeOf(mallocSizeOf)
{ }
- MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) {
+ [[nodiscard]] bool report(JSContext* cx, MutableHandleValue report) {
return rootCount->report(cx, report);
}
// This class needs to retain no per-node data.
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,
NodeData* referentData, bool first);
};
@@ -235,7 +235,7 @@ using CensusTraversal = BreadthFirst<CensusHandler>;
// Examine the census options supplied by the API consumer, and (among other
// 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,
CountTypePtr& outResult);
diff --git a/js/public/UbiNodeDominatorTree.h b/js/public/UbiNodeDominatorTree.h
index 5f7e061e54..8a53db0da5 100644
--- a/js/public/UbiNodeDominatorTree.h
+++ b/js/public/UbiNodeDominatorTree.h
@@ -322,9 +322,9 @@ class DominatorTree
// Do the post order traversal of the heap graph and populate our
// predecessor sets.
- static MOZ_MUST_USE bool doTraversal(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root,
- JS::ubi::Vector<Node>& postOrder,
- PredecessorSets& predecessorSets) {
+ [[nodiscard]] static bool doTraversal(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root,
+ JS::ubi::Vector<Node>& postOrder,
+ PredecessorSets& predecessorSets) {
uint32_t nodeCount = 0;
auto onNode = [&](const Node& node) {
nodeCount++;
@@ -356,8 +356,8 @@ class DominatorTree
// Populates the given `map` with an entry for each node to its index in
// `postOrder`.
- static MOZ_MUST_USE bool mapNodesToTheirIndices(JS::ubi::Vector<Node>& postOrder,
- NodeToIndexMap& map) {
+ [[nodiscard]] static bool mapNodesToTheirIndices(JS::ubi::Vector<Node>& postOrder,
+ NodeToIndexMap& map) {
MOZ_ASSERT(!map.initialized());
MOZ_ASSERT(postOrder.length() < UINT32_MAX);
uint32_t length = postOrder.length();
@@ -370,7 +370,7 @@ class DominatorTree
// Convert the Node -> NodeSet predecessorSets to a index -> Vector<index>
// form.
- static MOZ_MUST_USE bool convertPredecessorSetsToVectors(
+ [[nodiscard]] static bool convertPredecessorSetsToVectors(
const Node& root,
JS::ubi::Vector<Node>& postOrder,
PredecessorSets& predecessorSets,
@@ -409,7 +409,7 @@ class DominatorTree
// Initialize `doms` such that the immediate dominator of the `root` is the
// `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) {
MOZ_ASSERT(doms.length() == 0);
if (!doms.growByUninitialized(length))
@@ -426,7 +426,7 @@ class DominatorTree
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());
auto length = postOrder.length();
@@ -651,7 +651,7 @@ class DominatorTree
* `outSize`, or 0 if `node` is not a member of the dominator tree. Returns
* 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) {
assertSanity();
auto ptr = nodeToPostOrderIndex.lookup(node);
diff --git a/js/public/UbiNodePostOrder.h b/js/public/UbiNodePostOrder.h
index 15dcfb9ec3..666d5b1254 100644
--- a/js/public/UbiNodePostOrder.h
+++ b/js/public/UbiNodePostOrder.h
@@ -90,7 +90,7 @@ struct PostOrder {
#endif
private:
- MOZ_MUST_USE bool fillEdgesFromRange(EdgeVector& edges, js::UniquePtr<EdgeRange>& range) {
+ [[nodiscard]] bool fillEdgesFromRange(EdgeVector& edges, js::UniquePtr<EdgeRange>& range) {
MOZ_ASSERT(range);
for ( ; !range->empty(); range->popFront()) {
if (!edges.append(mozilla::Move(range->front())))
@@ -99,7 +99,7 @@ struct PostOrder {
return true;
}
- MOZ_MUST_USE bool pushForTraversing(const Node& node) {
+ [[nodiscard]] bool pushForTraversing(const Node& node) {
EdgeVector edges;
auto range = node.edges(cx, /* wantNames */ false);
return range &&
@@ -124,11 +124,11 @@ struct PostOrder {
{ }
// 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
// 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))
return false;
return pushForTraversing(node);
@@ -144,7 +144,7 @@ struct PostOrder {
// Return false on OOM or error return from `onNode::operator()` or
// `onEdge::operator()`.
template<typename NodeVisitor, typename EdgeVisitor>
- MOZ_MUST_USE bool traverse(NodeVisitor onNode, EdgeVisitor onEdge) {
+ [[nodiscard]] bool traverse(NodeVisitor onNode, EdgeVisitor onEdge) {
#ifdef DEBUG
MOZ_ASSERT(!traversed, "Can only traverse() once!");
traversed = true;
diff --git a/js/public/UbiNodeShortestPaths.h b/js/public/UbiNodeShortestPaths.h
index 18ed45a197..58c4568ff8 100644
--- a/js/public/UbiNodeShortestPaths.h
+++ b/js/public/UbiNodeShortestPaths.h
@@ -32,7 +32,7 @@ struct JS_PUBLIC_API(BackEdge)
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(!name_);
@@ -289,7 +289,7 @@ struct JS_PUBLIC_API(ShortestPaths)
* the given target, in which case `func` will not be invoked.
*/
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(targets_.has(target));
diff --git a/js/public/Utility.h b/js/public/Utility.h
index dbe69e18c0..e641c6097b 100644
--- a/js/public/Utility.h
+++ b/js/public/Utility.h
@@ -352,7 +352,7 @@ namespace js {
* instances of type |T|. Return false if the calculation overflowed.
*/
template <typename T>
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
CalculateAllocSize(size_t numElems, size_t* bytesOut)
{
*bytesOut = numElems * sizeof(T);
@@ -365,7 +365,7 @@ CalculateAllocSize(size_t numElems, size_t* bytesOut)
* false if the calculation overflowed.
*/
template <typename T, typename Extra>
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
CalculateAllocSizeWithExtra(size_t numExtra, size_t* bytesOut)
{
*bytesOut = sizeof(T) + numExtra * sizeof(Extra);
diff --git a/js/src/builtin/AtomicsObject.h b/js/src/builtin/AtomicsObject.h
index 18f00dad16..6e519cfa4a 100644
--- a/js/src/builtin/AtomicsObject.h
+++ b/js/src/builtin/AtomicsObject.h
@@ -21,21 +21,21 @@ class AtomicsObject : public JSObject
public:
static const Class class_;
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);
-MOZ_MUST_USE bool atomics_exchange(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_load(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_store(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_add(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_sub(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_and(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_or(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_xor(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_isLockFree(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_wait(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool atomics_notify(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_compareExchange(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_exchange(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_load(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_store(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_add(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_sub(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_and(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_or(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_xor(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_isLockFree(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_wait(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] bool atomics_notify(JSContext* cx, unsigned argc, Value* vp);
/* asm.js callouts */
namespace wasm { class Instance; }
@@ -52,14 +52,14 @@ class FutexRuntime
friend class AutoLockFutexAPI;
public:
- static MOZ_MUST_USE bool initialize();
+ [[nodiscard]] static bool initialize();
static void destroy();
static void lock();
static void unlock();
FutexRuntime();
- MOZ_MUST_USE bool initInstance();
+ [[nodiscard]] bool initInstance();
void destroyInstance();
// Parameters to notify().
@@ -83,8 +83,8 @@ public:
// wait.
//
// wait() will not wake up spuriously.
- MOZ_MUST_USE bool wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked,
- mozilla::Maybe<mozilla::TimeDuration>& timeout, WaitResult* result);
+ [[nodiscard]] bool wait(JSContext* cx, js::UniqueLock<js::Mutex>& locked,
+ mozilla::Maybe<mozilla::TimeDuration>& timeout, WaitResult* result);
// Notify the thread represented by this Runtime.
//
diff --git a/js/src/builtin/Eval.h b/js/src/builtin/Eval.h
index 4a1bd8642e..4b834928e2 100644
--- a/js/src/builtin/Eval.h
+++ b/js/src/builtin/Eval.h
@@ -16,17 +16,17 @@ namespace js {
// 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
// only ever called in the case indirect eval.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
IndirectEval(JSContext* cx, unsigned argc, Value* vp);
// Performs a direct eval of |v| (a string containing code, or another value
// that will be vacuously returned), which must correspond to the currently-
// executing stack frame, which must be a script frame.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
DirectEval(JSContext* cx, HandleValue v, MutableHandleValue vp);
// Performs a direct eval called from Ion code.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
DirectEvalStringFromIon(JSContext* cx,
HandleObject scopeObj, HandleScript callerScript,
HandleValue newTargetValue, HandleString str,
diff --git a/js/src/builtin/MapObject.cpp b/js/src/builtin/MapObject.cpp
index fe748a6bde..76f85cad63 100644
--- a/js/src/builtin/MapObject.cpp
+++ b/js/src/builtin/MapObject.cpp
@@ -476,7 +476,7 @@ class js::OrderedHashTableRef : public gc::BufferableRef
};
template <typename ObjectT>
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
WriteBarrierPostImpl(JSRuntime* rt, ObjectT* obj, const Value& keyValue)
{
if (MOZ_LIKELY(!keyValue.isObject()))
@@ -501,13 +501,13 @@ WriteBarrierPostImpl(JSRuntime* rt, ObjectT* obj, const Value& keyValue)
return true;
}
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
WriteBarrierPost(JSRuntime* rt, MapObject* map, const Value& key)
{
return WriteBarrierPostImpl(rt, map, key);
}
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
WriteBarrierPost(JSRuntime* rt, SetObject* set, const Value& key)
{
return WriteBarrierPostImpl(rt, set, key);
diff --git a/js/src/builtin/MapObject.h b/js/src/builtin/MapObject.h
index a9f685ea00..c62bdd633a 100644
--- a/js/src/builtin/MapObject.h
+++ b/js/src/builtin/MapObject.h
@@ -41,7 +41,7 @@ class HashableValue
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;
bool operator==(const HashableValue& other) const;
HashableValue mark(JSTracer* trc) const;
@@ -66,7 +66,7 @@ class MutableWrappedPtrOperations<HashableValue, Wrapper>
: public WrappedPtrOperations<HashableValue, Wrapper>
{
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);
}
};
@@ -107,26 +107,26 @@ class MapObject : public NativeObject {
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);
- static MOZ_MUST_USE bool entries(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool has(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool entries(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool has(JSContext* cx, unsigned argc, Value* vp);
static MapObject* create(JSContext* cx, HandleObject proto = nullptr);
// Publicly exposed Map calls for JSAPI access (webidl maplike/setlike
// interfaces, etc.)
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);
- static MOZ_MUST_USE 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 has(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
// as stated in spec, expects caller to return a value. for instance, with
// webidl maplike/setlike, should return interface object.
- static MOZ_MUST_USE bool set(JSContext *cx, HandleObject obj, HandleValue key, HandleValue val);
- static MOZ_MUST_USE bool clear(JSContext *cx, HandleObject obj);
- static MOZ_MUST_USE bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj,
+ [[nodiscard]] static bool set(JSContext *cx, HandleObject obj, HandleValue key, HandleValue val);
+ [[nodiscard]] static bool clear(JSContext *cx, HandleObject obj);
+ [[nodiscard]] static bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj,
MutableHandleValue iter);
using UnbarrieredTable = OrderedHashMap<Value, Value, UnbarrieredHashPolicy, RuntimeAllocPolicy>;
@@ -143,29 +143,29 @@ class MapObject : public NativeObject {
static ValueMap& extract(const CallArgs& args);
static void mark(JSTracer* trc, 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(HandleObject o);
- static MOZ_MUST_USE bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind);
-
- static MOZ_MUST_USE bool size_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool size(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool get_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool get(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool has_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool set_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool set(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool delete_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool delete_(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool keys_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool keys(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool values_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool values(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool entries_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool clear_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool clear(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind);
+
+ [[nodiscard]] static bool size_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool size(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool get_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool get(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool has_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool set_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool set(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool delete_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool delete_(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool keys_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool keys(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool values_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool values(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool entries_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool clear_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool clear(JSContext* cx, unsigned argc, Value* vp);
};
class MapIteratorObject : public NativeObject
@@ -187,7 +187,7 @@ class MapIteratorObject : public NativeObject
MapObject::IteratorKind kind);
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);
static JSObject* createResultPair(JSContext* cx);
@@ -213,21 +213,21 @@ class SetObject : public NativeObject {
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);
- static MOZ_MUST_USE bool values(JSContext *cx, unsigned argc, Value *vp);
- static MOZ_MUST_USE bool add(JSContext *cx, HandleObject obj, HandleValue key);
- static MOZ_MUST_USE bool has(JSContext *cx, unsigned argc, Value *vp);
+ [[nodiscard]] static bool values(JSContext *cx, unsigned argc, Value *vp);
+ [[nodiscard]] static bool add(JSContext *cx, HandleObject obj, HandleValue key);
+ [[nodiscard]] static bool has(JSContext *cx, unsigned argc, Value *vp);
// Publicly exposed Set calls for JSAPI access (webidl maplike/setlike
// interfaces, etc.)
static SetObject* create(JSContext *cx, HandleObject proto = nullptr);
static uint32_t size(JSContext *cx, HandleObject obj);
- static MOZ_MUST_USE bool has(JSContext *cx, HandleObject obj, HandleValue key, bool* rval);
- static MOZ_MUST_USE bool clear(JSContext *cx, HandleObject obj);
- static MOZ_MUST_USE bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj,
+ [[nodiscard]] static bool has(JSContext *cx, HandleObject obj, HandleValue key, bool* rval);
+ [[nodiscard]] static bool clear(JSContext *cx, HandleObject obj);
+ [[nodiscard]] static bool iterator(JSContext *cx, IteratorKind kind, HandleObject obj,
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>;
friend class OrderedHashTableRef<SetObject>;
@@ -251,20 +251,20 @@ class SetObject : public NativeObject {
static bool isBuiltinAdd(HandleValue add, JSContext* cx);
- static MOZ_MUST_USE bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind);
-
- static MOZ_MUST_USE bool size_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool size(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool has_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool add_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool add(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool delete_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool delete_(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool values_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool entries_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool entries(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool clear_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool clear(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool iterator_impl(JSContext* cx, const CallArgs& args, IteratorKind kind);
+
+ [[nodiscard]] static bool size_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool size(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool has_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool add_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool add(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool delete_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool delete_(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool values_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool entries_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool entries(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool clear_impl(JSContext* cx, const CallArgs& args);
+ [[nodiscard]] static bool clear(JSContext* cx, unsigned argc, Value* vp);
};
class SetIteratorObject : public NativeObject
@@ -286,7 +286,7 @@ class SetIteratorObject : public NativeObject
SetObject::IteratorKind kind);
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);
static JSObject* createResult(JSContext* cx);
@@ -299,7 +299,7 @@ using SetInitGetPrototypeOp = NativeObject* (*)(JSContext*, Handle<GlobalObject*
using SetInitIsBuiltinOp = bool (*)(HandleValue, JSContext*);
template <SetInitGetPrototypeOp getPrototypeOp, SetInitIsBuiltinOp isBuiltinOp>
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
IsOptimizableInitForSet(JSContext* cx, HandleObject setObject, HandleValue iterable, bool* optimized)
{
MOZ_ASSERT(!*optimized);
diff --git a/js/src/builtin/Object.h b/js/src/builtin/Object.h
index cd1fb51020..69bbc1b6ff 100644
--- a/js/src/builtin/Object.h
+++ b/js/src/builtin/Object.h
@@ -18,10 +18,10 @@ class Value;
namespace js {
// 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);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_propertyIsEnumerable(JSContext* cx, unsigned argc, Value* vp);
PlainObject*
@@ -32,32 +32,32 @@ PlainObject*
ObjectCreateWithTemplate(JSContext* cx, HandlePlainObject templateObj);
// 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);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_defineProperty(JSContext* cx, unsigned argc, JS::Value* vp);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_getOwnPropertyNames(JSContext* cx, unsigned argc, JS::Value* vp);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_getOwnPropertyDescriptor(JSContext* cx, unsigned argc, JS::Value* vp);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_getPrototypeOf(JSContext* cx, unsigned argc, JS::Value* vp);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_hasOwnProperty(JSContext* cx, unsigned argc, JS::Value* vp);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_isExtensible(JSContext* cx, unsigned argc, JS::Value* vp);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
obj_toString(JSContext* cx, unsigned argc, JS::Value* vp);
// 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);
/*
@@ -65,7 +65,7 @@ GetOwnPropertyKeys(JSContext* cx, const JS::CallArgs& args, unsigned flags);
* exposing a jsid to script for Object.getOwnProperty{Names,Symbols}
* or scriptable proxy traps.
*/
-MOZ_MUST_USE bool
+[[nodiscard]] bool
IdToStringOrSymbol(JSContext* cx, JS::HandleId id, JS::MutableHandleValue result);
#if JS_HAS_TOSOURCE
@@ -74,7 +74,7 @@ JSString*
ObjectToSource(JSContext* cx, JS::HandleObject obj);
#endif // JS_HAS_TOSOURCE
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
WatchHandler(JSContext* cx, JSObject* obj, jsid id, const JS::Value& old,
JS::Value* nvp, void* closure);
diff --git a/js/src/builtin/Profilers.h b/js/src/builtin/Profilers.h
index 6ef552a356..da71fd1a86 100644
--- a/js/src/builtin/Profilers.h
+++ b/js/src/builtin/Profilers.h
@@ -29,21 +29,21 @@ typedef int pid_t;
*
* 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);
/**
* Stop any profilers that were previously started with JS_StartProfiling.
* 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);
/**
* Write the current profile data to the given file, if applicable to whatever
* 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);
/**
@@ -51,13 +51,13 @@ JS_DumpProfile(const char* outfile, const char* profileName);
* whether any profilers failed to pause. (Profilers that do not support
* pause/resume do not count.)
*/
-extern MOZ_MUST_USE JS_PUBLIC_API(bool)
+[[nodiscard]] extern JS_PUBLIC_API(bool)
JS_PauseProfilers(const char* profileName);
/**
* Resume suspended profilers
*/
-extern MOZ_MUST_USE JS_PUBLIC_API(bool)
+[[nodiscard]] extern JS_PUBLIC_API(bool)
JS_ResumeProfilers(const char* profileName);
/**
@@ -70,23 +70,23 @@ JS_UnsafeGetLastProfilingError();
#ifdef MOZ_CALLGRIND
-extern MOZ_MUST_USE JS_FRIEND_API(bool)
+[[nodiscard]] extern JS_FRIEND_API(bool)
js_StopCallgrind();
-extern MOZ_MUST_USE JS_FRIEND_API(bool)
+[[nodiscard]] extern JS_FRIEND_API(bool)
js_StartCallgrind();
-extern MOZ_MUST_USE JS_FRIEND_API(bool)
+[[nodiscard]] extern JS_FRIEND_API(bool)
js_DumpCallgrind(const char* outfile);
#endif /* MOZ_CALLGRIND */
#ifdef __linux__
-extern MOZ_MUST_USE JS_FRIEND_API(bool)
+[[nodiscard]] extern JS_FRIEND_API(bool)
js_StartPerf();
-extern MOZ_MUST_USE JS_FRIEND_API(bool)
+[[nodiscard]] extern JS_FRIEND_API(bool)
js_StopPerf();
#endif /* __linux__ */
diff --git a/js/src/builtin/Promise.cpp b/js/src/builtin/Promise.cpp
index 7d4c232f2e..8755025ed0 100644
--- a/js/src/builtin/Promise.cpp
+++ b/js/src/builtin/Promise.cpp
@@ -311,7 +311,7 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
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
// for performance; we could go ahead and do the define via a cross-
// compartment proxy instead...
@@ -335,7 +335,7 @@ class MutableWrappedPtrOperations<PromiseCombinatorElements, Wrapper>
// Promise.all/allSettled/any function, which isn't necessarily the same
// compartment as unwrappedArray as explained in NewPromiseCombinatorElements.
// 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`.
MOZ_ASSERT(unwrappedArray()->getDenseElement(index).isUndefined());
@@ -560,7 +560,7 @@ MaybeGetAndClearException(JSContext* cx, MutableHandleValue 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,
HandleObject promiseObj);
@@ -778,7 +778,7 @@ static bool ResolvePromiseFunction(JSContext* cx, unsigned argc, Value* vp);
static bool RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp);
// ES2016, 25.4.1.3.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
CreateResolvingFunctions(JSContext* cx, HandleObject promise,
MutableHandleObject resolveFn,
MutableHandleObject rejectFn)
@@ -823,11 +823,11 @@ IsSettledMaybeWrappedPromise(JSObject* promise)
}
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason);
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason);
// ES2016, 25.4.1.3.1.
@@ -874,15 +874,15 @@ RejectPromiseFunction(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE bool FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj,
+[[nodiscard]] static bool FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj,
HandleValue value_);
-static MOZ_MUST_USE bool EnqueuePromiseResolveThenableJob(JSContext* cx,
+[[nodiscard]] static bool EnqueuePromiseResolveThenableJob(JSContext* cx,
HandleValue promiseToResolve,
HandleValue thenable,
HandleValue thenVal);
-static MOZ_MUST_USE bool EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx,
+[[nodiscard]] static bool EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx,
HandleObject promiseToResolve,
HandleObject thenable);
@@ -891,7 +891,7 @@ static bool Promise_then_impl(JSContext* cx, HandleValue promiseVal, HandleValue
HandleValue onRejected, MutableHandleValue rval, bool rvalUsed);
// ES2016, 25.4.1.3.2, steps 6-13.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ResolvePromiseInternal(JSContext* cx, HandleObject promise, HandleValue 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
* whether the onFulfilled or onRejected handler is called.
*/
-MOZ_MUST_USE static bool
+[[nodiscard]] static bool
EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj,
HandleValue handlerArg_, JS::PromiseState targetState)
{
@@ -1130,11 +1130,11 @@ EnqueuePromiseReactionJob(JSContext* cx, HandleObject reactionObj,
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);
// 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,
JS::PromiseState state)
{
@@ -1177,14 +1177,14 @@ ResolvePromise(JSContext* cx, Handle<PromiseObject*> promise, HandleValue valueO
}
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectPromiseInternal(JSContext* cx, Handle<PromiseObject*> promise, HandleValue reason)
{
return ResolvePromise(cx, promise, reason, JS::PromiseState::Rejected);
}
// ES2016, 25.4.1.4.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
FulfillMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue value_)
{
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 PromiseConstructor(JSContext* cx, unsigned argc, Value* vp);
-static MOZ_MUST_USE PromiseObject* CreatePromiseObjectInternal(JSContext* cx,
+[[nodiscard]] static PromiseObject* CreatePromiseObjectInternal(JSContext* cx,
HandleObject proto = nullptr,
bool protoIsWrapped = false,
bool informDebugger = true);
@@ -1220,7 +1220,7 @@ enum GetCapabilitiesExecutorSlots {
GetCapabilitiesExecutorSlots_Reject
};
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
CreatePromiseObjectWithoutResolutionFunctions(JSContext* cx)
{
Rooted<PromiseObject*> promise(cx, CreatePromiseObjectInternal(cx));
@@ -1231,7 +1231,7 @@ CreatePromiseObjectWithoutResolutionFunctions(JSContext* cx)
return promise;
}
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
CreatePromiseWithDefaultResolutionFunctions(JSContext* cx, MutableHandleObject resolve,
MutableHandleObject reject)
{
@@ -1258,7 +1258,7 @@ CreatePromiseWithDefaultResolutionFunctions(JSContext* cx, MutableHandleObject r
}
// ES2016, 25.4.1.5.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
NewPromiseCapability(JSContext* cx, HandleObject C, MutableHandle<PromiseCapability> capability,
bool canOmitResolutionFunctions)
{
@@ -1369,7 +1369,7 @@ GetCapabilitiesExecutor(JSContext* cx, unsigned argc, Value* vp)
}
// ES2016, 25.4.1.7.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue reason_)
{
Rooted<PromiseObject*> promise(cx);
@@ -1410,7 +1410,7 @@ RejectMaybeWrappedPromise(JSContext *cx, HandleObject promiseObj, HandleValue re
}
// ES2016, 25.4.1.8.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseState state,
HandleValue valueOrReason)
{
@@ -1440,7 +1440,7 @@ TriggerPromiseReactions(JSContext* cx, HandleValue reactionsVal, JS::PromiseStat
// Implements PromiseReactionJob optimized for the case when the reaction
// handler is one of the default resolving functions as created by the
// CreateResolvingFunctions abstract operation.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
DefaultResolvingPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval)
{
@@ -1485,7 +1485,7 @@ DefaultResolvingPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*>
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncFunctionPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval)
{
@@ -1513,7 +1513,7 @@ AsyncFunctionPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> re
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncGeneratorPromiseReactionJob(JSContext* cx, Handle<PromiseReactionRecord*> reaction,
MutableHandleValue rval)
{
@@ -1723,7 +1723,7 @@ PromiseResolveThenableJob(JSContext* cx, unsigned argc, Value* vp)
return Call(cx, rejectVal, UndefinedHandleValue, rval, &rval);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve);
@@ -1785,7 +1785,7 @@ PromiseResolveBuiltinThenableJob(JSContext* cx, unsigned argc, Value* vp)
* thenable_ - The thenable to resolve the Promise with.
* 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_,
HandleValue thenable_, HandleValue thenVal)
{
@@ -1847,7 +1847,7 @@ EnqueuePromiseResolveThenableJob(JSContext* cx, HandleValue promiseToResolve_,
* promiseToResolve - The promise to resolve, obviously.
* thenable - The thenable to resolve the Promise with.
*/
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToResolve,
HandleObject thenable)
{
@@ -1869,11 +1869,11 @@ EnqueuePromiseResolveThenableBuiltinJob(JSContext* cx, HandleObject promiseToRes
return cx->runtime()->enqueuePromiseJob(cx, job, promiseToResolve, incumbentGlobal);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise,
HandleObject dependentPromise);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction);
@@ -1947,7 +1947,7 @@ ClearResolutionFunctionSlots(JSFunction* resolutionFun)
}
// ES2016, 25.4.3.1. steps 3-7.
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
CreatePromiseObjectInternal(JSContext* cx, HandleObject proto /* = nullptr */,
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,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAllSettled(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAny(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseRace(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done);
@@ -2204,7 +2204,7 @@ enum class CombinatorKind { All, AllSettled, Any, Race };
// https://tc39.es/proposal-promise-any/
//
// Promise.any ( iterable )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
CommonPromiseCombinator(JSContext* cx, CallArgs& args, CombinatorKind mode)
{
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);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_,
HandleValue onRejected_, Handle<PromiseCapability> resultCapability);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve,
Handle<PromiseCapability> resultCapability);
@@ -2356,7 +2356,7 @@ static JSFunction* NewPromiseCombinatorElementFunction(
static bool PromiseAllResolveElementFunction(JSContext* cx, unsigned argc, Value* vp);
// Unforgeable version of ES2016, 25.4.4.1.
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises)
{
#ifdef DEBUG
@@ -2476,7 +2476,7 @@ js::GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises)
return resultCapability.promise();
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue result,
ResolutionMode mode, HandleObject promiseObj)
{
@@ -2528,7 +2528,7 @@ RunResolutionFunction(JSContext *cx, HandleObject resolutionFun, HandleValue res
return RejectPromiseInternal(cx, promise, result);
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal,
ResolutionMode mode);
@@ -2544,7 +2544,7 @@ IsPromiseSpecies(JSContext* cx, JSFunction* species);
// https://tc39.es/proposal-promise-any/
// Runtime Semantics: PerformPromiseAny, steps 6-8.
template <typename T>
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
CommonPerformPromiseCombinator(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
HandleObject resultPromise, HandleValue promiseResolve, bool* done,
bool resolveReturnsUndefined, T getResolveAndReject)
@@ -2810,7 +2810,7 @@ CommonPerformPromiseCombinator(JSContext *cx, PromiseForOfIterator& iterator, Ha
// Create the elements for the Promise combinators Promise.all and
// Promise.allSettled.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
NewPromiseCombinatorElements(JSContext* cx, Handle<PromiseCapability> resultCapability,
MutableHandle<PromiseCombinatorElements> elements)
{
@@ -2862,7 +2862,7 @@ NewPromiseCombinatorElements(JSContext* cx, Handle<PromiseCapability> resultCapa
}
// Retrieve the combinator elements from the data holder.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
GetPromiseCombinatorElements(JSContext* cx, Handle<PromiseCombinatorDataHolder*> data,
MutableHandle<PromiseCombinatorElements> elements)
{
@@ -2947,7 +2947,7 @@ PromiseCombinatorElementFunctionAlreadyCalled(const CallArgs& args,
// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
// 25.6.4.1.1 PerformPromiseAll (iteratorRecord, constructor, resultCapability)
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAll(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done)
{
@@ -3083,7 +3083,7 @@ Promise_static_race(JSContext* cx, unsigned argc, Value* vp)
// ES2020 draft rev a09fc232c137800dbf51b6204f37fdede4ba1646
// 25.6.4.3.1 PerformPromiseRace (iteratorRecord, constructor, resultCapability)
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseRace(JSContext *cx, PromiseForOfIterator& iterator, HandleObject C,
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 )
//
// PerformPromiseAllSettled ( iteratorRecord, constructor, resultCapability )
-static MOZ_MUST_USE bool PerformPromiseAllSettled(
+[[nodiscard]] static bool PerformPromiseAllSettled(
JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
Handle<PromiseCapability> resultCapability, HandleValue promiseResolve, bool* done) {
*done = false;
@@ -3349,7 +3349,7 @@ static void ThrowAggregateError(JSContext* cx,
// https://tc39.es/proposal-promise-any/
//
// PerformPromiseAny ( iteratorRecord, constructor, resultCapability )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseAny(JSContext* cx, PromiseForOfIterator& iterator, HandleObject C,
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.5 Promise.resolve ( x )
// 25.6.4.5.1 PromiseResolve ( C, x )
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue argVal,
ResolutionMode mode)
{
@@ -3610,7 +3610,7 @@ CommonStaticResolveRejectImpl(JSContext* cx, HandleValue thisVal, HandleValue ar
return capability.promise();
}
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
js::PromiseResolve(JSContext* cx, HandleObject constructor, HandleValue value)
{
RootedValue C(cx, ObjectValue(*constructor));
@@ -3789,7 +3789,7 @@ PromiseThenNewPromiseCapability(JSContext* cx, HandleObject promiseObj,
}
// ES2016, 25.4.5.3., steps 3-5.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
HandleValue onFulfilled, HandleValue onRejected,
MutableHandleObject dependent, CreateDependentPromise createDependent)
@@ -3813,7 +3813,7 @@ js::OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
OriginalPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve)
{
@@ -3870,7 +3870,7 @@ OriginalPromiseThenBuiltin(JSContext* cx, HandleValue promiseVal, HandleValue on
return true;
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise)
{
// 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);
}
-static MOZ_MUST_USE bool PerformPromiseThenWithReaction(JSContext* cx,
+[[nodiscard]] static bool PerformPromiseThenWithReaction(JSContext* cx,
Handle<PromiseObject*> promise,
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.
// ES 2018 draft 14.6.11 and 14.7.14 step 1.
-MOZ_MUST_USE PromiseObject*
+[[nodiscard]] PromiseObject*
js::CreatePromiseObjectForAsync(JSContext* cx, HandleValue generatorVal)
{
// Step 1.
@@ -3909,7 +3909,7 @@ js::IsPromiseForAsync(JSObject* promise)
}
// 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)
{
// 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.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value)
{
// Steps 3.d-e.
@@ -3939,7 +3939,7 @@ js::AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, H
// Helper function that performs the equivalent steps as
// Async Iteration proposal 4.1 Await steps 2-3, 6-9 or similar.
template <typename T>
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
InternalAwait(JSContext* cx, HandleValue value, HandleObject resultPromise,
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.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value)
{
// Steps 4-5.
@@ -3987,7 +3987,7 @@ js::AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, Hand
}
// Async Iteration proposal 4.1 Await steps 2-9.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorAwait(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value)
{
@@ -4146,13 +4146,13 @@ enum class ResumeNextKind {
Enqueue, Reject, Resolve
};
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
ResumeNextKind kind, HandleValue valueOrException = UndefinedHandleValue,
bool done = false);
// Async Iteration proposal 11.4.3.3.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value, bool done)
{
@@ -4160,7 +4160,7 @@ js::AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenO
}
// Async Iteration proposal 11.4.3.4.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue exception)
{
@@ -4168,7 +4168,7 @@ js::AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenOb
}
// Async Iteration proposal 11.4.3.5.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
ResumeNextKind kind,
HandleValue valueOrException_ /* = UndefinedHandleValue */,
@@ -4349,7 +4349,7 @@ AsyncGeneratorResumeNext(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenOb
}
// Async Iteration proposal 11.4.3.6.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::AsyncGeneratorEnqueue(JSContext* cx, HandleValue asyncGenVal,
CompletionKind completionKind, HandleValue completionValue,
MutableHandleValue result)
@@ -4540,7 +4540,7 @@ Promise_then(JSContext* cx, unsigned argc, Value* vp)
}
// ES2016, 25.4.5.3.1.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue onFulfilled_,
HandleValue onRejected_, Handle<PromiseCapability> resultCapability)
{
@@ -4567,7 +4567,7 @@ PerformPromiseThen(JSContext* cx, Handle<PromiseObject*> promise, HandleValue on
return PerformPromiseThenWithReaction(cx, promise, reaction);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseObject*> promiseToResolve,
Handle<PromiseCapability> resultCapability)
@@ -4593,7 +4593,7 @@ PerformPromiseThenWithoutSettleHandlers(JSContext* cx, Handle<PromiseObject*> pr
return PerformPromiseThenWithReaction(cx, promise, reaction);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
PerformPromiseThenWithReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction)
{
@@ -4637,7 +4637,7 @@ PerformPromiseThenWithReaction(JSContext* cx, Handle<PromiseObject*> promise,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
Handle<PromiseReactionRecord*> reaction)
{
@@ -4705,7 +4705,7 @@ AddPromiseReaction(JSContext* cx, Handle<PromiseObject*> promise,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AddDummyPromiseReactionForDebugger(JSContext* cx, Handle<PromiseObject*> promise,
HandleObject dependentPromise)
{
diff --git a/js/src/builtin/Promise.h b/js/src/builtin/Promise.h
index 5e5c850d60..f7c638acc7 100644
--- a/js/src/builtin/Promise.h
+++ b/js/src/builtin/Promise.h
@@ -73,10 +73,10 @@ class PromiseObject : public NativeObject
return getFixedSlot(PromiseSlot_ReactionsOrResult);
}
- static MOZ_MUST_USE bool resolve(JSContext* cx, Handle<PromiseObject*> promise,
- HandleValue resolutionValue);
- static MOZ_MUST_USE bool reject(JSContext* cx, Handle<PromiseObject*> promise,
- HandleValue rejectionValue);
+ [[nodiscard]] static bool resolve(JSContext* cx, Handle<PromiseObject*> promise,
+ HandleValue resolutionValue);
+ [[nodiscard]] static bool reject(JSContext* cx, Handle<PromiseObject*> promise,
+ HandleValue rejectionValue);
static void onSettled(JSContext* cx, Handle<PromiseObject*> promise);
@@ -89,7 +89,7 @@ class PromiseObject : public NativeObject
MOZ_ASSERT(state() != JS::PromiseState::Pending);
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();
bool isUnhandled() {
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,
* instances of `Promise` or a subclass of `Promise`.
*/
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises);
enum class CreateDependentPromise {
@@ -132,7 +132,7 @@ enum class CreateDependentPromise {
* `promise` field that can contain null. That field is only ever used by
* devtools, which have to treat these reactions specially.
*/
-MOZ_MUST_USE bool
+[[nodiscard]] bool
OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
HandleValue onFulfilled, HandleValue onRejected,
MutableHandleObject dependent, CreateDependentPromise createDependent);
@@ -143,41 +143,41 @@ OriginalPromiseThen(JSContext* cx, Handle<PromiseObject*> promise,
* The abstract operation PromiseResolve, given a constructor and a value,
* returns a new promise resolved with that value.
*/
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
PromiseResolve(JSContext* cx, HandleObject constructor, HandleValue value);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RejectPromiseWithPendingError(JSContext* cx, Handle<PromiseObject*> promise);
-MOZ_MUST_USE PromiseObject*
+[[nodiscard]] PromiseObject*
CreatePromiseObjectForAsync(JSContext* cx, HandleValue generatorVal);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
IsPromiseForAsync(JSObject* promise);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AsyncFunctionReturned(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AsyncFunctionThrown(JSContext* cx, Handle<PromiseObject*> resultPromise);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AsyncFunctionAwait(JSContext* cx, Handle<PromiseObject*> resultPromise, HandleValue value);
class AsyncGeneratorObject;
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AsyncGeneratorAwait(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj, HandleValue value);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AsyncGeneratorResolve(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue value, bool done);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AsyncGeneratorReject(JSContext* cx, Handle<AsyncGeneratorObject*> asyncGenObj,
HandleValue exception);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AsyncGeneratorEnqueue(JSContext* cx, HandleValue asyncGenVal, CompletionKind completionKind,
HandleValue completionValue, MutableHandleValue result);
diff --git a/js/src/builtin/Reflect.h b/js/src/builtin/Reflect.h
index abe088c2da..21857d4fcc 100644
--- a/js/src/builtin/Reflect.h
+++ b/js/src/builtin/Reflect.h
@@ -17,10 +17,10 @@ InitReflect(JSContext* cx, js::HandleObject obj);
namespace js {
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
Reflect_getPrototypeOf(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
Reflect_isExtensible(JSContext* cx, unsigned argc, Value* vp);
}
diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp
index a8dd93aab2..7eb7c46b2d 100644
--- a/js/src/builtin/ReflectParse.cpp
+++ b/js/src/builtin/ReflectParse.cpp
@@ -256,7 +256,7 @@ class NodeBuilder
userv(c)
{}
- MOZ_MUST_USE bool init(HandleObject userobj = nullptr) {
+ [[nodiscard]] bool init(HandleObject userobj = nullptr) {
if (src) {
if (!atomValue(src, &srcval))
return false;
@@ -307,7 +307,7 @@ class NodeBuilder
}
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)
{
// 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,
// just variadic.
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)
{
// Recursive loop to store the arguments into args. This eventually
@@ -338,7 +338,7 @@ class NodeBuilder
// bool callback(HandleValue fun, HandleValue... args, TokenPos* pos,
// MutableHandleValue dst);
template <typename... Arguments>
- MOZ_MUST_USE bool callback(HandleValue fun, Arguments&&... args) {
+ [[nodiscard]] bool callback(HandleValue fun, Arguments&&... args) {
InvokeArgs iargs(cx);
if (!iargs.init(cx, sizeof...(args) - 2 + size_t(saveLoc)))
return false;
@@ -355,7 +355,7 @@ class NodeBuilder
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
*/
@@ -367,7 +367,7 @@ class NodeBuilder
return true;
}
- MOZ_MUST_USE bool newObject(MutableHandleObject dst) {
+ [[nodiscard]] bool newObject(MutableHandleObject dst) {
RootedPlainObject nobj(cx, NewBuiltinClassInstance<PlainObject>(cx));
if (!nobj)
return false;
@@ -376,11 +376,11 @@ class NodeBuilder
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().
MOZ_ASSERT(obj);
dst.setObject(*obj);
@@ -388,7 +388,7 @@ class NodeBuilder
}
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)
{
// Recursive loop to define properties. Note that the newNodeHelper()
@@ -407,13 +407,13 @@ class NodeBuilder
// {const char *name0, HandleValue value0,}...
// MutableHandleValue dst);
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);
return createNode(type, pos, &node) &&
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) {
RootedValue array(cx);
if (!newArray(elts, &array))
@@ -426,7 +426,7 @@ class NodeBuilder
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);
/*
@@ -441,9 +441,9 @@ class NodeBuilder
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:
/*
@@ -459,27 +459,27 @@ class NodeBuilder
* 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 body, HandleValue rest, GeneratorStyle generatorStyle,
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);
- 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);
- MOZ_MUST_USE bool prototypeMutation(HandleValue val, TokenPos* pos, MutableHandleValue dst);
- MOZ_MUST_USE bool propertyInitializer(HandleValue key, HandleValue val, PropKind kind,
+ [[nodiscard]] bool prototypeMutation(HandleValue val, TokenPos* pos, MutableHandleValue dst);
+ [[nodiscard]] bool propertyInitializer(HandleValue key, HandleValue val, PropKind kind,
bool isShorthand, bool isMethod, TokenPos* pos,
MutableHandleValue dst);
@@ -488,165 +488,165 @@ class NodeBuilder
* 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- 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);
- MOZ_MUST_USE bool classMembers(NodeVector& members, MutableHandleValue dst);
- MOZ_MUST_USE bool classMethod(HandleValue name, HandleValue body, PropKind kind, bool isStatic,
+ [[nodiscard]] bool classMembers(NodeVector& members, MutableHandleValue dst);
+ [[nodiscard]] bool classMethod(HandleValue name, HandleValue body, PropKind kind, bool isStatic,
TokenPos* pos, MutableHandleValue dst);
- MOZ_MUST_USE bool classField(HandleValue name, HandleValue initializer,
+ [[nodiscard]] bool classField(HandleValue name, HandleValue initializer,
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
*/
- MOZ_MUST_USE bool binaryExpression(BinaryOperator op, HandleValue left, HandleValue right,
+ [[nodiscard]] bool binaryExpression(BinaryOperator op, HandleValue left, HandleValue right,
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);
- MOZ_MUST_USE bool assignmentExpression(AssignmentOperator op, HandleValue lhs, HandleValue rhs,
+ [[nodiscard]] bool assignmentExpression(AssignmentOperator op, HandleValue lhs, HandleValue rhs,
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);
- 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);
- MOZ_MUST_USE bool conditionalExpression(HandleValue test, HandleValue cons, HandleValue alt,
+ [[nodiscard]] bool conditionalExpression(HandleValue test, HandleValue cons, HandleValue alt,
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);
- 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);
- MOZ_MUST_USE bool memberExpression(bool computed, HandleValue expr, HandleValue member,
+ [[nodiscard]] bool memberExpression(bool computed, HandleValue expr, HandleValue member,
TokenPos* pos, MutableHandleValue dst,
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);
- MOZ_MUST_USE bool callSiteObj(NodeVector& raw, NodeVector& cooked, TokenPos* pos,
+ [[nodiscard]] bool callSiteObj(NodeVector& raw, NodeVector& cooked, TokenPos* pos,
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);
- 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);
- 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);
- 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,
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);
- MOZ_MUST_USE bool metaProperty(HandleValue meta, HandleValue property, TokenPos* pos,
+ [[nodiscard]] bool metaProperty(HandleValue meta, HandleValue property, TokenPos* pos,
MutableHandleValue dst);
- MOZ_MUST_USE bool callImportExpression(HandleValue ident, HandleValue arg, TokenPos* pos,
+ [[nodiscard]] bool callImportExpression(HandleValue ident, HandleValue arg, TokenPos* pos,
MutableHandleValue dst);
- MOZ_MUST_USE bool super(TokenPos* pos, MutableHandleValue dst);
+ [[nodiscard]] bool super(TokenPos* pos, MutableHandleValue dst);
/*
* declarations
*/
- MOZ_MUST_USE bool variableDeclaration(NodeVector& elts, VarDeclKind kind, TokenPos* pos,
+ [[nodiscard]] bool variableDeclaration(NodeVector& elts, VarDeclKind kind, TokenPos* pos,
MutableHandleValue dst);
/*
* 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);
};
diff --git a/js/src/builtin/RegExp.h b/js/src/builtin/RegExp.h
index c0a7d59f77..eefd19570a 100644
--- a/js/src/builtin/RegExp.h
+++ b/js/src/builtin/RegExp.h
@@ -25,42 +25,42 @@ InitRegExpClass(JSContext* cx, HandleObject obj);
* |input| may be nullptr if there is no JSString corresponding to
* |chars| and |length|.
*/
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ExecuteRegExpLegacy(JSContext* cx, RegExpStatics* res, Handle<RegExpObject*> reobj,
HandleLinearString input, size_t* lastIndex, bool test,
MutableHandleValue rval);
/* Translation from MatchPairs to a JS array in regexp_exec()'s output format. */
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CreateRegExpMatchResult(JSContext* cx, RegExpShared& re,
HandleString input, const MatchPairs& matches,
MutableHandleValue rval);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpMatcher(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpMatcherRaw(JSContext* cx, HandleObject regexp, HandleString input,
int32_t lastIndex, MatchPairs* maybeMatches, MutableHandleValue output);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpSearcher(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpSearcherRaw(JSContext* cx, HandleObject regexp, HandleString input,
int32_t lastIndex, MatchPairs* maybeMatches, int32_t* result);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpTester(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpTesterRaw(JSContext* cx, HandleObject regexp, HandleString input,
int32_t lastIndex, int32_t* endIndex);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intrinsic_GetElemBaseForLambda(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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|.
* 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);
/*
* Clone given RegExp object, inheriting pattern and flags, ignoring other
* properties.
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
regexp_clone(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
IsRegExp(JSContext* cx, HandleValue value, bool* result);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpCreate(JSContext* cx, HandleValue pattern, HandleValue flags, MutableHandleValue rval);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpPrototypeOptimizable(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpPrototypeOptimizableRaw(JSContext* cx, JSObject* proto);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpInstanceOptimizable(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpInstanceOptimizableRaw(JSContext* cx, JSObject* obj, JSObject* proto);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
RegExpGetSubstitution(JSContext* cx, HandleArrayObject matchResult, HandleLinearString string,
size_t position, HandleLinearString replacement, size_t firstDollarIndex,
HandleValue namedCaptures, MutableHandleValue rval);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
GetFirstDollarIndex(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
GetFirstDollarIndexRaw(JSContext* cx, HandleString str, int32_t* index);
extern int32_t
GetFirstDollarIndexRawFlat(JSLinearString* text);
// RegExp ClassSpec members used in RegExpObject.cpp.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
regexp_construct(JSContext* cx, unsigned argc, Value* vp);
extern const JSPropertySpec regexp_static_props[];
extern const JSPropertySpec regexp_properties[];
extern const JSFunctionSpec regexp_methods[];
// Used in RegExpObject::isOriginalFlagGetter.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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);
} /* namespace js */
diff --git a/js/src/builtin/Stream.cpp b/js/src/builtin/Stream.cpp
index 26457709d8..b4785ef171 100644
--- a/js/src/builtin/Stream.cpp
+++ b/js/src/builtin/Stream.cpp
@@ -179,14 +179,14 @@ js::ReadableStreamReaderIsClosed(const JSObject* reader)
return !ReaderHasStream(&reader->as<NativeObject>());
}
-inline static MOZ_MUST_USE ReadableStream*
+[[nodiscard]] inline static ReadableStream*
StreamFromController(const NativeObject* controller)
{
MOZ_ASSERT(IsReadableStreamController(controller));
return &controller->getFixedSlot(ControllerSlot_Stream).toObject().as<ReadableStream>();
}
-inline static MOZ_MUST_USE NativeObject*
+[[nodiscard]] inline static NativeObject*
ControllerFromStream(const ReadableStream* stream)
{
Value controllerVal = stream->getFixedSlot(StreamSlot_Controller);
@@ -211,14 +211,14 @@ ReadableStream::mode() const
: JS::ReadableStreamMode::Byte;
}
-inline static MOZ_MUST_USE ReadableStream*
+[[nodiscard]] inline static ReadableStream*
StreamFromReader(const NativeObject* reader)
{
MOZ_ASSERT(ReaderHasStream(reader));
return &reader->getFixedSlot(ReaderSlot_Stream).toObject().as<ReadableStream>();
}
-inline static MOZ_MUST_USE NativeObject*
+[[nodiscard]] inline static NativeObject*
ReaderFromStream(const NativeObject* stream)
{
Value readerVal = stream->getFixedSlot(StreamSlot_Reader);
@@ -232,7 +232,7 @@ HasReader(const ReadableStream* stream)
return !stream->getFixedSlot(StreamSlot_Reader).isUndefined();
}
-inline static MOZ_MUST_USE JSFunction*
+[[nodiscard]] inline static JSFunction*
NewHandler(JSContext *cx, Native handler, HandleObject target)
{
RootedAtom funName(cx, cx->names().empty);
@@ -246,23 +246,23 @@ NewHandler(JSContext *cx, Native handler, HandleObject target)
}
template<class T>
-inline static MOZ_MUST_USE T*
+[[nodiscard]] inline static T*
TargetFromHandler(JSObject& handler)
{
return &handler.as<JSFunction>().getExtendedSlot(0).toObject().as<T>();
}
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
ResetQueue(JSContext* cx, HandleNativeObject container);
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
InvokeOrNoop(JSContext* cx, HandleValue O, HandlePropertyName P, HandleValue arg,
MutableHandleValue rval);
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
PromiseInvokeOrNoop(JSContext* cx, HandleValue O, HandlePropertyName P, HandleValue arg);
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
PromiseRejectedWithPendingError(JSContext* cx) {
// Not much we can do about uncatchable exceptions, just bail.
RootedValue exn(cx);
@@ -284,7 +284,7 @@ ReportArgTypeError(JSContext* cx, const char* funName, const char* expectedType,
funName, expectedType, bytes.get());
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReturnPromiseRejectedWithPendingError(JSContext* cx, const CallArgs& args)
{
JSObject* promise = PromiseRejectedWithPendingError(cx);
@@ -295,7 +295,7 @@ ReturnPromiseRejectedWithPendingError(JSContext* cx, const CallArgs& args)
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RejectNonGenericMethod(JSContext* cx, const CallArgs& args,
const char* className, const char* methodName)
{
@@ -305,7 +305,7 @@ RejectNonGenericMethod(JSContext* cx, const CallArgs& args,
return ReturnPromiseRejectedWithPendingError(cx, args);
}
-inline static MOZ_MUST_USE NativeObject*
+[[nodiscard]] inline static NativeObject*
SetNewList(JSContext* cx, HandleNativeObject container, uint32_t slot)
{
NativeObject* list = NewObjectWithNullTaggedProto<PlainObject>(cx);
@@ -315,7 +315,7 @@ SetNewList(JSContext* cx, HandleNativeObject container, uint32_t slot)
return list;
}
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
AppendToList(JSContext* cx, HandleNativeObject list, HandleValue value)
{
uint32_t length = list->getDenseInitializedLength();
@@ -330,7 +330,7 @@ AppendToList(JSContext* cx, HandleNativeObject list, HandleValue value)
}
template<class T>
-inline static MOZ_MUST_USE T*
+[[nodiscard]] inline static T*
PeekList(NativeObject* list)
{
MOZ_ASSERT(list->getDenseInitializedLength() > 0);
@@ -338,7 +338,7 @@ PeekList(NativeObject* list)
}
template<class T>
-inline static MOZ_MUST_USE T*
+[[nodiscard]] inline static T*
ShiftFromList(JSContext* cx, HandleNativeObject list)
{
uint32_t length = list->getDenseInitializedLength();
@@ -645,7 +645,7 @@ ReadableStream::createStream(JSContext* cx, HandleObject proto /* = nullptr */)
return stream;
}
-static MOZ_MUST_USE ReadableStreamDefaultController*
+[[nodiscard]] static ReadableStreamDefaultController*
CreateReadableStreamDefaultController(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue underlyingSource, HandleValue size,
HandleValue highWaterMarkVal);
@@ -677,7 +677,7 @@ ReadableStream::createDefaultStream(JSContext* cx, HandleValue underlyingSource,
return stream;
}
-static MOZ_MUST_USE ReadableByteStreamController*
+[[nodiscard]] static ReadableByteStreamController*
CreateReadableByteStreamController(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue underlyingByteSource,
HandleValue highWaterMarkVal);
@@ -706,7 +706,7 @@ ReadableStream::createByteStream(JSContext* cx, HandleValue underlyingSource,
return stream;
}
-static MOZ_MUST_USE ReadableByteStreamController*
+[[nodiscard]] static ReadableByteStreamController*
CreateReadableByteStreamController(JSContext* cx, Handle<ReadableStream*> stream,
void* underlyingSource);
@@ -807,7 +807,7 @@ ReadableStream::constructor(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.2.4.1. get locked
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStream_locked_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStream*> stream(cx, &args.thisv().toObject().as<ReadableStream>());
@@ -826,7 +826,7 @@ ReadableStream_locked(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.2.4.2. cancel ( reason )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStream_cancel(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -856,14 +856,14 @@ ReadableStream_cancel(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE ReadableStreamDefaultReader*
+[[nodiscard]] static ReadableStreamDefaultReader*
CreateReadableStreamDefaultReader(JSContext* cx, Handle<ReadableStream*> stream);
-static MOZ_MUST_USE ReadableStreamBYOBReader*
+[[nodiscard]] static ReadableStreamBYOBReader*
CreateReadableStreamBYOBReader(JSContext* cx, Handle<ReadableStream*> stream);
// Streams spec, 3.2.4.3. getReader()
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStream_getReader_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStream*> stream(cx, &args.thisv().toObject().as<ReadableStream>());
@@ -916,7 +916,7 @@ ReadableStream_getReader(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.2.4.4. pipeThrough({ writable, readable }, options)
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStream_pipeThrough(JSContext* cx, unsigned argc, Value* vp)
{
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
@@ -930,7 +930,7 @@ ReadableStream_pipeThrough(JSContext* cx, unsigned argc, Value* vp)
// Streams spec, 3.2.4.5. pipeTo(dest, { preventClose, preventAbort, preventCancel } = {})
// TODO: Unimplemented since spec is not complete yet.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStream_pipeTo(JSContext* cx, unsigned argc, Value* vp)
{
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr,
@@ -938,12 +938,12 @@ ReadableStream_pipeTo(JSContext* cx, unsigned argc, Value* vp)
return false;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamTee(JSContext* cx, Handle<ReadableStream*> stream, bool cloneForBranch2,
MutableHandle<ReadableStream*> branch1, MutableHandle<ReadableStream*> branch2);
// Streams spec, 3.2.4.6. tee()
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStream_tee_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStream*> stream(cx, &args.thisv().toObject().as<ReadableStream>());
@@ -1022,10 +1022,10 @@ ReadableStream::locked() const
return HasReader(this);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerClose(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerEnqueue(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller,
HandleValue chunk);
@@ -1111,7 +1111,7 @@ TeeReaderReadHandler(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamTee_Pull(JSContext* cx, Handle<TeeState*> teeState,
Handle<ReadableStream*> branchStream)
{
@@ -1135,7 +1135,7 @@ ReadableStreamTee_Pull(JSContext* cx, Handle<TeeState*> teeState,
return JS::CallOriginalPromiseThen(cx, readPromise, onFulfilled, nullptr);
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamTee_Cancel(JSContext* cx, Handle<TeeState*> teeState,
Handle<ReadableStreamDefaultController*> branch, HandleValue reason)
{
@@ -1188,7 +1188,7 @@ ReadableStreamTee_Cancel(JSContext* cx, Handle<TeeState*> teeState,
return teeState->promise();
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamControllerError(JSContext* cx, HandleNativeObject controller, HandleValue e);
// Streams spec, 3.3.6. step 21:
@@ -1220,7 +1220,7 @@ TeeReaderClosedHandler(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.3.6. ReadableStreamTee ( stream, cloneForBranch2 )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamTee(JSContext* cx, Handle<ReadableStream*> stream, bool cloneForBranch2,
MutableHandle<ReadableStream*> branch1Stream,
MutableHandle<ReadableStream*> branch2Stream)
@@ -1308,7 +1308,7 @@ ReadableStreamTee(JSContext* cx, Handle<ReadableStream*> stream, bool cloneForBr
}
// Streams spec, 3.4.1. ReadableStreamAddReadIntoRequest ( stream )
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
ReadableStreamAddReadIntoRequest(JSContext* cx, Handle<ReadableStream*> stream)
{
// Step 1: MOZ_ASSERT: ! IsReadableStreamBYOBReader(stream.[[reader]]) is true.
@@ -1337,7 +1337,7 @@ ReadableStreamAddReadIntoRequest(JSContext* cx, Handle<ReadableStream*> stream)
}
// Streams spec, 3.4.2. ReadableStreamAddReadRequest ( stream )
-static MOZ_MUST_USE PromiseObject*
+[[nodiscard]] static PromiseObject*
ReadableStreamAddReadRequest(JSContext* cx, Handle<ReadableStream*> stream)
{
MOZ_ASSERT(stream->is<ReadableStream>());
@@ -1367,7 +1367,7 @@ ReadableStreamAddReadRequest(JSContext* cx, Handle<ReadableStream*> stream)
return promise;
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamControllerCancelSteps(JSContext* cx,
HandleNativeObject controller, HandleValue reason);
@@ -1380,11 +1380,11 @@ ReturnUndefined(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStreamCloseInternal(JSContext* cx, Handle<ReadableStream*> stream);
// Streams spec, 3.4.3. ReadableStreamCancel ( stream, reason )
-/* static */ MOZ_MUST_USE JSObject*
+/* static */ [[nodiscard]] JSObject*
ReadableStream::cancel(JSContext* cx, Handle<ReadableStream*> stream, HandleValue reason)
{
// Step 1: Set stream.[[disturbed]] to true.
@@ -1425,7 +1425,7 @@ ReadableStream::cancel(JSContext* cx, Handle<ReadableStream*> stream, HandleValu
}
// Streams spec, 3.4.4. ReadableStreamClose ( stream )
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStreamCloseInternal(JSContext* cx, Handle<ReadableStream*> stream)
{
// Step 1: Assert: stream.[[state]] is "readable".
@@ -1489,7 +1489,7 @@ ReadableStreamCloseInternal(JSContext* cx, Handle<ReadableStream*> stream)
}
// Streams spec, 3.4.5. ReadableStreamError ( stream, e )
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStreamErrorInternal(JSContext* cx, Handle<ReadableStream*> stream, HandleValue e)
{
// Step 1: Assert: ! IsReadableStream(stream) is true (implicit).
@@ -1552,7 +1552,7 @@ ReadableStreamErrorInternal(JSContext* cx, Handle<ReadableStream*> stream, Handl
// Streams spec, 3.4.6. ReadableStreamFulfillReadIntoRequest( stream, chunk, done )
// Streams spec, 3.4.7. ReadableStreamFulfillReadRequest ( stream, chunk, done )
// These two spec functions are identical in our implementation.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamFulfillReadOrReadIntoRequest(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue chunk, bool done)
{
@@ -1596,7 +1596,7 @@ ReadableStreamGetNumReadRequests(ReadableStream* stream)
}
// Stream spec 3.4.10. ReadableStreamHasBYOBReader ( stream )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamHasBYOBReader(ReadableStream* stream)
{
// Step 1: Let reader be stream.[[reader]].
@@ -1608,7 +1608,7 @@ ReadableStreamHasBYOBReader(ReadableStream* stream)
}
// Streap spec 3.4.11. ReadableStreamHasDefaultReader ( stream )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamHasDefaultReader(ReadableStream* stream)
{
// Step 1: Let reader be stream.[[reader]].
@@ -1619,14 +1619,14 @@ ReadableStreamHasDefaultReader(ReadableStream* stream)
return reader.isObject() && reader.toObject().is<ReadableStreamDefaultReader>();
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamReaderGenericInitialize(JSContext* cx,
HandleNativeObject reader,
Handle<ReadableStream*> stream);
// Stream spec, 3.5.3. new ReadableStreamDefaultReader ( stream )
// Steps 2-4.
-static MOZ_MUST_USE ReadableStreamDefaultReader*
+[[nodiscard]] static ReadableStreamDefaultReader*
CreateReadableStreamDefaultReader(JSContext* cx, Handle<ReadableStream*> stream)
{
Rooted<ReadableStreamDefaultReader*> reader(cx);
@@ -1680,7 +1680,7 @@ ReadableStreamDefaultReader::constructor(JSContext* cx, unsigned argc, Value* vp
}
// Streams spec, 3.5.4.1 get closed
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultReader_closed(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -1696,11 +1696,11 @@ ReadableStreamDefaultReader_closed(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamReaderGenericCancel(JSContext* cx, HandleNativeObject reader, HandleValue reason);
// Streams spec, 3.5.4.2. cancel ( reason )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultReader_cancel(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -1728,7 +1728,7 @@ ReadableStreamDefaultReader_cancel(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.5.4.3 read ( )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultReader_read(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -1756,11 +1756,11 @@ ReadableStreamDefaultReader_read(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamReaderGenericRelease(JSContext* cx, HandleNativeObject reader);
// Streams spec, 3.5.4.4. releaseLock ( )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultReader_releaseLock_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStreamDefaultReader*> reader(cx);
@@ -1817,7 +1817,7 @@ CLASS_SPEC(ReadableStreamDefaultReader, 1, ReaderSlotCount, ClassSpec::DontDefin
// Streams spec, 3.6.3 new ReadableStreamBYOBReader ( stream )
// Steps 2-5.
-static MOZ_MUST_USE ReadableStreamBYOBReader*
+[[nodiscard]] static ReadableStreamBYOBReader*
CreateReadableStreamBYOBReader(JSContext* cx, Handle<ReadableStream*> stream)
{
// Step 2: If ! IsReadableByteStreamController(stream.[[readableStreamController]])
@@ -1877,7 +1877,7 @@ ReadableStreamBYOBReader::constructor(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.6.4.1 get closed
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamBYOBReader_closed(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -1894,7 +1894,7 @@ ReadableStreamBYOBReader_closed(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.6.4.2. cancel ( reason )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamBYOBReader_cancel(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -1922,7 +1922,7 @@ ReadableStreamBYOBReader_cancel(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.6.4.3 read ( )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamBYOBReader_read(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
@@ -1972,11 +1972,11 @@ ReadableStreamBYOBReader_read(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamReaderGenericRelease(JSContext* cx, HandleNativeObject reader);
// Streams spec, 3.6.4.4. releaseLock ( )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamBYOBReader_releaseLock_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStreamBYOBReader*> reader(cx);
@@ -2028,7 +2028,7 @@ static const JSFunctionSpec ReadableStreamBYOBReader_methods[] = {
CLASS_SPEC(ReadableStreamBYOBReader, 1, 3, ClassSpec::DontDefineConstructor, 0, JS_NULL_CLASS_OPS);
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
ReadableStreamControllerCallPullIfNeeded(JSContext* cx, HandleNativeObject controller);
// Streams spec, 3.7.1. IsReadableStreamDefaultReader ( x )
@@ -2038,7 +2038,7 @@ ReadableStreamControllerCallPullIfNeeded(JSContext* cx, HandleNativeObject contr
// Implemented via intrinsic_isInstanceOfBuiltin<ReadableStreamBYOBReader>()
// Streams spec, 3.7.3. ReadableStreamReaderGenericCancel ( reader, reason )
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamReaderGenericCancel(JSContext* cx, HandleNativeObject reader, HandleValue reason)
{
// Step 1: Let stream be reader.[[ownerReadableStream]].
@@ -2051,7 +2051,7 @@ ReadableStreamReaderGenericCancel(JSContext* cx, HandleNativeObject reader, Hand
}
// Streams spec, 3.7.4. ReadableStreamReaderGenericInitialize ( reader, stream )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamReaderGenericInitialize(JSContext* cx, HandleNativeObject reader,
Handle<ReadableStream*> stream)
{
@@ -2091,7 +2091,7 @@ ReadableStreamReaderGenericInitialize(JSContext* cx, HandleNativeObject reader,
}
// Streams spec, 3.7.5. ReadableStreamReaderGenericRelease ( reader )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamReaderGenericRelease(JSContext* cx, HandleNativeObject reader)
{
// Step 1: Assert: reader.[[ownerReadableStream]] is not undefined.
@@ -2133,13 +2133,13 @@ ReadableStreamReaderGenericRelease(JSContext* cx, HandleNativeObject reader)
return true;
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableByteStreamControllerPullInto(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
Handle<ArrayBufferViewObject*> view);
// Streams spec, 3.7.6. ReadableStreamBYOBReaderRead ( reader, view )
-/* static */ MOZ_MUST_USE JSObject*
+/* static */ [[nodiscard]] JSObject*
ReadableStreamBYOBReader::read(JSContext* cx, Handle<ReadableStreamBYOBReader*> reader,
Handle<ArrayBufferViewObject*> view)
{
@@ -2165,11 +2165,11 @@ ReadableStreamBYOBReader::read(JSContext* cx, Handle<ReadableStreamBYOBReader*>
return ReadableByteStreamControllerPullInto(cx, controller, view);
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamControllerPullSteps(JSContext* cx, HandleNativeObject controller);
// Streams spec, 3.7.7. ReadableStreamDefaultReaderRead ( reader )
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
ReadableStreamDefaultReader::read(JSContext* cx, Handle<ReadableStreamDefaultReader*> reader)
{
// Step 1: Let stream be reader.[[ownerReadableStream]].
@@ -2230,12 +2230,12 @@ ControllerStartHandler(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerErrorIfNeeded(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller,
HandleValue e);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamControllerError(JSContext* cx, HandleNativeObject controller, HandleValue e);
// Streams spec, 3.8.3, step 11.b.
@@ -2264,12 +2264,12 @@ ControllerStartFailedHandler(JSContext* cx, unsigned argc, Value* vp)
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ValidateAndNormalizeHighWaterMark(JSContext* cx,
HandleValue highWaterMarkVal,
double* highWaterMark);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ValidateAndNormalizeQueuingStrategy(JSContext* cx,
HandleValue size,
HandleValue highWaterMarkVal,
@@ -2278,7 +2278,7 @@ ValidateAndNormalizeQueuingStrategy(JSContext* cx,
// Streams spec, 3.8.3 new ReadableStreamDefaultController ( stream, underlyingSource,
// size, highWaterMark )
// Steps 3 - 11.
-static MOZ_MUST_USE ReadableStreamDefaultController*
+[[nodiscard]] static ReadableStreamDefaultController*
CreateReadableStreamDefaultController(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue underlyingSource, HandleValue size,
HandleValue highWaterMarkVal)
@@ -2380,13 +2380,13 @@ ReadableStreamDefaultController::constructor(JSContext* cx, unsigned argc, Value
return true;
}
-static MOZ_MUST_USE double
+[[nodiscard]] static double
ReadableStreamControllerGetDesiredSizeUnchecked(NativeObject* controller);
// Streams spec, 3.8.4.1. get desiredSize
// and
// Streams spec, 3.10.4.2. get desiredSize
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamController_desiredSize_impl(JSContext* cx, const CallArgs& args)
{
RootedNativeObject controller(cx);
@@ -2424,12 +2424,12 @@ ReadableStreamDefaultController_desiredSize(JSContext* cx, unsigned argc, Value*
ReadableStreamController_desiredSize_impl>(cx, args);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerClose(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller);
// Unified implementation of steps 2-3 of 3.8.4.2 and 3.10.4.3.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
VerifyControllerStateForClosing(JSContext* cx, HandleNativeObject controller)
{
// Step 2: If this.[[closeRequested]] is true, throw a TypeError exception.
@@ -2452,7 +2452,7 @@ VerifyControllerStateForClosing(JSContext* cx, HandleNativeObject controller)
}
// Streams spec, 3.8.4.2 close()
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultController_close_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStreamDefaultController*> controller(cx);
@@ -2480,13 +2480,13 @@ ReadableStreamDefaultController_close(JSContext* cx, unsigned argc, Value* vp)
ReadableStreamDefaultController_close_impl>(cx, args);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerEnqueue(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller,
HandleValue chunk);
// Streams spec, 3.8.4.3. enqueue ( chunk )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultController_enqueue_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStreamDefaultController*> controller(cx);
@@ -2527,7 +2527,7 @@ ReadableStreamDefaultController_enqueue(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.8.4.4. error ( e )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultController_error_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStreamDefaultController*> controller(cx);
@@ -2581,7 +2581,7 @@ CLASS_SPEC(ReadableStreamDefaultController, 4, 7, ClassSpec::DontDefineConstruct
* and
* Streams spec, 3.10.5.1. [[CancelSteps]] ( reason )
*/
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamControllerCancelSteps(JSContext* cx, HandleNativeObject controller,
HandleValue reason)
{
@@ -2631,7 +2631,7 @@ ReadableStreamControllerCancelSteps(JSContext* cx, HandleNativeObject controller
return PromiseInvokeOrNoop(cx, underlyingSource, cx->names().cancel, reason);
}
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
DequeueValue(JSContext* cx, HandleNativeObject container, MutableHandleValue chunk);
// Streams spec, 3.8.5.2. ReadableStreamDefaultController [[PullSteps]]()
@@ -2737,13 +2737,13 @@ ControllerPullFailedHandler(JSContext* cx, unsigned argc, Value* vp)
static bool
ReadableStreamControllerShouldCallPull(NativeObject* controller);
-static MOZ_MUST_USE double
+[[nodiscard]] static double
ReadableStreamControllerGetDesiredSizeUnchecked(NativeObject* controller);
// Streams spec, 3.9.2 ReadableStreamDefaultControllerCallPullIfNeeded ( controller )
// and
// Streams spec, 3.12.3. ReadableByteStreamControllerCallPullIfNeeded ( controller )
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
ReadableStreamControllerCallPullIfNeeded(JSContext* cx, HandleNativeObject controller)
{
// Step 1: Let shouldPull be
@@ -2847,7 +2847,7 @@ ReadableStreamControllerShouldCallPull(NativeObject* controller)
}
// Streams spec, 3.9.4. ReadableStreamDefaultControllerClose ( controller )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerClose(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller)
{
@@ -2872,12 +2872,12 @@ ReadableStreamDefaultControllerClose(JSContext* cx,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
EnqueueValueWithSize(JSContext* cx, HandleNativeObject container, HandleValue value,
HandleValue sizeVal);
// Streams spec, 3.9.5. ReadableStreamDefaultControllerEnqueue ( controller, chunk )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerEnqueue(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller,
HandleValue chunk)
@@ -2943,13 +2943,13 @@ ReadableStreamDefaultControllerEnqueue(JSContext* cx,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerClearPendingPullIntos(JSContext* cx, HandleNativeObject controller);
// Streams spec, 3.9.6. ReadableStreamDefaultControllerError ( controller, e )
// and
// Streams spec, 3.12.10. ReadableByteStreamControllerError ( controller, e )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamControllerError(JSContext* cx, HandleNativeObject controller, HandleValue e)
{
MOZ_ASSERT(IsReadableStreamController(controller));
@@ -2978,7 +2978,7 @@ ReadableStreamControllerError(JSContext* cx, HandleNativeObject controller, Hand
}
// Streams spec, 3.9.7. ReadableStreamDefaultControllerErrorIfNeeded ( controller, e ) nothrow
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamDefaultControllerErrorIfNeeded(JSContext* cx,
Handle<ReadableStreamDefaultController*> controller,
HandleValue e)
@@ -2994,7 +2994,7 @@ ReadableStreamDefaultControllerErrorIfNeeded(JSContext* cx,
// Streams spec, 3.9.8. ReadableStreamDefaultControllerGetDesiredSize ( controller )
// and
// Streams spec 3.12.13. ReadableByteStreamControllerGetDesiredSize ( controller )
-static MOZ_MUST_USE double
+[[nodiscard]] static double
ReadableStreamControllerGetDesiredSizeUnchecked(NativeObject* controller)
{
// Steps 1-4 done at callsites, so only assert that they have been done.
@@ -3012,7 +3012,7 @@ ReadableStreamControllerGetDesiredSizeUnchecked(NativeObject* controller)
// Streams spec, 3.10.3 new ReadableByteStreamController ( stream, underlyingSource,
// highWaterMark )
// Steps 3 - 16.
-static MOZ_MUST_USE ReadableByteStreamController*
+[[nodiscard]] static ReadableByteStreamController*
CreateReadableByteStreamController(JSContext* cx, Handle<ReadableStream*> stream,
HandleValue underlyingByteSource,
HandleValue highWaterMarkVal)
@@ -3150,7 +3150,7 @@ ReadableByteStreamController::constructor(JSContext* cx, unsigned argc, Value* v
// Version of the ReadableByteStreamConstructor that's specialized for
// handling external, embedding-provided, underlying sources.
-static MOZ_MUST_USE ReadableByteStreamController*
+[[nodiscard]] static ReadableByteStreamController*
CreateReadableByteStreamController(JSContext* cx, Handle<ReadableStream*> stream,
void* underlyingSource)
{
@@ -3213,12 +3213,12 @@ CreateReadableByteStreamController(JSContext* cx, Handle<ReadableStream*> stream
return controller;
}
-static MOZ_MUST_USE ReadableStreamBYOBRequest*
+[[nodiscard]] static ReadableStreamBYOBRequest*
CreateReadableStreamBYOBRequest(JSContext* cx, Handle<ReadableByteStreamController*> controller,
HandleObject view);
// Streams spec, 3.10.4.1. get byobRequest
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamController_byobRequest_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableByteStreamController*> controller(cx);
@@ -3285,11 +3285,11 @@ ReadableByteStreamController_desiredSize(JSContext* cx, unsigned argc, Value* vp
ReadableStreamController_desiredSize_impl>(cx, args);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerClose(JSContext* cx, Handle<ReadableByteStreamController*> controller);
// Streams spec, 3.10.4.3. close()
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamController_close_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableByteStreamController*> controller(cx);
@@ -3316,13 +3316,13 @@ ReadableByteStreamController_close(JSContext* cx, unsigned argc, Value* vp)
ReadableByteStreamController_close_impl>(cx, args);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerEnqueue(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleObject chunk);
// Streams spec, 3.10.4.4. enqueue ( chunk )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamController_enqueue_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableByteStreamController*> controller(cx);
@@ -3373,7 +3373,7 @@ ReadableByteStreamController_enqueue(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.10.4.5. error ( e )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamController_error_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableByteStreamController*> controller(cx);
@@ -3457,7 +3457,7 @@ CLASS_SPEC(ReadableByteStreamController, 3, 9, ClassSpec::DontDefineConstructor,
// Streams spec, 3.10.5.1. [[PullSteps]] ()
// Unified with 3.8.5.1 above.
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerHandleQueueDrain(JSContext* cx, HandleNativeObject controller);
// Streams spec, 3.10.5.2. [[PullSteps]] ()
@@ -3601,7 +3601,7 @@ ReadableByteStreamControllerPullSteps(JSContext* cx, HandleNativeObject controll
* and
* Streams spec, 3.10.5.2. [[PullSteps]] ()
*/
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableStreamControllerPullSteps(JSContext* cx, HandleNativeObject controller)
{
MOZ_ASSERT(IsReadableStreamController(controller));
@@ -3613,7 +3613,7 @@ ReadableStreamControllerPullSteps(JSContext* cx, HandleNativeObject controller)
}
-static MOZ_MUST_USE ReadableStreamBYOBRequest*
+[[nodiscard]] static ReadableStreamBYOBRequest*
CreateReadableStreamBYOBRequest(JSContext* cx, Handle<ReadableByteStreamController*> controller,
HandleObject view)
{
@@ -3673,7 +3673,7 @@ ReadableStreamBYOBRequest::constructor(JSContext* cx, unsigned argc, Value* vp)
}
// Streams spec, 3.11.4.1 get view
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamBYOBRequest_view_impl(JSContext* cx, const CallArgs& args)
{
// Step 2: Return this.[[view]].
@@ -3692,13 +3692,13 @@ ReadableStreamBYOBRequest_view(JSContext* cx, unsigned argc, Value* vp)
ReadableStreamBYOBRequest_view_impl>(cx, args);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespond(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleValue bytesWrittenVal);
// Streams spec, 3.11.4.2. respond ( bytesWritten )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamBYOBRequest_respond_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStreamBYOBRequest*> request(cx);
@@ -3737,13 +3737,13 @@ ReadableStreamBYOBRequest_respond(JSContext* cx, unsigned argc, Value* vp)
ReadableStreamBYOBRequest_respond_impl>(cx, args);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespondWithNewView(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleObject view);
// Streams spec, 3.11.4.3. respondWithNewView ( view )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableStreamBYOBRequest_respondWithNewView_impl(JSContext* cx, const CallArgs& args)
{
Rooted<ReadableStreamBYOBRequest*> request(cx);
@@ -3820,7 +3820,7 @@ static void
ReadableByteStreamControllerInvalidateBYOBRequest(NativeObject* controller);
// Streams spec, 3.12.4. ReadableByteStreamControllerClearPendingPullIntos ( controller )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerClearPendingPullIntos(JSContext* cx, HandleNativeObject controller)
{
MOZ_ASSERT(controller->is<ReadableByteStreamController>());
@@ -3833,7 +3833,7 @@ ReadableByteStreamControllerClearPendingPullIntos(JSContext* cx, HandleNativeObj
}
// Streams spec, 3.12.5. ReadableByteStreamControllerClose ( controller )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerClose(JSContext* cx, Handle<ReadableByteStreamController*> controller)
{
// Step 1: Let stream be controller.[[controlledReadableStream]].
@@ -3886,12 +3886,12 @@ ReadableByteStreamControllerClose(JSContext* cx, Handle<ReadableByteStreamContro
return ReadableStreamCloseInternal(cx, stream);
}
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableByteStreamControllerConvertPullIntoDescriptor(JSContext* cx,
Handle<PullIntoDescriptor*> pullIntoDescriptor);
// Streams spec, 3.12.6. ReadableByteStreamControllerCommitPullIntoDescriptor ( stream, pullIntoDescriptor )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerCommitPullIntoDescriptor(JSContext* cx, Handle<ReadableStream*> stream,
Handle<PullIntoDescriptor*> pullIntoDescriptor)
{
@@ -3938,7 +3938,7 @@ ReadableByteStreamControllerCommitPullIntoDescriptor(JSContext* cx, Handle<Reada
}
// Streams spec, 3.12.7. ReadableByteStreamControllerConvertPullIntoDescriptor ( pullIntoDescriptor )
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableByteStreamControllerConvertPullIntoDescriptor(JSContext* cx,
Handle<PullIntoDescriptor*> pullIntoDescriptor)
{
@@ -3972,21 +3972,21 @@ ReadableByteStreamControllerConvertPullIntoDescriptor(JSContext* cx,
return JS_New(cx, ctor, args);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerEnqueueChunkToQueue(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleObject buffer, uint32_t byteOffset,
uint32_t byteLength);
-static MOZ_MUST_USE ArrayBufferObject*
+[[nodiscard]] static ArrayBufferObject*
TransferArrayBuffer(JSContext* cx, HandleObject buffer);
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(JSContext* cx,
Handle<ReadableByteStreamController*> controller);
// Streams spec, 3.12.8. ReadableByteStreamControllerEnqueue ( controller, chunk )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerEnqueue(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleObject chunk)
@@ -4110,7 +4110,7 @@ ReadableByteStreamControllerEnqueue(JSContext* cx,
// Streams spec, 3.12.9.
// ReadableByteStreamControllerEnqueueChunkToQueue ( controller, buffer,
// byteOffset, byteLength )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerEnqueueChunkToQueue(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleObject buffer, uint32_t byteOffset,
@@ -4167,7 +4167,7 @@ ReadableByteStreamControllerFillHeadPullIntoDescriptor(ReadableByteStreamControl
}
// Streams spec, 3.12.12. ReadableByteStreamControllerFillPullIntoDescriptorFromQueue ( controller, pullIntoDescriptor )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
Handle<PullIntoDescriptor*> pullIntoDescriptor,
@@ -4336,7 +4336,7 @@ ReadableByteStreamControllerFillPullIntoDescriptorFromQueue(JSContext* cx,
// Unified with 3.9.8 above.
// Streams spec, 3.12.14. ReadableByteStreamControllerHandleQueueDrain ( controller )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerHandleQueueDrain(JSContext* cx, HandleNativeObject controller)
{
MOZ_ASSERT(controller->is<ReadableByteStreamController>());
@@ -4382,11 +4382,11 @@ ReadableByteStreamControllerInvalidateBYOBRequest(NativeObject* controller)
controller->setFixedSlot(ByteControllerSlot_BYOBRequest, UndefinedValue());
}
-static MOZ_MUST_USE PullIntoDescriptor*
+[[nodiscard]] static PullIntoDescriptor*
ReadableByteStreamControllerShiftPendingPullInto(JSContext* cx, HandleNativeObject controller);
// Streams spec 3.12.16. ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue ( controller )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(JSContext* cx,
Handle<ReadableByteStreamController*> controller)
{
@@ -4438,7 +4438,7 @@ ReadableByteStreamControllerProcessPullIntoDescriptorsUsingQueue(JSContext* cx,
}
// Streams spec, 3.12.17. ReadableByteStreamControllerPullInto ( controller, view )
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
ReadableByteStreamControllerPullInto(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
Handle<ArrayBufferViewObject*> view)
@@ -4614,13 +4614,13 @@ ReadableByteStreamControllerPullInto(JSContext* cx,
return promise;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespondInternal(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
double bytesWritten);
// Streams spec 3.12.18. ReadableByteStreamControllerRespond( controller, bytesWritten )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespond(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleValue bytesWrittenVal)
@@ -4651,7 +4651,7 @@ ReadableByteStreamControllerRespond(JSContext* cx,
}
// Streams spec 3.12.19. ReadableByteStreamControllerRespondInClosedState( controller, firstDescriptor )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespondInClosedState(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
Handle<PullIntoDescriptor*> firstDescriptor)
@@ -4695,7 +4695,7 @@ ReadableByteStreamControllerRespondInClosedState(JSContext* cx,
// Streams spec 3.12.20.
// ReadableByteStreamControllerRespondInReadableState( controller, bytesWritten, pullIntoDescriptor )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespondInReadableState(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
uint32_t bytesWritten,
@@ -4782,7 +4782,7 @@ ReadableByteStreamControllerRespondInReadableState(JSContext* cx,
}
// Streams spec, 3.12.21. ReadableByteStreamControllerRespondInternal ( controller, bytesWritten )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespondInternal(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
double bytesWritten)
@@ -4822,7 +4822,7 @@ ReadableByteStreamControllerRespondInternal(JSContext* cx,
}
// Streams spec, 3.12.22. ReadableByteStreamControllerRespondWithNewView ( controller, view )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadableByteStreamControllerRespondWithNewView(JSContext* cx,
Handle<ReadableByteStreamController*> controller,
HandleObject view)
@@ -4868,7 +4868,7 @@ ReadableByteStreamControllerRespondWithNewView(JSContext* cx,
}
// Streams spec, 3.12.23. ReadableByteStreamControllerShiftPendingPullInto ( controller )
-static MOZ_MUST_USE PullIntoDescriptor*
+[[nodiscard]] static PullIntoDescriptor*
ReadableByteStreamControllerShiftPendingPullInto(JSContext* cx, HandleNativeObject controller)
{
MOZ_ASSERT(controller->is<ReadableByteStreamController>());
@@ -4989,7 +4989,7 @@ CLASS_SPEC(CountQueuingStrategy, 1, 0, 0, 0, JS_NULL_CLASS_OPS);
#undef CLASS_SPEC
// Streams spec, 6.3.1. DequeueValue ( container ) nothrow
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
DequeueValue(JSContext* cx, HandleNativeObject container, MutableHandleValue chunk)
{
// Step 1: Assert: container has [[queue]] and [[queueTotalSize]] internal
@@ -5025,7 +5025,7 @@ DequeueValue(JSContext* cx, HandleNativeObject container, MutableHandleValue chu
}
// Streams spec, 6.3.2. EnqueueValueWithSize ( container, value, size ) throws
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
EnqueueValueWithSize(JSContext* cx, HandleNativeObject container, HandleValue value,
HandleValue sizeVal)
{
@@ -5068,7 +5068,7 @@ EnqueueValueWithSize(JSContext* cx, HandleNativeObject container, HandleValue va
// Streams spec, 6.3.3. PeekQueueValue ( container ) nothrow
// Used by WritableStream.
-// static MOZ_MUST_USE Value
+// [[nodiscard]] static Value
// PeekQueueValue(NativeObject* container)
// {
// // Step 1: Assert: container has [[queue]] and [[queueTotalSize]] internal
@@ -5090,7 +5090,7 @@ EnqueueValueWithSize(JSContext* cx, HandleNativeObject container, HandleValue va
/**
* Streams spec, 6.3.4. ResetQueue ( container ) nothrow
*/
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
ResetQueue(JSContext* cx, HandleNativeObject container)
{
// Step 1: Assert: container has [[queue]] and [[queueTotalSize]] internal
@@ -5111,7 +5111,7 @@ ResetQueue(JSContext* cx, HandleNativeObject container)
/**
* Streams spec, 6.4.1. InvokeOrNoop ( O, P, args )
*/
-inline static MOZ_MUST_USE bool
+[[nodiscard]] inline static bool
InvokeOrNoop(JSContext* cx, HandleValue O, HandlePropertyName P, HandleValue arg,
MutableHandleValue rval)
{
@@ -5134,7 +5134,7 @@ InvokeOrNoop(JSContext* cx, HandleValue O, HandlePropertyName P, HandleValue arg
* Streams spec, 6.4.3. PromiseInvokeOrNoop ( O, P, args )
* Specialized to one arg, because that's what all stream related callers use.
*/
-static MOZ_MUST_USE JSObject*
+[[nodiscard]] static JSObject*
PromiseInvokeOrNoop(JSContext* cx, HandleValue O, HandlePropertyName P, HandleValue arg)
{
// Step 1: Assert: O is not undefined.
@@ -5157,7 +5157,7 @@ PromiseInvokeOrNoop(JSContext* cx, HandleValue O, HandlePropertyName P, HandleVa
/**
* Streams spec, 6.4.4 TransferArrayBuffer ( O )
*/
-static MOZ_MUST_USE ArrayBufferObject*
+[[nodiscard]] static ArrayBufferObject*
TransferArrayBuffer(JSContext* cx, HandleObject buffer)
{
// Step 1 (implicit).
@@ -5185,7 +5185,7 @@ TransferArrayBuffer(JSContext* cx, HandleObject buffer)
}
// Streams spec, 6.4.5. ValidateAndNormalizeHighWaterMark ( highWaterMark )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ValidateAndNormalizeHighWaterMark(JSContext* cx, HandleValue highWaterMarkVal, double* highWaterMark)
{
// Step 1: Set highWaterMark to ? ToNumber(highWaterMark).
@@ -5204,7 +5204,7 @@ ValidateAndNormalizeHighWaterMark(JSContext* cx, HandleValue highWaterMarkVal, d
}
// Streams spec, 6.4.6. ValidateAndNormalizeQueuingStrategy ( size, highWaterMark )
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ValidateAndNormalizeQueuingStrategy(JSContext* cx, HandleValue size,
HandleValue highWaterMarkVal, double* highWaterMark)
{
@@ -5224,7 +5224,7 @@ ValidateAndNormalizeQueuingStrategy(JSContext* cx, HandleValue size,
return true;
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::ReadableStreamReaderCancel(JSContext* cx, HandleObject readerObj, HandleValue reason)
{
MOZ_ASSERT(IsReadableStreamReader(readerObj));
@@ -5233,7 +5233,7 @@ js::ReadableStreamReaderCancel(JSContext* cx, HandleObject readerObj, HandleValu
return ReadableStreamReaderGenericCancel(cx, reader, reason);
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
js::ReadableStreamReaderReleaseLock(JSContext* cx, HandleObject readerObj)
{
MOZ_ASSERT(IsReadableStreamReader(readerObj));
@@ -5242,7 +5242,7 @@ js::ReadableStreamReaderReleaseLock(JSContext* cx, HandleObject readerObj)
return ReadableStreamReaderGenericRelease(cx, reader);
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStream::enqueue(JSContext* cx, Handle<ReadableStream*> stream, HandleValue chunk)
{
Rooted<ReadableStreamDefaultController*> controller(cx);
@@ -5254,7 +5254,7 @@ ReadableStream::enqueue(JSContext* cx, Handle<ReadableStream*> stream, HandleVal
return ReadableStreamDefaultControllerEnqueue(cx, controller, chunk);
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStream::enqueueBuffer(JSContext* cx, Handle<ReadableStream*> stream,
Handle<ArrayBufferObject*> chunk)
{
@@ -5334,7 +5334,7 @@ ReadableStream::embeddingFlags() const
//
// The remaining steps of those two functions perform checks and asserts that
// don't apply to streams with external underlying sources.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStream::updateDataAvailableFromSource(JSContext* cx, Handle<ReadableStream*> stream,
uint32_t availableData)
{
@@ -5429,7 +5429,7 @@ ReadableStream::updateDataAvailableFromSource(JSContext* cx, Handle<ReadableStre
return true;
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStream::close(JSContext* cx, Handle<ReadableStream*> stream)
{
RootedNativeObject controllerObj(cx, ControllerFromStream(stream));
@@ -5447,7 +5447,7 @@ ReadableStream::close(JSContext* cx, Handle<ReadableStream*> stream)
return ReadableByteStreamControllerClose(cx, controller);
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStream::error(JSContext* cx, Handle<ReadableStream*> stream, HandleValue reason)
{
// Step 3: If stream.[[state]] is not "readable", throw a TypeError exception.
@@ -5462,7 +5462,7 @@ ReadableStream::error(JSContext* cx, Handle<ReadableStream*> stream, HandleValue
return ReadableStreamControllerError(cx, controller, reason);
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ReadableStream::tee(JSContext* cx, Handle<ReadableStream*> stream, bool cloneForBranch2,
MutableHandle<ReadableStream*> branch1Stream,
MutableHandle<ReadableStream*> branch2Stream)
@@ -5470,7 +5470,7 @@ ReadableStream::tee(JSContext* cx, Handle<ReadableStream*> stream, bool cloneFor
return ReadableStreamTee(cx, stream, false, branch1Stream, branch2Stream);
}
-MOZ_MUST_USE NativeObject*
+[[nodiscard]] NativeObject*
ReadableStream::getReader(JSContext* cx, Handle<ReadableStream*> stream,
JS::ReadableStreamReaderMode mode)
{
diff --git a/js/src/builtin/Stream.h b/js/src/builtin/Stream.h
index 0726e78361..1bd62a8772 100644
--- a/js/src/builtin/Stream.h
+++ b/js/src/builtin/Stream.h
@@ -37,31 +37,31 @@ class ReadableStream : public NativeObject
JS::ReadableStreamMode mode() const;
- static MOZ_MUST_USE bool close(JSContext* cx, Handle<ReadableStream*> stream);
- static MOZ_MUST_USE JSObject* cancel(JSContext* cx, Handle<ReadableStream*> stream,
- HandleValue reason);
- static MOZ_MUST_USE bool error(JSContext* cx, Handle<ReadableStream*> stream,
- HandleValue error);
-
- static MOZ_MUST_USE NativeObject* getReader(JSContext* cx, Handle<ReadableStream*> stream,
- JS::ReadableStreamReaderMode mode);
-
- static MOZ_MUST_USE bool tee(JSContext* cx,
- Handle<ReadableStream*> stream, bool cloneForBranch2,
- MutableHandle<ReadableStream*> branch1Stream,
- MutableHandle<ReadableStream*> branch2Stream);
-
- static MOZ_MUST_USE bool enqueue(JSContext* cx, Handle<ReadableStream*> stream,
- HandleValue chunk);
- static MOZ_MUST_USE bool enqueueBuffer(JSContext* cx, Handle<ReadableStream*> stream,
- Handle<ArrayBufferObject*> chunk);
- static MOZ_MUST_USE bool getExternalSource(JSContext* cx, Handle<ReadableStream*> stream,
- void** source);
+ [[nodiscard]] static bool close(JSContext* cx, Handle<ReadableStream*> stream);
+ [[nodiscard]] static JSObject* cancel(JSContext* cx, Handle<ReadableStream*> stream,
+ HandleValue reason);
+ [[nodiscard]] static bool error(JSContext* cx, Handle<ReadableStream*> stream,
+ HandleValue error);
+
+ [[nodiscard]] static NativeObject* getReader(JSContext* cx, Handle<ReadableStream*> stream,
+ JS::ReadableStreamReaderMode mode);
+
+ [[nodiscard]] static bool tee(JSContext* cx,
+ Handle<ReadableStream*> stream, bool cloneForBranch2,
+ MutableHandle<ReadableStream*> branch1Stream,
+ MutableHandle<ReadableStream*> branch2Stream);
+
+ [[nodiscard]] static bool enqueue(JSContext* cx, Handle<ReadableStream*> stream,
+ HandleValue chunk);
+ [[nodiscard]] static bool enqueueBuffer(JSContext* cx, Handle<ReadableStream*> stream,
+ Handle<ArrayBufferObject*> chunk);
+ [[nodiscard]] static bool getExternalSource(JSContext* cx, Handle<ReadableStream*> stream,
+ void** source);
void releaseExternalSource();
uint8_t embeddingFlags() const;
- static MOZ_MUST_USE bool updateDataAvailableFromSource(JSContext* cx,
- Handle<ReadableStream*> stream,
- uint32_t availableData);
+ [[nodiscard]] static bool updateDataAvailableFromSource(JSContext* cx,
+ Handle<ReadableStream*> stream,
+ uint32_t availableData);
enum State {
Readable = 1 << 0,
@@ -71,7 +71,7 @@ class ReadableStream : public NativeObject
};
private:
- static MOZ_MUST_USE ReadableStream* createStream(JSContext* cx, HandleObject proto = nullptr);
+ [[nodiscard]] static ReadableStream* createStream(JSContext* cx, HandleObject proto = nullptr);
public:
static bool constructor(JSContext* cx, unsigned argc, Value* vp);
@@ -84,7 +84,7 @@ class ReadableStream : public NativeObject
class ReadableStreamDefaultReader : public NativeObject
{
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 const ClassSpec classSpec_;
@@ -96,8 +96,8 @@ class ReadableStreamDefaultReader : public NativeObject
class ReadableStreamBYOBReader : public NativeObject
{
public:
- static MOZ_MUST_USE JSObject* read(JSContext* cx, Handle<ReadableStreamBYOBReader*> reader,
- Handle<ArrayBufferViewObject*> view);
+ [[nodiscard]] static JSObject* read(JSContext* cx, Handle<ReadableStreamBYOBReader*> reader,
+ Handle<ArrayBufferViewObject*> view);
static bool constructor(JSContext* cx, unsigned argc, Value* vp);
static const ClassSpec classSpec_;
@@ -108,10 +108,10 @@ class ReadableStreamBYOBReader : public NativeObject
bool ReadableStreamReaderIsClosed(const JSObject* reader);
-MOZ_MUST_USE bool ReadableStreamReaderCancel(JSContext* cx, HandleObject reader,
+[[nodiscard]] bool ReadableStreamReaderCancel(JSContext* cx, HandleObject reader,
HandleValue reason);
-MOZ_MUST_USE bool ReadableStreamReaderReleaseLock(JSContext* cx, HandleObject reader);
+[[nodiscard]] bool ReadableStreamReaderReleaseLock(JSContext* cx, HandleObject reader);
class ReadableStreamDefaultController : public NativeObject
{
diff --git a/js/src/builtin/SymbolObject.h b/js/src/builtin/SymbolObject.h
index 54d187fb59..96d8010bdd 100644
--- a/js/src/builtin/SymbolObject.h
+++ b/js/src/builtin/SymbolObject.h
@@ -38,22 +38,22 @@ class SymbolObject : public NativeObject
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 MOZ_MUST_USE bool for_(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool keyFor(JSContext* cx, unsigned argc, Value* vp);
+ static [[nodiscard]] bool for_(JSContext* cx, unsigned argc, Value* vp);
+ static [[nodiscard]] bool keyFor(JSContext* cx, unsigned argc, Value* vp);
// Methods defined on Symbol.prototype.
- static MOZ_MUST_USE bool toString_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool toString(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool valueOf_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool valueOf(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool toPrimitive(JSContext* cx, unsigned argc, Value* vp);
+ static [[nodiscard]] bool toString_impl(JSContext* cx, const CallArgs& args);
+ static [[nodiscard]] bool toString(JSContext* cx, unsigned argc, Value* vp);
+ static [[nodiscard]] bool valueOf_impl(JSContext* cx, const CallArgs& args);
+ static [[nodiscard]] bool valueOf(JSContext* cx, unsigned argc, Value* vp);
+ static [[nodiscard]] bool toPrimitive(JSContext* cx, unsigned argc, Value* vp);
// Properties defined on Symbol.prototype.
- static MOZ_MUST_USE bool descriptionGetter_impl(JSContext* cx, const CallArgs& args);
- static MOZ_MUST_USE bool descriptionGetter(JSContext* cx, unsigned argc, Value *vp);
+ static [[nodiscard]] bool descriptionGetter_impl(JSContext* cx, const CallArgs& args);
+ static [[nodiscard]] bool descriptionGetter(JSContext* cx, unsigned argc, Value *vp);
static const JSPropertySpec properties[];
static const JSFunctionSpec methods[];
diff --git a/js/src/builtin/TestingFunctions.h b/js/src/builtin/TestingFunctions.h
index 79a697482e..459257054a 100644
--- a/js/src/builtin/TestingFunctions.h
+++ b/js/src/builtin/TestingFunctions.h
@@ -10,13 +10,13 @@
namespace js {
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DefineTestingFunctions(JSContext* cx, HandleObject obj, bool fuzzingSafe, bool disableOOMFunctions);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
testingFunc_assertFloat32(JSContext* cx, unsigned argc, Value* vp);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
testingFunc_assertRecoveredOnBailout(JSContext* cx, unsigned argc, Value* vp);
} /* namespace js */
diff --git a/js/src/builtin/TypedObject.h b/js/src/builtin/TypedObject.h
index cceff0c638..f41a74514a 100644
--- a/js/src/builtin/TypedObject.h
+++ b/js/src/builtin/TypedObject.h
@@ -176,7 +176,7 @@ class TypeDescr : public NativeObject
}
// 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
// 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
// terminated by -1. The arrays store offsets of string, object, and value
// 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();
}
const int32_t* traceList() const {
@@ -257,7 +257,7 @@ class ScalarTypeDescr : public SimpleTypeDescr
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
@@ -310,7 +310,7 @@ class ReferenceTypeDescr : public SimpleTypeDescr
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_) \
@@ -333,7 +333,7 @@ class ComplexTypeDescr : public TypeDescr
bool IsTypedObjectClass(const Class* clasp); // Defined below
bool IsTypedObjectArray(JSObject& obj);
-MOZ_MUST_USE bool CreateUserSizeAndAlignmentProperties(JSContext* cx, HandleTypeDescr obj);
+[[nodiscard]] bool CreateUserSizeAndAlignmentProperties(JSContext* cx, HandleTypeDescr obj);
class ArrayTypeDescr;
@@ -371,7 +371,7 @@ class ArrayMetaTypeDescr : public NativeObject
// This is the function that gets called when the user
// 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
// 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
@@ -435,7 +435,7 @@ class StructTypeDescr : public ComplexTypeDescr
// Set `*out` to the index of the field named `id` and returns true,
// 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`.
JSAtom& fieldName(size_t index) const;
@@ -475,45 +475,45 @@ class TypedObject : public ShapedObject
{
static const bool IsTypedObjectClass = true;
- static MOZ_MUST_USE bool obj_getArrayElement(JSContext* cx,
- Handle<TypedObject*> typedObj,
- Handle<TypeDescr*> typeDescr,
- uint32_t index,
- MutableHandleValue vp);
+ [[nodiscard]] static bool obj_getArrayElement(JSContext* cx,
+ Handle<TypedObject*> typedObj,
+ Handle<TypeDescr*> typeDescr,
+ uint32_t index,
+ MutableHandleValue vp);
protected:
static const ObjectOps objectOps_;
- static MOZ_MUST_USE bool obj_lookupProperty(JSContext* cx, HandleObject obj,
- HandleId id, MutableHandleObject objp,
- MutableHandle<PropertyResult> propp);
+ [[nodiscard]] static bool obj_lookupProperty(JSContext* cx, HandleObject obj,
+ HandleId id, MutableHandleObject objp,
+ MutableHandle<PropertyResult> propp);
- static MOZ_MUST_USE bool obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id,
- Handle<PropertyDescriptor> desc,
- ObjectOpResult& result);
+ [[nodiscard]] static bool obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id,
+ Handle<PropertyDescriptor> desc,
+ ObjectOpResult& result);
- static MOZ_MUST_USE bool obj_hasProperty(JSContext* cx, HandleObject obj, HandleId id,
- bool* foundp);
+ [[nodiscard]] static bool obj_hasProperty(JSContext* cx, HandleObject obj, HandleId id,
+ bool* foundp);
- static MOZ_MUST_USE bool obj_getProperty(JSContext* cx, HandleObject obj, HandleValue receiver,
- HandleId id, MutableHandleValue vp);
+ [[nodiscard]] static bool obj_getProperty(JSContext* cx, HandleObject obj, HandleValue receiver,
+ HandleId id, MutableHandleValue vp);
- static MOZ_MUST_USE bool obj_getElement(JSContext* cx, HandleObject obj, HandleValue receiver,
- uint32_t index, MutableHandleValue vp);
+ [[nodiscard]] static bool obj_getElement(JSContext* cx, HandleObject obj, HandleValue receiver,
+ uint32_t index, MutableHandleValue vp);
- static MOZ_MUST_USE bool obj_setProperty(JSContext* cx, HandleObject obj, HandleId id,
- HandleValue v, HandleValue receiver,
- ObjectOpResult& result);
+ [[nodiscard]] static bool obj_setProperty(JSContext* cx, HandleObject obj, HandleId id,
+ HandleValue v, HandleValue receiver,
+ ObjectOpResult& result);
- static MOZ_MUST_USE bool obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj,
- HandleId id,
- MutableHandle<PropertyDescriptor> desc);
+ [[nodiscard]] static bool obj_getOwnPropertyDescriptor(JSContext* cx, HandleObject obj,
+ HandleId id,
+ MutableHandle<PropertyDescriptor> desc);
- static MOZ_MUST_USE bool obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId id,
- ObjectOpResult& result);
+ [[nodiscard]] static bool obj_deleteProperty(JSContext* cx, HandleObject obj, HandleId id,
+ ObjectOpResult& result);
- static MOZ_MUST_USE bool obj_enumerate(JSContext* cx, HandleObject obj,
- AutoIdVector& properties, bool enumerableOnly);
+ [[nodiscard]] static bool obj_enumerate(JSContext* cx, HandleObject obj,
+ AutoIdVector& properties, bool enumerableOnly);
uint8_t* typedMem() const;
@@ -548,7 +548,7 @@ class TypedObject : public ShapedObject
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
// 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
// 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. */
- static MOZ_MUST_USE bool GetBuffer(JSContext* cx, unsigned argc, Value* vp);
- static MOZ_MUST_USE bool GetByteOffset(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool GetBuffer(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] static bool GetByteOffset(JSContext* cx, unsigned argc, Value* vp);
Shape** addressOfShapeFromGC() { return shape_.unsafeUnbarrieredForTracing(); }
};
@@ -733,14 +733,14 @@ class InlineOpaqueTypedObject : public InlineTypedObject
*
* 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)
*
* 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)
@@ -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
* 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)
@@ -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`.
* `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)
*
* 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)
*
* 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)
*
* 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)
*
* 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. */
-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)
@@ -798,21 +798,21 @@ MOZ_MUST_USE bool TypeDescrIsArrayType(JSContext*, unsigned argc, Value* vp);
* Given a TypedObject `obj`, returns true if `obj` is
* "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)
*
* 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)
*
* 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()
@@ -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
* 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)
@@ -844,7 +844,7 @@ MOZ_MUST_USE bool GetTypedObjectModule(JSContext* cx, unsigned argc, Value* vp);
#define JS_STORE_SCALAR_CLASS_DEFN(_constant, T, _name) \
class StoreScalar##T { \
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; \
};
@@ -864,11 +864,11 @@ class StoreScalar##T { \
#define JS_STORE_REFERENCE_CLASS_DEFN(_constant, T, _name) \
class StoreReference##_name { \
private: \
- static MOZ_MUST_USE bool store(JSContext* cx, T* heap, const Value& v, \
- TypedObject* obj, jsid id); \
+ [[nodiscard]] static bool store(JSContext* cx, T* heap, const Value& v, \
+ TypedObject* obj, jsid id); \
\
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; \
};
@@ -883,7 +883,7 @@ class StoreReference##_name { \
#define JS_LOAD_SCALAR_CLASS_DEFN(_constant, T, _name) \
class LoadScalar##T { \
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; \
};
@@ -901,7 +901,7 @@ class LoadReference##_name { \
static void load(T* heap, MutableHandleValue v); \
\
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; \
};
diff --git a/js/src/builtin/WeakSetObject.h b/js/src/builtin/WeakSetObject.h
index af45a99595..3eb1b42fbe 100644
--- a/js/src/builtin/WeakSetObject.h
+++ b/js/src/builtin/WeakSetObject.h
@@ -23,7 +23,7 @@ class WeakSetObject : public NativeObject
static const JSFunctionSpec methods[];
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);
};
diff --git a/js/src/builtin/intl/Collator.h b/js/src/builtin/intl/Collator.h
index 757740bd3d..330ec65a80 100644
--- a/js/src/builtin/intl/Collator.h
+++ b/js/src/builtin/intl/Collator.h
@@ -49,7 +49,7 @@ CreateCollatorPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
*
* Usage: collator = intl_Collator(locales, options)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_isUpperCaseFirst(JSContext* cx, unsigned argc, Value* vp);
diff --git a/js/src/builtin/intl/DateTimeFormat.h b/js/src/builtin/intl/DateTimeFormat.h
index 5a223e8716..e652baa6ed 100644
--- a/js/src/builtin/intl/DateTimeFormat.h
+++ b/js/src/builtin/intl/DateTimeFormat.h
@@ -51,7 +51,7 @@ CreateDateTimeFormatPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
*
* Usage: dateTimeFormat = intl_DateTimeFormat(locales, options)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_canonicalizeTimeZone(JSContext* cx, unsigned argc, Value* vp);
/**
@@ -102,7 +102,7 @@ intl_canonicalizeTimeZone(JSContext* cx, unsigned argc, Value* vp);
*
* Usage: icuDefaultTimeZone = intl_defaultTimeZone()
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_defaultTimeZone(JSContext* cx, unsigned argc, Value* vp);
/**
@@ -110,7 +110,7 @@ intl_defaultTimeZone(JSContext* cx, unsigned argc, Value* vp);
*
* Usage: defaultTimeZoneOffset = intl_defaultTimeZoneOffset()
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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,
* hour12, hourCycle)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_FormatDateTime(JSContext* cx, unsigned argc, Value* vp);
diff --git a/js/src/builtin/intl/IntlObject.h b/js/src/builtin/intl/IntlObject.h
index eb5b4c69f8..e8ef32cdcc 100644
--- a/js/src/builtin/intl/IntlObject.h
+++ b/js/src/builtin/intl/IntlObject.h
@@ -50,7 +50,7 @@ InitIntlClass(JSContext* cx, JS::Handle<JSObject*> obj);
*
* 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);
/**
@@ -92,7 +92,7 @@ intl_GetCalendarInfo(JSContext* cx, unsigned argc, JS::Value* vp);
* 'AM'
* ]
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_supportedLocaleOrFallback(JSContext* cx, unsigned argc, JS::Value* vp);
} // namespace js
diff --git a/js/src/builtin/intl/LanguageTag.h b/js/src/builtin/intl/LanguageTag.h
index 3c2ecb1553..1cab3681a1 100644
--- a/js/src/builtin/intl/LanguageTag.h
+++ b/js/src/builtin/intl/LanguageTag.h
@@ -220,9 +220,9 @@ class MOZ_STACK_CLASS LanguageTag final {
void performComplexLanguageMappings();
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(
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
* 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);
/**
* 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.
*/
-MOZ_MUST_USE bool ParseStandaloneScriptTag(JS::Handle<JSLinearString*> str,
+[[nodiscard]] bool ParseStandaloneScriptTag(JS::Handle<JSLinearString*> str,
ScriptSubtag& result);
/**
* 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.
*/
-MOZ_MUST_USE bool ParseStandaloneRegionTag(JS::Handle<JSLinearString*> str,
+[[nodiscard]] bool ParseStandaloneRegionTag(JS::Handle<JSLinearString*> str,
RegionSubtag& result);
/**
@@ -759,7 +759,7 @@ class UnicodeExtensionKeyword final {
void trace(JSTracer* trc);
};
-extern MOZ_MUST_USE bool ApplyUnicodeExtensionToTag(
+[[nodiscard]] extern bool ApplyUnicodeExtensionToTag(
JSContext* cx, LanguageTag& tag,
JS::HandleVector<UnicodeExtensionKeyword> keywords);
diff --git a/js/src/builtin/intl/Locale.h b/js/src/builtin/intl/Locale.h
index 881906616b..b57af31296 100644
--- a/js/src/builtin/intl/Locale.h
+++ b/js/src/builtin/intl/Locale.h
@@ -48,14 +48,14 @@ extern JSObject* CreateLocalePrototype(JSContext* cx,
JS::Handle<JSObject*> Intl,
JS::Handle<GlobalObject*> global);
-extern MOZ_MUST_USE bool intl_ValidateAndCanonicalizeLanguageTag(JSContext* cx,
- unsigned argc,
- Value* vp);
+[[nodiscard]] extern bool intl_ValidateAndCanonicalizeLanguageTag(JSContext* cx,
+ unsigned argc,
+ Value* vp);
-extern MOZ_MUST_USE bool intl_TryValidateAndCanonicalizeLanguageTag(
+[[nodiscard]] extern bool intl_TryValidateAndCanonicalizeLanguageTag(
JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool intl_ValidateAndCanonicalizeUnicodeExtensionType(
+[[nodiscard]] extern bool intl_ValidateAndCanonicalizeUnicodeExtensionType(
JSContext* cx, unsigned argc, Value* vp);
} // namespace js
diff --git a/js/src/builtin/intl/NumberFormat.h b/js/src/builtin/intl/NumberFormat.h
index bc2f659527..b7045c8e98 100644
--- a/js/src/builtin/intl/NumberFormat.h
+++ b/js/src/builtin/intl/NumberFormat.h
@@ -47,7 +47,7 @@ CreateNumberFormatPrototype(JSContext* cx, HandleObject Intl, Handle<GlobalObjec
*
* Usage: numberFormat = intl_NumberFormat(locales, options)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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);
} // namespace js
diff --git a/js/src/builtin/intl/PluralRules.h b/js/src/builtin/intl/PluralRules.h
index 6f8e09ac80..04427de06c 100644
--- a/js/src/builtin/intl/PluralRules.h
+++ b/js/src/builtin/intl/PluralRules.h
@@ -46,7 +46,7 @@ CreatePluralRulesPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
*
* Usage: pluralRules = intl_PluralRules(locales, options)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
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']
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_GetPluralCategories(JSContext* cx, unsigned argc, Value* vp);
} // namespace js
diff --git a/js/src/builtin/intl/RelativeTimeFormat.h b/js/src/builtin/intl/RelativeTimeFormat.h
index 85b6d645b4..f6b62eae96 100644
--- a/js/src/builtin/intl/RelativeTimeFormat.h
+++ b/js/src/builtin/intl/RelativeTimeFormat.h
@@ -48,8 +48,7 @@ CreateRelativeTimeFormatPrototype(JSContext* cx, JS::Handle<JSObject*> Intl,
*
* Usage: formatted = intl_FormatRelativeTime(relativeTimeFormat, t, unit)
*/
-extern MOZ_MUST_USE bool
-intl_FormatRelativeTime(JSContext* cx, unsigned argc, Value* vp);
+[[nodiscard]] extern bool intl_FormatRelativeTime(JSContext* cx, unsigned argc, Value* vp);
} // namespace js
diff --git a/js/src/builtin/intl/SharedIntlData.h b/js/src/builtin/intl/SharedIntlData.h
index edf90308df..bd5332dc9a 100644
--- a/js/src/builtin/intl/SharedIntlData.h
+++ b/js/src/builtin/intl/SharedIntlData.h
@@ -233,9 +233,9 @@ class SharedIntlData
* Sets |supported| to true if |locale| is supported by the requested Intl
* service constructor. Otherwise sets |supported| to false.
*/
- MOZ_MUST_USE bool isSupportedLocale(JSContext* cx, SupportedLocaleKind kind,
- JS::Handle<JSString*> locale,
- bool* supported);
+ [[nodiscard]] bool isSupportedLocale(JSContext* cx, SupportedLocaleKind kind,
+ JS::Handle<JSString*> locale,
+ bool* supported);
private:
/**
diff --git a/js/src/ctypes/CTypes.h b/js/src/ctypes/CTypes.h
index ae372d92be..7eb4c1020a 100644
--- a/js/src/ctypes/CTypes.h
+++ b/js/src/ctypes/CTypes.h
@@ -178,7 +178,7 @@ GetDeflatedUTF8StringLength(JSContext* maybecx, const CharT* chars,
size_t charsLength);
template <typename CharT>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DeflateStringToUTF8Buffer(JSContext* maybecx, const CharT* src, size_t srclen,
char* dst, size_t* dstlenp);
@@ -456,7 +456,7 @@ namespace CType {
TypeCode GetTypeCode(JSObject* typeObj);
bool TypesEqual(JSObject* t1, JSObject* t2);
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);
size_t GetAlignment(JSObject* obj);
ffi_type* GetFFIType(JSContext* cx, JSObject* obj);
@@ -480,12 +480,12 @@ namespace ArrayType {
JSObject* GetBaseType(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);
} // namespace ArrayType
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 FieldInfo* LookupField(JSContext* cx, JSObject* obj, JSFlatString* name);
@@ -521,9 +521,9 @@ namespace CData {
bool IsCDataProto(JSObject* obj);
// 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'
- MOZ_MUST_USE bool GetRuntime(JSContext* cx, unsigned argc, Value* vp);
+ [[nodiscard]] bool GetRuntime(JSContext* cx, unsigned argc, Value* vp);
} // namespace CData
namespace Int64 {
diff --git a/js/src/ctypes/Library.h b/js/src/ctypes/Library.h
index 83e2daba05..56f2df19a9 100644
--- a/js/src/ctypes/Library.h
+++ b/js/src/ctypes/Library.h
@@ -23,14 +23,14 @@ enum LibrarySlot {
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);
bool IsLibrary(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 ctypes
diff --git a/js/src/ds/Fifo.h b/js/src/ds/Fifo.h
index 4946c8452c..61426aa7b0 100644
--- a/js/src/ds/Fifo.h
+++ b/js/src/ds/Fifo.h
@@ -94,7 +94,7 @@ class Fifo
// Push an element to the back of the queue. This method can take either a
// |const T&| or a |T&&|.
template <typename U>
- MOZ_MUST_USE bool pushBack(U&& u) {
+ [[nodiscard]] bool pushBack(U&& u) {
if (!rear_.append(mozilla::Forward<U>(u)))
return false;
if (!fixup()) {
@@ -106,7 +106,7 @@ class Fifo
// Construct a T in-place at the back of the queue.
template <typename... Args>
- MOZ_MUST_USE bool emplaceBack(Args&&... args) {
+ [[nodiscard]] bool emplaceBack(Args&&... args) {
if (!rear_.emplaceBack(mozilla::Forward<Args>(args)...))
return false;
if (!fixup()) {
@@ -127,7 +127,7 @@ class Fifo
}
// Remove the front element from the queue.
- MOZ_MUST_USE bool popFront() {
+ [[nodiscard]] bool popFront() {
MOZ_ASSERT(!empty());
T t(mozilla::Move(front()));
front_.popBack();
diff --git a/js/src/ds/InlineTable.h b/js/src/ds/InlineTable.h
index 17d27ec282..5793e78533 100644
--- a/js/src/ds/InlineTable.h
+++ b/js/src/ds/InlineTable.h
@@ -67,7 +67,7 @@ class InlineTable
return inlNext_ > InlineEntries;
}
- MOZ_MUST_USE bool switchToTable() {
+ [[nodiscard]] bool switchToTable() {
MOZ_ASSERT(inlNext_ == InlineEntries);
if (table_.initialized()) {
@@ -91,7 +91,7 @@ class InlineTable
}
MOZ_NEVER_INLINE
- MOZ_MUST_USE bool switchAndAdd(const InlineEntry& entry) {
+ [[nodiscard]] bool switchAndAdd(const InlineEntry& entry) {
if (!switchToTable())
return false;
@@ -285,7 +285,7 @@ class InlineTable
template <typename KeyInput,
typename... Args>
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(keyNonZero(key));
@@ -439,7 +439,7 @@ class InlineMap
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));
}
};
@@ -531,12 +531,12 @@ class InlineMap
template <typename KeyInput, typename ValueInput>
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));
}
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);
if (p) {
p->value() = mozilla::Forward<ValueInput>(value);
@@ -577,7 +577,7 @@ class InlineSet
this->key = mozilla::Forward<TInput>(key);
}
- MOZ_MUST_USE bool moveTo(Set& set) {
+ [[nodiscard]] bool moveTo(Set& set) {
return set.putNew(mozilla::Move(key));
}
};
@@ -662,12 +662,12 @@ class InlineSet
template <typename TInput>
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));
}
template <typename TInput>
- MOZ_MUST_USE bool put(TInput&& key) {
+ [[nodiscard]] bool put(TInput&& key) {
AddPtr p = lookupForAdd(key);
return p ? true : add(p, mozilla::Forward<TInput>(key));
}
diff --git a/js/src/ds/LifoAlloc.h b/js/src/ds/LifoAlloc.h
index 7c617a02fc..1c64dd44d9 100644
--- a/js/src/ds/LifoAlloc.h
+++ b/js/src/ds/LifoAlloc.h
@@ -313,7 +313,7 @@ class LifoAlloc
// allocation requests, not necessarily contiguous. Note that this does
// not guarantee a successful single allocation of N bytes.
MOZ_ALWAYS_INLINE
- MOZ_MUST_USE bool ensureUnusedApproximate(size_t n) {
+ [[nodiscard]] bool ensureUnusedApproximate(size_t n) {
AutoFallibleScope fallibleAllocator(this);
size_t total = 0;
for (BumpChunk* chunk = latest; chunk; chunk = chunk->next()) {
@@ -640,7 +640,7 @@ class LifoAllocPolicy
}
void reportAllocOverflow() const {
}
- MOZ_MUST_USE bool checkSimulatedOOM() const {
+ [[nodiscard]] bool checkSimulatedOOM() const {
return fb == Infallible || !js::oom::ShouldFailWithOOM();
}
};
diff --git a/js/src/ds/OrderedHashTable.h b/js/src/ds/OrderedHashTable.h
index c12d43caa7..1432b308fb 100644
--- a/js/src/ds/OrderedHashTable.h
+++ b/js/src/ds/OrderedHashTable.h
@@ -86,7 +86,7 @@ class OrderedHashTable
OrderedHashTable(AllocPolicy& ap, mozilla::HashCodeScrambler 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");
uint32_t buckets = initialBuckets();
@@ -153,7 +153,7 @@ class OrderedHashTable
* means the element was not added to the table.
*/
template <typename ElementInput>
- MOZ_MUST_USE bool put(ElementInput&& element) {
+ [[nodiscard]] bool put(ElementInput&& element) {
HashNumber h = prepareHash(Ops::getKey(element));
if (Data* e = lookup(Ops::getKey(element), h)) {
e->element = Forward<ElementInput>(element);
@@ -224,7 +224,7 @@ class OrderedHashTable
* particular, those Ranges are still live and will see any entries added
* after a successful clear().
*/
- MOZ_MUST_USE bool clear() {
+ [[nodiscard]] bool clear() {
if (dataLength != 0) {
Data** oldHashTable = hashTable;
Data* oldData = data;
@@ -633,7 +633,7 @@ class OrderedHashTable
* empty elements in data[0:dataLength]. On allocation failure, this
* 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
// allocating memory.
if (newHashShift == hashShift) {
@@ -746,17 +746,17 @@ class OrderedHashMap
typedef typename Impl::Range Range;
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(); }
bool has(const Key& key) const { return impl.has(key); }
Range all() { return impl.all(); }
const Entry* get(const Key& key) const { 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); }
- MOZ_MUST_USE bool clear() { return impl.clear(); }
+ [[nodiscard]] bool clear() { return impl.clear(); }
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)));
}
@@ -804,13 +804,13 @@ class OrderedHashSet
typedef typename Impl::Range Range;
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(); }
bool has(const T& value) const { return impl.has(value); }
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); }
- MOZ_MUST_USE bool clear() { return impl.clear(); }
+ [[nodiscard]] bool clear() { return impl.clear(); }
HashNumber hash(const T& value) const { return impl.prepareHash(value); }
diff --git a/js/src/ds/PageProtectingVector.h b/js/src/ds/PageProtectingVector.h
index ddb6ee6eae..a21854d88c 100644
--- a/js/src/ds/PageProtectingVector.h
+++ b/js/src/ds/PageProtectingVector.h
@@ -223,7 +223,7 @@ class PageProtectingVector final
unprotectedBytes = 0;
}
- MOZ_MUST_USE bool reserve(size_t size) {
+ [[nodiscard]] bool reserve(size_t size) {
AutoUnprotect guard;
if (size > vector.capacity())
guard.emplace(this);
@@ -237,7 +237,7 @@ class PageProtectingVector final
}
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;
{
AutoUnprotect guard;
diff --git a/js/src/ds/PriorityQueue.h b/js/src/ds/PriorityQueue.h
index ce8d1af7e6..a7430620cf 100644
--- a/js/src/ds/PriorityQueue.h
+++ b/js/src/ds/PriorityQueue.h
@@ -34,7 +34,7 @@ class PriorityQueue
: heap(ap)
{}
- MOZ_MUST_USE bool reserve(size_t capacity) {
+ [[nodiscard]] bool reserve(size_t capacity) {
return heap.reserve(capacity);
}
@@ -56,7 +56,7 @@ class PriorityQueue
return highest;
}
- MOZ_MUST_USE bool insert(const T& v) {
+ [[nodiscard]] bool insert(const T& v) {
if (!heap.append(v))
return false;
siftUp(heap.length() - 1);
diff --git a/js/src/ds/Sort.h b/js/src/ds/Sort.h
index 0f98dc5f75..2dcab1c4e0 100644
--- a/js/src/ds/Sort.h
+++ b/js/src/ds/Sort.h
@@ -77,7 +77,7 @@ MergeArrayRuns(T* dst, const T* src, size_t run1, size_t run2, Comparator c)
* arbitrary.
*/
template<typename T, typename Comparator>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
MergeSort(T* array, size_t nelems, T* scratch, Comparator c)
{
const size_t INS_SORT_LIMIT = 3;
diff --git a/js/src/ds/SplayTree.h b/js/src/ds/SplayTree.h
index af2c48075a..7aa87637d1 100644
--- a/js/src/ds/SplayTree.h
+++ b/js/src/ds/SplayTree.h
@@ -89,7 +89,7 @@ class SplayTree
return false;
}
- MOZ_MUST_USE bool insert(const T& v)
+ [[nodiscard]] bool insert(const T& v)
{
Node* element = allocateNode(v);
if (!element)
diff --git a/js/src/frontend/BytecodeCompiler.h b/js/src/frontend/BytecodeCompiler.h
index 471e9e36d9..407ac2d119 100644
--- a/js/src/frontend/BytecodeCompiler.h
+++ b/js/src/frontend/BytecodeCompiler.h
@@ -49,7 +49,7 @@ CompileModule(ExclusiveContext* cx, const ReadOnlyCompileOptions& options,
SourceBufferHolder& srcBuf, LifoAlloc& alloc,
ScriptSourceObject** sourceObjectOut = nullptr);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
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){ if (3", "return x;}")
//
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CompileStandaloneFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd,
HandleScope enclosingScope = nullptr);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CompileStandaloneGenerator(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CompileStandaloneAsyncFunction(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CompileStandaloneAsyncGenerator(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
JS::SourceBufferHolder& srcBuf,
mozilla::Maybe<uint32_t> parameterListEnd);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CompileAsyncFunctionBody(JSContext* cx, MutableHandleFunction fun,
const ReadOnlyCompileOptions& options,
Handle<PropertyNameVector> formals, JS::SourceBufferHolder& srcBuf);
diff --git a/js/src/frontend/BytecodeControlStructures.h b/js/src/frontend/BytecodeControlStructures.h
index 0863f9ef5d..fe7032b0cd 100644
--- a/js/src/frontend/BytecodeControlStructures.h
+++ b/js/src/frontend/BytecodeControlStructures.h
@@ -64,7 +64,7 @@ class BreakableControl : public NestableControl
BreakableControl(BytecodeEmitter* bce, StatementKind kind);
- MOZ_MUST_USE bool patchBreaks(BytecodeEmitter* bce);
+ [[nodiscard]] bool patchBreaks(BytecodeEmitter* bce);
};
template <>
inline bool
@@ -131,7 +131,7 @@ class LoopControl : public BreakableControl
return canIonOsr_;
}
- MOZ_MUST_USE bool patchBreaksAndContinues(BytecodeEmitter* bce);
+ [[nodiscard]] bool patchBreaksAndContinues(BytecodeEmitter* bce);
};
template <>
inline bool
diff --git a/js/src/frontend/BytecodeEmitter.cpp b/js/src/frontend/BytecodeEmitter.cpp
index 7680411f07..89b768344a 100644
--- a/js/src/frontend/BytecodeEmitter.cpp
+++ b/js/src/frontend/BytecodeEmitter.cpp
@@ -144,13 +144,13 @@ class MOZ_RAII OptionalEmitter
Other
};
- MOZ_MUST_USE bool emitJumpShortCircuit();
- MOZ_MUST_USE bool emitJumpShortCircuitForCall();
+ [[nodiscard]] bool emitJumpShortCircuit();
+ [[nodiscard]] bool emitJumpShortCircuitForCall();
// 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
// (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,
@@ -708,7 +708,7 @@ class NonLocalExitControl
NonLocalExitControl(const NonLocalExitControl&) = delete;
- MOZ_MUST_USE bool leaveScope(EmitterScope* scope);
+ [[nodiscard]] bool leaveScope(EmitterScope* scope);
public:
NonLocalExitControl(BytecodeEmitter* bce, Kind kind)
@@ -725,9 +725,9 @@ class NonLocalExitControl
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);
}
};
diff --git a/js/src/frontend/BytecodeEmitter.h b/js/src/frontend/BytecodeEmitter.h
index 9ca4856cf5..0ce4f6c1a3 100644
--- a/js/src/frontend/BytecodeEmitter.h
+++ b/js/src/frontend/BytecodeEmitter.h
@@ -40,7 +40,7 @@ class CGConstList {
explicit CGConstList(ExclusiveContext* cx)
: vector(cx, ValueVector(cx))
{ }
- MOZ_MUST_USE bool append(const Value& v) {
+ [[nodiscard]] bool append(const Value& v) {
return vector.append(v);
}
size_t length() const { return vector.length(); }
@@ -75,7 +75,7 @@ struct CGTryNoteList {
Vector<JSTryNote> list;
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(); }
void finish(TryNoteArray* array);
};
@@ -97,7 +97,7 @@ struct CGScopeNoteList {
Vector<CGScopeNote> list;
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);
void recordEnd(uint32_t index, uint32_t offset, bool inPrologue);
size_t length() const { return list.length(); }
@@ -110,7 +110,7 @@ struct CGYieldAndAwaitOffsetList {
uint32_t numAwaits;
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(); }
void finish(YieldAndAwaitOffsetArray& array, uint32_t prologueLength);
};
@@ -264,7 +264,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
TokenPos bodyPosition, EmitterMode emitterMode = Normal,
FieldInitializers fieldInitializers = FieldInitializers::Invalid());
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
template <typename T>
T* findInnermostNestableControl() const;
@@ -300,7 +300,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
Scope* innermostScope() const;
MOZ_ALWAYS_INLINE
- MOZ_MUST_USE bool makeAtomIndex(JSAtom* atom, uint32_t* indexp) {
+ [[nodiscard]] bool makeAtomIndex(JSAtom* atom, uint32_t* indexp) {
MOZ_ASSERT(atomIndices);
AtomIndexMap::AddPtr p = atomIndices->lookupForAdd(atom);
if (p) {
@@ -317,16 +317,16 @@ struct MOZ_STACK_CLASS BytecodeEmitter
}
bool isInLoop();
- MOZ_MUST_USE bool checkSingletonContext();
+ [[nodiscard]] bool checkSingletonContext();
// Check whether our function is in a run-once context (a toplevel
// run-one script or a run-once lambda).
- MOZ_MUST_USE bool checkRunOnceContext();
+ [[nodiscard]] bool checkRunOnceContext();
bool needsImplicitThis();
- MOZ_MUST_USE bool maybeSetDisplayURL();
- MOZ_MUST_USE bool maybeSetSourceMap();
+ [[nodiscard]] bool maybeSetDisplayURL();
+ [[nodiscard]] bool maybeSetSourceMap();
void tellDebuggerAboutCompiledScript(ExclusiveContext* cx);
inline TokenStream& tokenStream();
@@ -383,29 +383,29 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// 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,
// 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
- MOZ_MUST_USE bool checkStrictOrSloppy(JSOp op);
+ [[nodiscard]] bool checkStrictOrSloppy(JSOp op);
#endif
// 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
// within the array pointed at by current->notes as outparam.
- MOZ_MUST_USE bool newSrcNote(SrcNoteType type, unsigned* indexp = nullptr);
- MOZ_MUST_USE 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 newSrcNote(SrcNoteType type, unsigned* indexp = nullptr);
+ [[nodiscard]] bool newSrcNote2(SrcNoteType type, ptrdiff_t offset, unsigned* indexp = nullptr);
+ [[nodiscard]] bool newSrcNote3(SrcNoteType type, ptrdiff_t offset1, ptrdiff_t offset2,
unsigned* indexp = nullptr);
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.
- 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
// 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.
enum EmitLineNumberNote {
@@ -414,242 +414,242 @@ struct MOZ_STACK_CLASS BytecodeEmitter
};
// 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);
// Emit code for the optional tree rooted at pn.
- MOZ_MUST_USE bool emitOptionalTree(ParseNode* pn,
+ [[nodiscard]] bool emitOptionalTree(ParseNode* pn,
OptionalEmitter& oe,
ValueUsage valueUsage = ValueUsage::WantValue);
// 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);
// Emit global, eval, or module code for tree rooted at body. Always
// 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.
- MOZ_MUST_USE bool emitFunctionScript(FunctionNode* funNode);
+ [[nodiscard]] bool emitFunctionScript(FunctionNode* funNode);
void updateDepth(ptrdiff_t target);
- MOZ_MUST_USE bool updateLineNumberNotes(uint32_t offset);
- MOZ_MUST_USE bool updateSourceCoordNotes(uint32_t offset);
+ [[nodiscard]] bool updateLineNumberNotes(uint32_t offset);
+ [[nodiscard]] bool updateSourceCoordNotes(uint32_t offset);
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.
- MOZ_MUST_USE bool emit1(JSOp op);
+ [[nodiscard]] bool emit1(JSOp op);
// Emit two bytecodes, an opcode (op) with a byte of immediate operand
// (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.
- 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
// 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.
- MOZ_MUST_USE bool emitPopN(unsigned n);
+ [[nodiscard]] bool emitPopN(unsigned n);
// 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.
- MOZ_MUST_USE bool emitCheckIsObj(CheckIsObjectKind kind);
+ [[nodiscard]] bool emitCheckIsObj(CheckIsObjectKind kind);
// 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
// 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.
- 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.
- 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);
- MOZ_MUST_USE bool emitGetFunctionThis(ParseNode* pn);
- MOZ_MUST_USE bool emitGetFunctionThis(const mozilla::Maybe<uint32_t>& offset);
- MOZ_MUST_USE bool emitGetThisForSuperBase(UnaryNode* superBase);
- MOZ_MUST_USE bool emitSetThis(BinaryNode* setThisNode);
- MOZ_MUST_USE bool emitCheckDerivedClassConstructorReturn();
+ [[nodiscard]] bool emitThisLiteral(ThisLiteral* pn);
+ [[nodiscard]] bool emitGetFunctionThis(ParseNode* pn);
+ [[nodiscard]] bool emitGetFunctionThis(const mozilla::Maybe<uint32_t>& offset);
+ [[nodiscard]] bool emitGetThisForSuperBase(UnaryNode* superBase);
+ [[nodiscard]] bool emitSetThis(BinaryNode* setThisNode);
+ [[nodiscard]] bool emitCheckDerivedClassConstructorReturn();
// Handle jump opcodes and jump targets.
- MOZ_MUST_USE bool emitJumpTarget(JumpTarget* target);
- MOZ_MUST_USE bool emitJumpNoFallthrough(JSOp op, JumpList* jump);
- MOZ_MUST_USE bool emitJump(JSOp op, JumpList* jump);
- MOZ_MUST_USE bool emitBackwardJump(JSOp op, JumpTarget target, JumpList* jump,
+ [[nodiscard]] bool emitJumpTarget(JumpTarget* target);
+ [[nodiscard]] bool emitJumpNoFallthrough(JSOp op, JumpList* jump);
+ [[nodiscard]] bool emitJump(JSOp op, JumpList* jump);
+ [[nodiscard]] bool emitBackwardJump(JSOp op, JumpTarget target, JumpList* jump,
JumpTarget* fallthrough);
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);
- MOZ_MUST_USE bool emitCall(JSOp op, uint16_t argc, ParseNode* pn = nullptr);
- MOZ_MUST_USE bool emitCallIncDec(UnaryNode* incDec);
+ [[nodiscard]] bool emitCall(JSOp op, uint16_t argc, ParseNode* pn = nullptr);
+ [[nodiscard]] bool emitCallIncDec(UnaryNode* incDec);
- MOZ_MUST_USE bool emitLoopHead(ParseNode* nextpn, JumpTarget* top);
- MOZ_MUST_USE bool emitLoopEntry(ParseNode* nextpn, JumpList entryJump);
+ [[nodiscard]] bool emitLoopHead(ParseNode* nextpn, JumpTarget* top);
+ [[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);
- MOZ_MUST_USE bool emitIndex32(JSOp op, uint32_t index);
- MOZ_MUST_USE bool emitIndexOp(JSOp op, uint32_t index);
+ [[nodiscard]] bool emitIndex32(JSOp op, uint32_t index);
+ [[nodiscard]] bool emitIndexOp(JSOp op, uint32_t index);
- MOZ_MUST_USE bool emitAtomOp(JSAtom* atom, JSOp op);
- MOZ_MUST_USE bool emitAtomOp(uint32_t atomIndex, JSOp op);
+ [[nodiscard]] bool emitAtomOp(JSAtom* atom, JSOp op);
+ [[nodiscard]] bool emitAtomOp(uint32_t atomIndex, JSOp op);
- MOZ_MUST_USE bool emitArrayLiteral(ListNode* array);
- MOZ_MUST_USE bool emitArray(ParseNode* arrayHead, uint32_t count, JSOp op);
- MOZ_MUST_USE bool emitArrayComp(ListNode* pn);
+ [[nodiscard]] bool emitArrayLiteral(ListNode* array);
+ [[nodiscard]] bool emitArray(ParseNode* arrayHead, uint32_t count, JSOp op);
+ [[nodiscard]] bool emitArrayComp(ListNode* pn);
- MOZ_MUST_USE bool emitInternedScopeOp(uint32_t index, JSOp op);
- MOZ_MUST_USE bool emitInternedObjectOp(uint32_t index, JSOp op);
- MOZ_MUST_USE bool emitObjectOp(ObjectBox* objbox, JSOp op);
- MOZ_MUST_USE bool emitObjectPairOp(ObjectBox* objbox1, ObjectBox* objbox2, JSOp op);
- MOZ_MUST_USE bool emitRegExp(uint32_t index);
+ [[nodiscard]] bool emitInternedScopeOp(uint32_t index, JSOp op);
+ [[nodiscard]] bool emitInternedObjectOp(uint32_t index, JSOp op);
+ [[nodiscard]] bool emitObjectOp(ObjectBox* objbox, JSOp op);
+ [[nodiscard]] bool emitObjectPairOp(ObjectBox* objbox1, ObjectBox* objbox2, JSOp op);
+ [[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,
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);
enum class FieldPlacement { Instance, Static };
FieldInitializers setupFieldInitializers(ListNode* classMembers, FieldPlacement placement);
- MOZ_MUST_USE bool emitCreateFieldKeys(ListNode* obj, FieldPlacement placement);
- MOZ_MUST_USE bool emitCreateFieldInitializers(ClassEmitter& ce, ListNode* obj, FieldPlacement placement);
+ [[nodiscard]] bool emitCreateFieldKeys(ListNode* obj, FieldPlacement placement);
+ [[nodiscard]] bool emitCreateFieldInitializers(ClassEmitter& ce, ListNode* obj, FieldPlacement placement);
const FieldInitializers& findFieldInitializersForCall();
- MOZ_MUST_USE bool emitInitializeInstanceFields();
- MOZ_MUST_USE bool emitInitializeStaticFields(ListNode* classMembers);
+ [[nodiscard]] bool emitInitializeInstanceFields();
+ [[nodiscard]] bool emitInitializeStaticFields(ListNode* classMembers);
// To catch accidental misuse, emitUint16Operand/emit3 assert that they are
// not used to unconditionally emit JSOP_GETLOCAL. Variable access should
// instead be emitted using EmitVarOp. In special cases, when the caller
// definitely knows that a given local slot is unaliased, this function may be
// 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);
- MOZ_MUST_USE bool emitEnvCoordOp(JSOp op, EnvironmentCoordinate ec);
+ [[nodiscard]] bool emitArgOp(JSOp op, uint16_t slot);
+ [[nodiscard]] bool emitEnvCoordOp(JSOp op, EnvironmentCoordinate ec);
- MOZ_MUST_USE bool emitGetNameAtLocation(JSAtom* name, const NameLocation& loc);
- MOZ_MUST_USE bool emitGetName(JSAtom* name) {
+ [[nodiscard]] bool emitGetNameAtLocation(JSAtom* name, const NameLocation& loc);
+ [[nodiscard]] bool emitGetName(JSAtom* 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);
- MOZ_MUST_USE bool emitSingleDeclaration(ParseNode* declList, ParseNode* decl,
+ [[nodiscard]] bool emitDeclarationList(ListNode* declList);
+ [[nodiscard]] bool emitSingleDeclaration(ParseNode* declList, ParseNode* decl,
ParseNode* initializer);
- MOZ_MUST_USE bool emitNewInit(JSProtoKey key);
- MOZ_MUST_USE bool emitSingletonInitialiser(ParseNode* pn);
+ [[nodiscard]] bool emitNewInit(JSProtoKey key);
+ [[nodiscard]] bool emitSingletonInitialiser(ParseNode* pn);
- MOZ_MUST_USE bool emitPrepareIteratorResult();
- MOZ_MUST_USE bool emitFinishIteratorResult(bool done);
- MOZ_MUST_USE bool iteratorResultShape(unsigned* shape);
- MOZ_MUST_USE bool emitToIteratorResult(bool done);
+ [[nodiscard]] bool emitPrepareIteratorResult();
+ [[nodiscard]] bool emitFinishIteratorResult(bool done);
+ [[nodiscard]] bool iteratorResultShape(unsigned* shape);
+ [[nodiscard]] bool emitToIteratorResult(bool done);
- MOZ_MUST_USE bool emitGetDotGeneratorInInnermostScope() {
+ [[nodiscard]] bool emitGetDotGeneratorInInnermostScope() {
return emitGetDotGeneratorInScope(*innermostEmitterScope());
}
- MOZ_MUST_USE bool emitGetDotGeneratorInScope(EmitterScope& currentScope);
+ [[nodiscard]] bool emitGetDotGeneratorInScope(EmitterScope& currentScope);
- MOZ_MUST_USE bool emitInitialYield(UnaryNode* yieldNode);
- MOZ_MUST_USE bool emitYield(UnaryNode* yieldNode);
- MOZ_MUST_USE bool emitYieldOp(JSOp op);
- MOZ_MUST_USE bool emitYieldStar(ParseNode* iter);
- MOZ_MUST_USE bool emitAwaitInInnermostScope() {
+ [[nodiscard]] bool emitInitialYield(UnaryNode* yieldNode);
+ [[nodiscard]] bool emitYield(UnaryNode* yieldNode);
+ [[nodiscard]] bool emitYieldOp(JSOp op);
+ [[nodiscard]] bool emitYieldStar(ParseNode* iter);
+ [[nodiscard]] bool emitAwaitInInnermostScope() {
return emitAwaitInScope(*innermostEmitterScope());
}
- MOZ_MUST_USE bool emitAwaitInInnermostScope(UnaryNode* awaitNode);
- MOZ_MUST_USE bool emitAwaitInScope(EmitterScope& currentScope);
- MOZ_MUST_USE bool emitPropLHS(PropertyAccess* prop);
- MOZ_MUST_USE bool emitPropIncDec(UnaryNode* incDec);
+ [[nodiscard]] bool emitAwaitInInnermostScope(UnaryNode* awaitNode);
+ [[nodiscard]] bool emitAwaitInScope(EmitterScope& currentScope);
+ [[nodiscard]] bool emitPropLHS(PropertyAccess* prop);
+ [[nodiscard]] bool emitPropIncDec(UnaryNode* incDec);
- MOZ_MUST_USE bool emitAsyncWrapperLambda(unsigned index, bool isArrow);
- MOZ_MUST_USE bool emitAsyncWrapper(unsigned index, bool needsHomeObject, bool isArrow,
+ [[nodiscard]] bool emitAsyncWrapperLambda(unsigned index, bool isArrow);
+ [[nodiscard]] bool emitAsyncWrapper(unsigned index, bool needsHomeObject, bool isArrow,
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
// opcode onto the stack in the right order. In the case of SETELEM, the
// value to be assigned must already be pushed.
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);
- MOZ_MUST_USE bool emitElemOpBase(JSOp op);
- MOZ_MUST_USE bool emitElemIncDec(UnaryNode* incDec);
+ [[nodiscard]] bool emitElemObjAndKey(PropertyByValue* elem, bool isSuper, ElemOpEmitter& eoe);
+ [[nodiscard]] bool emitElemOpBase(JSOp op);
+ [[nodiscard]] bool emitElemIncDec(UnaryNode* incDec);
- MOZ_MUST_USE bool emitCatch(TernaryNode* catchNode);
- MOZ_MUST_USE bool emitIf(TernaryNode* ifNode);
- MOZ_MUST_USE bool emitWith(BinaryNode* withNode);
+ [[nodiscard]] bool emitCatch(TernaryNode* catchNode);
+ [[nodiscard]] bool emitIf(TernaryNode* ifNode);
+ [[nodiscard]] bool emitWith(BinaryNode* withNode);
- MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLabeledStatement(const LabeledStatement* pn);
- MOZ_NEVER_INLINE MOZ_MUST_USE bool emitLexicalScope(LexicalScopeNode* lexicalScope);
- MOZ_MUST_USE bool emitLexicalScopeBody(ParseNode* body,
+ [[nodiscard]] MOZ_NEVER_INLINE bool emitLabeledStatement(const LabeledStatement* pn);
+ [[nodiscard]] MOZ_NEVER_INLINE bool emitLexicalScope(LexicalScopeNode* lexicalScope);
+ [[nodiscard]] bool emitLexicalScopeBody(ParseNode* body,
EmitLineNumberNote emitLineNote = EMIT_LINENOTE);
- MOZ_NEVER_INLINE MOZ_MUST_USE bool emitSwitch(SwitchStatement* switchStmt);
- MOZ_NEVER_INLINE MOZ_MUST_USE bool emitTry(TryNode* tryNode);
+ [[nodiscard]] MOZ_NEVER_INLINE bool emitSwitch(SwitchStatement* switchStmt);
+ [[nodiscard]] MOZ_NEVER_INLINE bool emitTry(TryNode* tryNode);
// emitDestructuringLHSRef emits the lhs expression's reference.
// 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 there's nothing to evaluate for the reference, it emits nothing.
// |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
// 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
// []/{} expression).
- MOZ_MUST_USE bool emitSetOrInitializeDestructuring(ParseNode* target, DestructuringFlavor flav);
+ [[nodiscard]] bool emitSetOrInitializeDestructuring(ParseNode* target, DestructuringFlavor flav);
// emitDestructuringObjRestExclusionSet emits the property exclusion set
// 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
// pushed on the stack and emits code to destructure each part of a [] or
// {} lhs expression.
- MOZ_MUST_USE bool emitDestructuringOps(ListNode* pattern, DestructuringFlavor flav);
- MOZ_MUST_USE bool emitDestructuringOpsArray(ListNode* pattern, DestructuringFlavor flav);
- MOZ_MUST_USE bool emitDestructuringOpsObject(ListNode* pattern, DestructuringFlavor flav);
+ [[nodiscard]] bool emitDestructuringOps(ListNode* pattern, DestructuringFlavor flav);
+ [[nodiscard]] bool emitDestructuringOpsArray(ListNode* pattern, DestructuringFlavor flav);
+ [[nodiscard]] bool emitDestructuringOpsObject(ListNode* pattern, DestructuringFlavor flav);
typedef bool
(*DestructuringDeclEmitter)(BytecodeEmitter* bce, ParseNode* pn);
// Throw a TypeError if the value atop the stack isn't convertible to an
// object, with no overall effect on the stack.
- MOZ_MUST_USE bool emitRequireObjectCoercible();
+ [[nodiscard]] bool emitRequireObjectCoercible();
enum class CopyOption {
Filtered, Unfiltered
@@ -658,27 +658,27 @@ struct MOZ_STACK_CLASS BytecodeEmitter
// Calls either the |CopyDataProperties| or the
// |CopyDataPropertiesUnfiltered| intrinsic function, consumes three (or
// 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.
// 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
// 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()|
// 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);
- MOZ_MUST_USE bool emitIteratorCloseInScope(EmitterScope& currentScope,
+ [[nodiscard]] bool emitIteratorCloseInScope(EmitterScope& currentScope,
IteratorKind iterKind = IteratorKind::Sync,
CompletionKind completionKind = CompletionKind::Normal,
bool allowSelfHosted = false);
- MOZ_MUST_USE bool emitIteratorCloseInInnermostScope(IteratorKind iterKind = IteratorKind::Sync,
+ [[nodiscard]] bool emitIteratorCloseInInnermostScope(IteratorKind iterKind = IteratorKind::Sync,
CompletionKind completionKind = CompletionKind::Normal,
bool allowSelfHosted = false) {
return emitIteratorCloseInScope(*innermostEmitterScope(), iterKind, completionKind,
@@ -686,7 +686,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
}
template <typename InnerEmitter>
- MOZ_MUST_USE bool wrapWithDestructuringIteratorCloseTryNote(int32_t iterDepth,
+ [[nodiscard]] bool wrapWithDestructuringIteratorCloseTryNote(int32_t iterDepth,
InnerEmitter emitter);
// 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
// identifier and |defaultExpr| is an anonymous function, |SetFunctionName|
// 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);
- MOZ_MUST_USE bool setFunName(JSFunction* fun, JSAtom* name);
- MOZ_MUST_USE bool emitSetClassConstructorName(JSAtom* name);
- MOZ_MUST_USE bool emitSetFunctionNameFromStack(uint8_t offset);
+ [[nodiscard]] bool setOrEmitSetFunName(ParseNode* maybeFun, HandleAtom name);
+ [[nodiscard]] bool setFunName(JSFunction* fun, JSAtom* name);
+ [[nodiscard]] bool emitSetClassConstructorName(JSAtom* name);
+ [[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);
- MOZ_MUST_USE bool emitTemplateString(ListNode* templateString);
- MOZ_MUST_USE bool emitAssignmentOrInit(ParseNodeKind kind, JSOp compoundOp,
+ [[nodiscard]] bool emitCallSiteObject(CallSiteNode* callSiteObj);
+ [[nodiscard]] bool emitTemplateString(ListNode* templateString);
+ [[nodiscard]] bool emitAssignmentOrInit(ParseNodeKind kind, JSOp compoundOp,
ParseNode* lhs, ParseNode* rhs);
- MOZ_MUST_USE bool emitShortCircuitAssignment(ParseNodeKind kind, JSOp op,
+ [[nodiscard]] bool emitShortCircuitAssignment(ParseNodeKind kind, JSOp op,
ParseNode* lhs, ParseNode* rhs);
- MOZ_MUST_USE bool emitReturn(UnaryNode* returnNode);
- MOZ_MUST_USE bool emitStatement(UnaryNode* exprStmt);
- MOZ_MUST_USE bool emitStatementList(ListNode* stmtList);
+ [[nodiscard]] bool emitReturn(UnaryNode* returnNode);
+ [[nodiscard]] bool emitStatement(UnaryNode* exprStmt);
+ [[nodiscard]] bool emitStatementList(ListNode* stmtList);
- MOZ_MUST_USE bool emitDeleteName(UnaryNode* deleteNode);
- MOZ_MUST_USE bool emitDeleteProperty(UnaryNode* deleteNode);
- MOZ_MUST_USE bool emitDeleteElement(UnaryNode* deleteNode);
- MOZ_MUST_USE bool emitDeleteExpression(UnaryNode* deleteNode);
+ [[nodiscard]] bool emitDeleteName(UnaryNode* deleteNode);
+ [[nodiscard]] bool emitDeleteProperty(UnaryNode* deleteNode);
+ [[nodiscard]] bool emitDeleteElement(UnaryNode* deleteNode);
+ [[nodiscard]] bool emitDeleteExpression(UnaryNode* deleteNode);
// Optional methods which emit Optional Jump Target
- MOZ_MUST_USE bool emitOptionalChain(UnaryNode* optionalChain,
+ [[nodiscard]] bool emitOptionalChain(UnaryNode* optionalChain,
ValueUsage valueUsage);
- MOZ_MUST_USE bool emitCalleeAndThisForOptionalChain(UnaryNode* optionalChain,
+ [[nodiscard]] bool emitCalleeAndThisForOptionalChain(UnaryNode* optionalChain,
ParseNode* callNode,
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
// 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,
OptionalEmitter& oe);
- MOZ_MUST_USE bool emitOptionalElemExpression(PropertyByValueBase* elem,
+ [[nodiscard]] bool emitOptionalElemExpression(PropertyByValueBase* elem,
ElemOpEmitter& eoe, bool isSuper,
OptionalEmitter& oe);
- MOZ_MUST_USE bool emitOptionalCall(BinaryNode* callNode,
+ [[nodiscard]] bool emitOptionalCall(BinaryNode* callNode,
OptionalEmitter& oe,
ValueUsage valueUsage);
- MOZ_MUST_USE bool emitDeletePropertyInOptChain(PropertyAccessBase* propExpr,
+ [[nodiscard]] bool emitDeletePropertyInOptChain(PropertyAccessBase* propExpr,
OptionalEmitter& oe);
- MOZ_MUST_USE bool emitDeleteElementInOptChain(PropertyByValueBase* elemExpr,
+ [[nodiscard]] bool emitDeleteElementInOptChain(PropertyByValueBase* elemExpr,
OptionalEmitter& oe);
// |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);
- MOZ_MUST_USE bool emitRightAssociative(ListNode* node);
- MOZ_MUST_USE bool emitLeftAssociative(ListNode* node);
- MOZ_MUST_USE bool emitLogical(ListNode* node);
- MOZ_MUST_USE bool emitSequenceExpr(ListNode* node,
+ [[nodiscard]] bool emitUnary(UnaryNode* unaryNode);
+ [[nodiscard]] bool emitRightAssociative(ListNode* node);
+ [[nodiscard]] bool emitLeftAssociative(ListNode* node);
+ [[nodiscard]] bool emitLogical(ListNode* node);
+ [[nodiscard]] bool emitSequenceExpr(ListNode* node,
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);
- MOZ_MUST_USE bool isRestParameter(ParseNode* pn);
- MOZ_MUST_USE bool emitOptimizeSpread(ParseNode* arg0, JumpList* jmp, bool* emitted);
+ [[nodiscard]] bool isRestParameter(ParseNode* pn);
+ [[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);
- MOZ_MUST_USE bool emitArguments(ListNode* argsList, bool isCall, bool isSpread,
+ [[nodiscard]] bool emitArguments(ListNode* argsList, bool isCall, bool isSpread,
CallOrNewEmitter& cone);
- MOZ_MUST_USE bool emitCallOrNew(BinaryNode* pn,
+ [[nodiscard]] bool emitCallOrNew(BinaryNode* pn,
ValueUsage valueUsage = ValueUsage::WantValue);
- MOZ_MUST_USE bool emitCalleeAndThis(ParseNode* callNode,
+ [[nodiscard]] bool emitCalleeAndThis(ParseNode* callNode,
ParseNode* calleeNode,
CallOrNewEmitter& cone);
- MOZ_MUST_USE bool emitOptionalCalleeAndThis(ParseNode* callNode,
+ [[nodiscard]] bool emitOptionalCalleeAndThis(ParseNode* callNode,
ParseNode* calleeNode,
CallOrNewEmitter& cone,
OptionalEmitter& oe);
- MOZ_MUST_USE bool emitSelfHostedCallFunction(BinaryNode* callNode);
- MOZ_MUST_USE bool emitSelfHostedResumeGenerator(BinaryNode* callNode);
- MOZ_MUST_USE bool emitSelfHostedForceInterpreter(ParseNode* pn);
- MOZ_MUST_USE bool emitSelfHostedAllowContentIter(BinaryNode* callNode);
+ [[nodiscard]] bool emitSelfHostedCallFunction(BinaryNode* callNode);
+ [[nodiscard]] bool emitSelfHostedResumeGenerator(BinaryNode* callNode);
+ [[nodiscard]] bool emitSelfHostedForceInterpreter(ParseNode* pn);
+ [[nodiscard]] bool emitSelfHostedAllowContentIter(BinaryNode* callNode);
- MOZ_MUST_USE bool emitComprehensionFor(ForNode* forNode);
- MOZ_MUST_USE bool emitComprehensionForIn(ForNode* forNode);
- MOZ_MUST_USE bool emitComprehensionForInOrOfVariables(ParseNode* pn, bool* lexicalScope);
- MOZ_MUST_USE bool emitComprehensionForOf(ForNode* forNode);
+ [[nodiscard]] bool emitComprehensionFor(ForNode* forNode);
+ [[nodiscard]] bool emitComprehensionForIn(ForNode* forNode);
+ [[nodiscard]] bool emitComprehensionForInOrOfVariables(ParseNode* pn, bool* lexicalScope);
+ [[nodiscard]] bool emitComprehensionForOf(ForNode* forNode);
- MOZ_MUST_USE bool emitDo(BinaryNode* doNode);
- MOZ_MUST_USE bool emitWhile(BinaryNode* whileNode);
+ [[nodiscard]] bool emitDo(BinaryNode* doNode);
+ [[nodiscard]] bool emitWhile(BinaryNode* whileNode);
- MOZ_MUST_USE bool emitFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope = nullptr);
- MOZ_MUST_USE bool emitCStyleFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope);
- MOZ_MUST_USE bool emitForIn(ForNode* forNode, const EmitterScope* headLexicalEmitterScope);
- MOZ_MUST_USE bool emitForOf(ForNode* forNode, const EmitterScope* headLexicalEmitterScope);
+ [[nodiscard]] bool emitFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope = nullptr);
+ [[nodiscard]] bool emitCStyleFor(ForNode* forNode, const EmitterScope* headLexicalEmitterScope);
+ [[nodiscard]] bool emitForIn(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);
- MOZ_MUST_USE bool emitContinue(PropertyName* label);
+ [[nodiscard]] bool emitBreak(PropertyName* label);
+ [[nodiscard]] bool emitContinue(PropertyName* label);
- MOZ_MUST_USE bool emitFunctionFormalParameters(ListNode* paramsBody);
- MOZ_MUST_USE bool emitInitializeFunctionSpecialNames();
- MOZ_MUST_USE bool emitLexicalInitialization(NameNode* pn);
- MOZ_MUST_USE bool emitLexicalInitialization(JSAtom* name);
+ [[nodiscard]] bool emitFunctionFormalParameters(ListNode* paramsBody);
+ [[nodiscard]] bool emitInitializeFunctionSpecialNames();
+ [[nodiscard]] bool emitLexicalInitialization(NameNode* pn);
+ [[nodiscard]] bool emitLexicalInitialization(JSAtom* name);
// 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
// incrementing I, then push the result I (it will be original I +
// 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 {
diff --git a/js/src/frontend/CallOrNewEmitter.cpp b/js/src/frontend/CallOrNewEmitter.cpp
index 430c422811..51d624e38a 100644
--- a/js/src/frontend/CallOrNewEmitter.cpp
+++ b/js/src/frontend/CallOrNewEmitter.cpp
@@ -59,7 +59,7 @@ CallOrNewEmitter::emitNameCallee(JSAtom* name)
return true;
}
-MOZ_MUST_USE PropOpEmitter&
+[[nodiscard]] PropOpEmitter&
CallOrNewEmitter::prepareForPropCallee(bool isSuperProp)
{
MOZ_ASSERT(state_ == State::Start);
@@ -76,7 +76,7 @@ CallOrNewEmitter::prepareForPropCallee(bool isSuperProp)
return *poe_;
}
-MOZ_MUST_USE ElemOpEmitter&
+[[nodiscard]] ElemOpEmitter&
CallOrNewEmitter::prepareForElemCallee(bool isSuperElem)
{
MOZ_ASSERT(state_ == State::Start);
diff --git a/js/src/frontend/CallOrNewEmitter.h b/js/src/frontend/CallOrNewEmitter.h
index f1f9ce5e5a..021c5706eb 100644
--- a/js/src/frontend/CallOrNewEmitter.h
+++ b/js/src/frontend/CallOrNewEmitter.h
@@ -265,60 +265,60 @@ class MOZ_STACK_CLASS CallOrNewEmitter
ValueUsage valueUsage);
private:
- MOZ_MUST_USE bool isCall() const {
+ [[nodiscard]] bool isCall() const {
return op_ == JSOP_CALL || op_ == JSOP_CALL_IGNORES_RV ||
op_ == JSOP_SPREADCALL ||
isEval() || isFunApply() || isFunCall();
}
- MOZ_MUST_USE bool isNew() const {
+ [[nodiscard]] bool isNew() const {
return op_ == JSOP_NEW || op_ == JSOP_SPREADNEW;
}
- MOZ_MUST_USE bool isSuperCall() const {
+ [[nodiscard]] bool isSuperCall() const {
return op_ == JSOP_SUPERCALL || op_ == JSOP_SPREADSUPERCALL;
}
- MOZ_MUST_USE bool isEval() const {
+ [[nodiscard]] bool isEval() const {
return op_ == JSOP_EVAL || op_ == JSOP_STRICTEVAL ||
op_ == JSOP_SPREADEVAL || op_ == JSOP_STRICTSPREADEVAL;
}
- MOZ_MUST_USE bool isFunApply() const {
+ [[nodiscard]] bool isFunApply() const {
return op_ == JSOP_FUNAPPLY;
}
- MOZ_MUST_USE bool isFunCall() const {
+ [[nodiscard]] bool isFunCall() const {
return op_ == JSOP_FUNCALL;
}
- MOZ_MUST_USE bool isSpread() const {
+ [[nodiscard]] bool isSpread() const {
return JOF_OPTYPE(op_) == JOF_BYTE;
}
- MOZ_MUST_USE bool isSingleSpreadRest() const {
+ [[nodiscard]] bool isSingleSpreadRest() const {
return argumentsKind_ == ArgumentsKind::SingleSpreadRest;
}
public:
- MOZ_MUST_USE bool emitNameCallee(JSAtom* name);
- MOZ_MUST_USE PropOpEmitter& prepareForPropCallee(bool isSuperProp);
- MOZ_MUST_USE ElemOpEmitter& prepareForElemCallee(bool isSuperElem);
- MOZ_MUST_USE bool prepareForFunctionCallee();
- MOZ_MUST_USE bool emitSuperCallee();
- MOZ_MUST_USE bool prepareForOtherCallee();
+ [[nodiscard]] bool emitNameCallee(JSAtom* name);
+ [[nodiscard]] PropOpEmitter& prepareForPropCallee(bool isSuperProp);
+ [[nodiscard]] ElemOpEmitter& prepareForElemCallee(bool isSuperElem);
+ [[nodiscard]] bool prepareForFunctionCallee();
+ [[nodiscard]] bool emitSuperCallee();
+ [[nodiscard]] bool prepareForOtherCallee();
- MOZ_MUST_USE bool emitThis();
+ [[nodiscard]] bool emitThis();
// Used by BytecodeEmitter::emitPipeline to reuse CallOrNewEmitter instance
// across multiple chained calls.
void reset();
- MOZ_MUST_USE bool prepareForNonSpreadArguments();
+ [[nodiscard]] bool prepareForNonSpreadArguments();
// See the usage in the comment at the top of the class.
- MOZ_MUST_USE bool wantSpreadOperand();
- MOZ_MUST_USE bool emitSpreadArgumentsTest();
+ [[nodiscard]] bool wantSpreadOperand();
+ [[nodiscard]] bool emitSpreadArgumentsTest();
// Parameters are the offset in the source code for each character below:
//
@@ -328,7 +328,7 @@ class MOZ_STACK_CLASS CallOrNewEmitter
// beginPos
//
// Can be Nothing() if not available.
- MOZ_MUST_USE bool emitEnd(uint32_t argc, const mozilla::Maybe<uint32_t>& beginPos);
+ [[nodiscard]] bool emitEnd(uint32_t argc, const mozilla::Maybe<uint32_t>& beginPos);
};
} /* namespace frontend */
diff --git a/js/src/frontend/DefaultEmitter.h b/js/src/frontend/DefaultEmitter.h
index 45b8e01a11..65314821c2 100644
--- a/js/src/frontend/DefaultEmitter.h
+++ b/js/src/frontend/DefaultEmitter.h
@@ -6,7 +6,7 @@
#ifndef frontend_DefaultEmitter_h
#define frontend_DefaultEmitter_h
-#include "mozilla/Attributes.h" // MOZ_STACK_CLASS, MOZ_MUST_USE
+#include "mozilla/Attributes.h" // MOZ_STACK_CLASS
#include "mozilla/Maybe.h" // Maybe
#include "frontend/IfEmitter.h" // IfEmitter
@@ -54,8 +54,8 @@ class MOZ_STACK_CLASS DefaultEmitter {
public:
explicit DefaultEmitter(BytecodeEmitter* bce);
- MOZ_MUST_USE bool prepareForDefault();
- MOZ_MUST_USE bool emitEnd();
+ [[nodiscard]] bool prepareForDefault();
+ [[nodiscard]] bool emitEnd();
};
} /* namespace frontend */
diff --git a/js/src/frontend/ElemOpEmitter.h b/js/src/frontend/ElemOpEmitter.h
index c7feac4a94..d1f6a93477 100644
--- a/js/src/frontend/ElemOpEmitter.h
+++ b/js/src/frontend/ElemOpEmitter.h
@@ -218,63 +218,63 @@ class MOZ_STACK_CLASS ElemOpEmitter
ElemOpEmitter(BytecodeEmitter* bce, Kind kind, ObjKind objKind);
private:
- MOZ_MUST_USE bool isCall() const {
+ [[nodiscard]] bool isCall() const {
return kind_ == Kind::Call;
}
- MOZ_MUST_USE bool isSimpleAssignment() const {
+ [[nodiscard]] bool isSimpleAssignment() const {
return kind_ == Kind::SimpleAssignment;
}
- MOZ_MUST_USE bool isPropInit() const {
+ [[nodiscard]] bool isPropInit() const {
return kind_ == Kind::PropInit;
}
- MOZ_MUST_USE bool isDelete() const {
+ [[nodiscard]] bool isDelete() const {
return kind_ == Kind::Delete;
}
- MOZ_MUST_USE bool isCompoundAssignment() const {
+ [[nodiscard]] bool isCompoundAssignment() const {
return kind_ == Kind::CompoundAssignment;
}
- MOZ_MUST_USE bool isIncDec() const {
+ [[nodiscard]] bool isIncDec() const {
return isPostIncDec() || isPreIncDec();
}
- MOZ_MUST_USE bool isPostIncDec() const {
+ [[nodiscard]] bool isPostIncDec() const {
return kind_ == Kind::PostIncrement ||
kind_ == Kind::PostDecrement;
}
- MOZ_MUST_USE bool isPreIncDec() const {
+ [[nodiscard]] bool isPreIncDec() const {
return kind_ == Kind::PreIncrement ||
kind_ == Kind::PreDecrement;
}
- MOZ_MUST_USE bool isInc() const {
+ [[nodiscard]] bool isInc() const {
return kind_ == Kind::PostIncrement ||
kind_ == Kind::PreIncrement;
}
- MOZ_MUST_USE bool isSuper() const {
+ [[nodiscard]] bool isSuper() const {
return objKind_ == ObjKind::Super;
}
public:
- MOZ_MUST_USE bool prepareForObj();
- MOZ_MUST_USE bool prepareForKey();
+ [[nodiscard]] bool prepareForObj();
+ [[nodiscard]] bool prepareForKey();
- MOZ_MUST_USE bool emitGet();
+ [[nodiscard]] bool emitGet();
- MOZ_MUST_USE bool prepareForRhs();
- MOZ_MUST_USE bool skipObjAndKeyAndRhs();
+ [[nodiscard]] bool prepareForRhs();
+ [[nodiscard]] bool skipObjAndKeyAndRhs();
- MOZ_MUST_USE bool emitDelete();
+ [[nodiscard]] bool emitDelete();
- MOZ_MUST_USE bool emitAssignment();
+ [[nodiscard]] bool emitAssignment();
- MOZ_MUST_USE bool emitIncDec();
+ [[nodiscard]] bool emitIncDec();
};
} /* namespace frontend */
diff --git a/js/src/frontend/EmitterScope.h b/js/src/frontend/EmitterScope.h
index c7dfd1d559..9498cc1b38 100644
--- a/js/src/frontend/EmitterScope.h
+++ b/js/src/frontend/EmitterScope.h
@@ -56,16 +56,16 @@ class EmitterScope : public Nestable<EmitterScope>
// block scope note list. Otherwise ScopeNote::NoScopeNote.
uint32_t noteIndex_;
- MOZ_MUST_USE bool ensureCache(BytecodeEmitter* bce);
+ [[nodiscard]] bool ensureCache(BytecodeEmitter* bce);
template <typename BindingIter>
- MOZ_MUST_USE bool checkSlotLimits(BytecodeEmitter* bce, const BindingIter& bi);
+ [[nodiscard]] bool checkSlotLimits(BytecodeEmitter* bce, const BindingIter& bi);
- MOZ_MUST_USE bool checkEnvironmentChainLength(BytecodeEmitter* bce);
+ [[nodiscard]] bool checkEnvironmentChainLength(BytecodeEmitter* bce);
void updateFrameFixedSlots(BytecodeEmitter* bce, const BindingIter& bi);
- MOZ_MUST_USE bool putNameInCache(BytecodeEmitter* bce, JSAtom* name, NameLocation loc);
+ [[nodiscard]] bool putNameInCache(BytecodeEmitter* bce, JSAtom* name, NameLocation loc);
mozilla::Maybe<NameLocation> lookupInCache(BytecodeEmitter* bce, JSAtom* name);
@@ -79,12 +79,12 @@ class EmitterScope : public Nestable<EmitterScope>
NameLocation searchAndCache(BytecodeEmitter* bce, JSAtom* name);
template <typename ScopeCreator>
- MOZ_MUST_USE bool internScope(BytecodeEmitter* bce, ScopeCreator createScope);
+ [[nodiscard]] bool internScope(BytecodeEmitter* bce, ScopeCreator createScope);
template <typename ScopeCreator>
- MOZ_MUST_USE bool internBodyScope(BytecodeEmitter* bce, ScopeCreator createScope);
- MOZ_MUST_USE bool appendScopeNote(BytecodeEmitter* bce);
+ [[nodiscard]] bool internBodyScope(BytecodeEmitter* bce, ScopeCreator createScope);
+ [[nodiscard]] bool appendScopeNote(BytecodeEmitter* bce);
- MOZ_MUST_USE bool deadZoneFrameSlotRange(BytecodeEmitter* bce, uint32_t slotStart,
+ [[nodiscard]] bool deadZoneFrameSlotRange(BytecodeEmitter* bce, uint32_t slotStart,
uint32_t slotEnd) const;
public:
@@ -92,21 +92,21 @@ class EmitterScope : public Nestable<EmitterScope>
void dump(BytecodeEmitter* bce);
- MOZ_MUST_USE bool enterLexical(BytecodeEmitter* bce, ScopeKind kind,
+ [[nodiscard]] bool enterLexical(BytecodeEmitter* bce, ScopeKind kind,
Handle<LexicalScope::Data*> bindings);
- MOZ_MUST_USE bool enterNamedLambda(BytecodeEmitter* bce, FunctionBox* funbox);
- MOZ_MUST_USE bool enterComprehensionFor(BytecodeEmitter* bce,
+ [[nodiscard]] bool enterNamedLambda(BytecodeEmitter* bce, FunctionBox* funbox);
+ [[nodiscard]] bool enterComprehensionFor(BytecodeEmitter* bce,
Handle<LexicalScope::Data*> bindings);
- MOZ_MUST_USE bool enterFunction(BytecodeEmitter* bce, FunctionBox* funbox);
- MOZ_MUST_USE bool enterFunctionExtraBodyVar(BytecodeEmitter* bce, FunctionBox* funbox);
- MOZ_MUST_USE bool enterParameterExpressionVar(BytecodeEmitter* bce);
- MOZ_MUST_USE bool enterGlobal(BytecodeEmitter* bce, GlobalSharedContext* globalsc);
- MOZ_MUST_USE bool enterEval(BytecodeEmitter* bce, EvalSharedContext* evalsc);
- MOZ_MUST_USE bool enterModule(BytecodeEmitter* module, ModuleSharedContext* modulesc);
- MOZ_MUST_USE bool enterWith(BytecodeEmitter* bce);
- MOZ_MUST_USE bool deadZoneFrameSlots(BytecodeEmitter* bce) const;
-
- MOZ_MUST_USE bool leave(BytecodeEmitter* bce, bool nonLocal = false);
+ [[nodiscard]] bool enterFunction(BytecodeEmitter* bce, FunctionBox* funbox);
+ [[nodiscard]] bool enterFunctionExtraBodyVar(BytecodeEmitter* bce, FunctionBox* funbox);
+ [[nodiscard]] bool enterParameterExpressionVar(BytecodeEmitter* bce);
+ [[nodiscard]] bool enterGlobal(BytecodeEmitter* bce, GlobalSharedContext* globalsc);
+ [[nodiscard]] bool enterEval(BytecodeEmitter* bce, EvalSharedContext* evalsc);
+ [[nodiscard]] bool enterModule(BytecodeEmitter* module, ModuleSharedContext* modulesc);
+ [[nodiscard]] bool enterWith(BytecodeEmitter* bce);
+ [[nodiscard]] bool deadZoneFrameSlots(BytecodeEmitter* bce) const;
+
+ [[nodiscard]] bool leave(BytecodeEmitter* bce, bool nonLocal = false);
uint32_t index() const {
MOZ_ASSERT(scopeIndex_ != ScopeNote::NoScopeIndex, "Did you forget to intern a Scope?");
diff --git a/js/src/frontend/FoldConstants.h b/js/src/frontend/FoldConstants.h
index 1c8455183e..bb64efa9fe 100644
--- a/js/src/frontend/FoldConstants.h
+++ b/js/src/frontend/FoldConstants.h
@@ -24,10 +24,10 @@ namespace frontend {
// return false;
// if (!FoldConstants(cx, &pn, parser))
// return false;
-MOZ_MUST_USE bool
+[[nodiscard]] bool
FoldConstants(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>* parser);
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
FoldConstants(ExclusiveContext* cx, SyntaxParseHandler::Node* pnp,
Parser<SyntaxParseHandler>* parser)
{
diff --git a/js/src/frontend/ForOfLoopControl.h b/js/src/frontend/ForOfLoopControl.h
index 9cf3ea3ff3..1f5b0949e3 100644
--- a/js/src/frontend/ForOfLoopControl.h
+++ b/js/src/frontend/ForOfLoopControl.h
@@ -72,16 +72,16 @@ class ForOfLoopControl : public LoopControl
ForOfLoopControl(BytecodeEmitter* bce, int32_t iterDepth, bool allowSelfHosted,
IteratorKind iterKind);
- MOZ_MUST_USE bool emitBeginCodeNeedingIteratorClose(BytecodeEmitter* bce);
- MOZ_MUST_USE bool emitEndCodeNeedingIteratorClose(BytecodeEmitter* bce);
+ [[nodiscard]] bool emitBeginCodeNeedingIteratorClose(BytecodeEmitter* bce);
+ [[nodiscard]] bool emitEndCodeNeedingIteratorClose(BytecodeEmitter* bce);
- MOZ_MUST_USE bool emitIteratorCloseInInnermostScope(BytecodeEmitter* bce,
+ [[nodiscard]] bool emitIteratorCloseInInnermostScope(BytecodeEmitter* bce,
CompletionKind completionKind = CompletionKind::Normal);
- MOZ_MUST_USE bool emitIteratorCloseInScope(BytecodeEmitter* bce,
+ [[nodiscard]] bool emitIteratorCloseInScope(BytecodeEmitter* bce,
EmitterScope& currentScope,
CompletionKind completionKind = CompletionKind::Normal);
- MOZ_MUST_USE bool emitPrepareForNonLocalJumpFromScope(BytecodeEmitter* bce,
+ [[nodiscard]] bool emitPrepareForNonLocalJumpFromScope(BytecodeEmitter* bce,
EmitterScope& currentScope,
bool isTarget);
};
diff --git a/js/src/frontend/FullParseHandler.h b/js/src/frontend/FullParseHandler.h
index d2c8bbc2df..4919012ad9 100644
--- a/js/src/frontend/FullParseHandler.h
+++ b/js/src/frontend/FullParseHandler.h
@@ -319,7 +319,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return literal;
}
- MOZ_MUST_USE bool addElision(ListNodeType literal, const TokenPos& pos) {
+ [[nodiscard]] bool addElision(ListNodeType literal, const TokenPos& pos) {
NullaryNode* elision = new_<NullaryNode>(PNK_ELISION, pos);
if (!elision)
return false;
@@ -329,7 +329,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return true;
}
- MOZ_MUST_USE bool addSpreadElement(ListNodeType literal, uint32_t begin, Node inner) {
+ [[nodiscard]] bool addSpreadElement(ListNodeType literal, uint32_t begin, Node inner) {
ParseNode* spread = newSpread(begin, inner);
if (!spread)
return false;
@@ -400,7 +400,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<UnaryNode>(PNK_SUPERBASE, JSOP_NOP, pos, thisName);
}
- MOZ_MUST_USE bool addPrototypeMutation(ListNodeType literal, uint32_t begin, Node expr) {
+ [[nodiscard]] bool addPrototypeMutation(ListNodeType literal, uint32_t begin, Node expr) {
// Object literals with mutated [[Prototype]] are non-constant so that
// singleton objects will have Object.prototype as their [[Prototype]].
literal->setHasNonConstInitializer();
@@ -412,7 +412,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return true;
}
- MOZ_MUST_USE bool addPropertyDefinition(ListNodeType literal, Node key, Node val) {
+ [[nodiscard]] bool addPropertyDefinition(ListNodeType literal, Node key, Node val) {
MOZ_ASSERT(literal->isKind(PNK_OBJECT));
MOZ_ASSERT(key->isKind(PNK_NUMBER) ||
key->isKind(PNK_OBJECT_PROPERTY_NAME) ||
@@ -430,7 +430,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return true;
}
- MOZ_MUST_USE bool addShorthand(ListNodeType literal, NameNodeType name, NameNodeType expr) {
+ [[nodiscard]] bool addShorthand(ListNodeType literal, NameNodeType name, NameNodeType expr) {
MOZ_ASSERT(literal->isKind(PNK_OBJECT));
MOZ_ASSERT(name->isKind(PNK_OBJECT_PROPERTY_NAME));
MOZ_ASSERT(expr->isKind(PNK_NAME));
@@ -444,7 +444,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return true;
}
- MOZ_MUST_USE bool addSpreadProperty(ListNodeType literal, uint32_t begin, Node inner) {
+ [[nodiscard]] bool addSpreadProperty(ListNodeType literal, uint32_t begin, Node inner) {
MOZ_ASSERT(literal->isKind(PNK_OBJECT));
literal->setHasNonConstInitializer();
@@ -455,8 +455,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return true;
}
- MOZ_MUST_USE bool addObjectMethodDefinition(ListNodeType literal, Node key, FunctionNodeType funNode,
- JSOp op)
+ [[nodiscard]] bool addObjectMethodDefinition(ListNodeType literal, Node key, FunctionNodeType funNode,
+ JSOp op)
{
MOZ_ASSERT(key->isKind(PNK_NUMBER) ||
key->isKind(PNK_OBJECT_PROPERTY_NAME) ||
@@ -471,27 +471,27 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return true;
}
- MOZ_MUST_USE ClassMethod* newClassMethodDefinition(Node key, FunctionNodeType funNode,
- JSOp op, bool isStatic)
+ [[nodiscard]] ClassMethod* newClassMethodDefinition(Node key, FunctionNodeType funNode,
+ JSOp op, bool isStatic)
{
MOZ_ASSERT(isUsableAsObjectPropertyName(key));
return new_<ClassMethod>(key, funNode, op, isStatic);
}
- MOZ_MUST_USE ClassField* newClassFieldDefinition(Node name, FunctionNodeType initializer, bool isStatic)
+ [[nodiscard]] ClassField* newClassFieldDefinition(Node name, FunctionNodeType initializer, bool isStatic)
{
MOZ_ASSERT(isUsableAsObjectPropertyName(name));
return new_<ClassField>(name, initializer, isStatic);
}
- MOZ_MUST_USE StaticClassBlock* newStaticClassBlock(FunctionNodeType block)
+ [[nodiscard]] StaticClassBlock* newStaticClassBlock(FunctionNodeType block)
{
return new_<StaticClassBlock>(block);
}
- MOZ_MUST_USE bool addClassMemberDefinition(ListNodeType memberList, Node member)
+ [[nodiscard]] bool addClassMemberDefinition(ListNodeType memberList, Node member)
{
MOZ_ASSERT(memberList->isKind(PNK_CLASSMEMBERLIST));
// Constructors can be surrounded by LexicalScopes.
@@ -536,7 +536,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<ListNode>(PNK_STATEMENTLIST, pos);
}
- MOZ_MUST_USE bool isFunctionStmt(Node stmt) {
+ [[nodiscard]] bool isFunctionStmt(Node stmt) {
while (stmt->isKind(PNK_LABEL))
stmt = stmt->as<LabeledStatement>().statement();
return stmt->is<FunctionNode>();
@@ -563,7 +563,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
list->setHasTopLevelFunctionDeclarations();
}
- MOZ_MUST_USE bool prependInitialYield(ListNodeType stmtList, Node genName) {
+ [[nodiscard]] bool prependInitialYield(ListNodeType stmtList, Node genName) {
MOZ_ASSERT(stmtList->isKind(PNK_STATEMENTLIST));
TokenPos yieldPos(stmtList->pn_pos.begin, stmtList->pn_pos.begin + 1);
@@ -752,10 +752,10 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return new_<OptionalPropertyByValue>(lhs, index, lhs->pn_pos.begin, end);
}
- inline MOZ_MUST_USE bool addCatchBlock(ListNodeType catchList, LexicalScopeNodeType lexicalScope,
- Node catchBinding, Node catchGuard, Node catchBody);
+ [[nodiscard]] inline bool addCatchBlock(ListNodeType catchList, LexicalScopeNodeType lexicalScope,
+ Node catchBinding, Node catchGuard, Node catchBody);
- inline MOZ_MUST_USE bool setLastFunctionFormalParameterDefault(FunctionNodeType funNode,
+ [[nodiscard]] inline bool setLastFunctionFormalParameterDefault(FunctionNodeType funNode,
Node defaultValue);
inline void setLastFunctionFormalParameterDestructuring(Node funcpn, Node pn);
@@ -858,7 +858,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
node->isKind(PNK_COMPUTED_NAME);
}
- inline MOZ_MUST_USE bool finishInitializerAssignment(NameNodeType nameNode, Node init);
+ [[nodiscard]] inline bool finishInitializerAssignment(NameNodeType nameNode, Node init);
void setBeginPosition(Node pn, Node oth) {
setBeginPosition(pn, oth->pn_pos.begin);
@@ -941,12 +941,12 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
literal->setHasNonConstInitializer();
}
template <typename NodeType>
- MOZ_MUST_USE NodeType parenthesize(NodeType node) {
+ [[nodiscard]] NodeType parenthesize(NodeType node) {
node->setInParens(true);
return node;
}
template <typename NodeType>
- MOZ_MUST_USE NodeType setLikelyIIFE(NodeType node) {
+ [[nodiscard]] NodeType setLikelyIIFE(NodeType node) {
return parenthesize(node);
}
void setInDirectivePrologue(UnaryNodeType exprStmt) {
diff --git a/js/src/frontend/FunctionEmitter.h b/js/src/frontend/FunctionEmitter.h
index 4596aca219..f297f8e6c6 100644
--- a/js/src/frontend/FunctionEmitter.h
+++ b/js/src/frontend/FunctionEmitter.h
@@ -6,7 +6,7 @@
#ifndef frontend_FunctionEmitter_h
#define frontend_FunctionEmitter_h
-#include "mozilla/Attributes.h" // MOZ_STACK_CLASS, MOZ_MUST_USE
+#include "mozilla/Attributes.h" // MOZ_STACK_CLASS
#include <stdint.h> // uint16_t, uint32_t
@@ -118,30 +118,30 @@ class MOZ_STACK_CLASS FunctionEmitter {
FunctionEmitter(BytecodeEmitter* bce, FunctionBox* funbox,
FunctionSyntaxKind syntaxKind, bool isHoisted);
- MOZ_MUST_USE bool prepareForNonLazy();
- MOZ_MUST_USE bool emitNonLazyEnd();
+ [[nodiscard]] bool prepareForNonLazy();
+ [[nodiscard]] bool emitNonLazyEnd();
- MOZ_MUST_USE bool emitLazy();
+ [[nodiscard]] bool emitLazy();
- MOZ_MUST_USE bool emitAgain();
+ [[nodiscard]] bool emitAgain();
- MOZ_MUST_USE bool emitAsmJSModule();
+ [[nodiscard]] bool emitAsmJSModule();
private:
// Common code for non-lazy and lazy functions.
- MOZ_MUST_USE bool interpretedCommon();
+ [[nodiscard]] bool interpretedCommon();
// Emit the function declaration, expression, method etc.
// This leaves function object on the stack for expression etc,
// and doesn't for declaration.
- MOZ_MUST_USE bool emitFunction();
+ [[nodiscard]] bool emitFunction();
// Helper methods used by emitFunction for each case.
// `index` is the object index of the function.
- MOZ_MUST_USE bool emitNonHoisted(unsigned index);
- MOZ_MUST_USE bool emitHoisted(unsigned index);
- MOZ_MUST_USE bool emitTopLevelFunction(unsigned index);
- MOZ_MUST_USE bool emitNewTargetForArrow();
+ [[nodiscard]] bool emitNonHoisted(unsigned index);
+ [[nodiscard]] bool emitHoisted(unsigned index);
+ [[nodiscard]] bool emitTopLevelFunction(unsigned index);
+ [[nodiscard]] bool emitNewTargetForArrow();
};
// Class for emitting function script.
@@ -243,19 +243,19 @@ class MOZ_STACK_CLASS FunctionScriptEmitter {
paramStart_(paramStart),
bodyEnd_(bodyEnd) {}
- MOZ_MUST_USE bool prepareForParameters();
- MOZ_MUST_USE bool prepareForBody();
- MOZ_MUST_USE bool emitEndBody();
+ [[nodiscard]] bool prepareForParameters();
+ [[nodiscard]] bool prepareForBody();
+ [[nodiscard]] bool emitEndBody();
// Initialize JSScript for this function.
// WARNING: There shouldn't be any fallible operation for the function
// compilation after `initScript` call.
// See the comment inside JSScript::fullyInitFromEmitter for
// more details.
- MOZ_MUST_USE bool initScript();
+ [[nodiscard]] bool initScript();
private:
- MOZ_MUST_USE bool emitExtraBodyVarScope();
+ [[nodiscard]] bool emitExtraBodyVarScope();
};
// Class for emitting function parameters.
@@ -411,36 +411,36 @@ class MOZ_STACK_CLASS FunctionParamsEmitter {
// paramName is used only when there's at least one expression in the
// paramerters (funbox_->hasParameterExprs == true).
- MOZ_MUST_USE bool emitSimple(JS::Handle<JSAtom*> paramName);
+ [[nodiscard]] bool emitSimple(JS::Handle<JSAtom*> paramName);
- MOZ_MUST_USE bool prepareForDefault();
- MOZ_MUST_USE bool emitDefaultEnd(JS::Handle<JSAtom*> paramName);
+ [[nodiscard]] bool prepareForDefault();
+ [[nodiscard]] bool emitDefaultEnd(JS::Handle<JSAtom*> paramName);
- MOZ_MUST_USE bool prepareForDestructuring();
- MOZ_MUST_USE bool emitDestructuringEnd();
+ [[nodiscard]] bool prepareForDestructuring();
+ [[nodiscard]] bool emitDestructuringEnd();
- MOZ_MUST_USE bool prepareForDestructuringDefaultInitializer();
- MOZ_MUST_USE bool prepareForDestructuringDefault();
- MOZ_MUST_USE bool emitDestructuringDefaultEnd();
+ [[nodiscard]] bool prepareForDestructuringDefaultInitializer();
+ [[nodiscard]] bool prepareForDestructuringDefault();
+ [[nodiscard]] bool emitDestructuringDefaultEnd();
- MOZ_MUST_USE bool emitRest(JS::Handle<JSAtom*> paramName);
+ [[nodiscard]] bool emitRest(JS::Handle<JSAtom*> paramName);
- MOZ_MUST_USE bool prepareForDestructuringRest();
- MOZ_MUST_USE bool emitDestructuringRestEnd();
+ [[nodiscard]] bool prepareForDestructuringRest();
+ [[nodiscard]] bool emitDestructuringRestEnd();
- MOZ_MUST_USE DestructuringFlavor getDestructuringFlavor();
+ [[nodiscard]] DestructuringFlavor getDestructuringFlavor();
private:
// Enter/leave var scope for `eval` if necessary.
- MOZ_MUST_USE bool enterParameterExpressionVarScope();
- MOZ_MUST_USE bool leaveParameterExpressionVarScope();
+ [[nodiscard]] bool enterParameterExpressionVarScope();
+ [[nodiscard]] bool leaveParameterExpressionVarScope();
- MOZ_MUST_USE bool prepareForInitializer();
- MOZ_MUST_USE bool emitInitializerEnd();
+ [[nodiscard]] bool prepareForInitializer();
+ [[nodiscard]] bool emitInitializerEnd();
- MOZ_MUST_USE bool emitRestArray();
+ [[nodiscard]] bool emitRestArray();
- MOZ_MUST_USE bool emitAssignment(JS::Handle<JSAtom*> paramName);
+ [[nodiscard]] bool emitAssignment(JS::Handle<JSAtom*> paramName);
};
} /* namespace frontend */
diff --git a/js/src/frontend/IfEmitter.h b/js/src/frontend/IfEmitter.h
index b4032f3988..fc78f8bf3b 100644
--- a/js/src/frontend/IfEmitter.h
+++ b/js/src/frontend/IfEmitter.h
@@ -171,14 +171,14 @@ class MOZ_STACK_CLASS IfEmitter
public:
explicit IfEmitter(BytecodeEmitter* bce);
- MOZ_MUST_USE bool emitThen();
- MOZ_MUST_USE bool emitCond();
- MOZ_MUST_USE bool emitThenElse();
+ [[nodiscard]] bool emitThen();
+ [[nodiscard]] bool emitCond();
+ [[nodiscard]] bool emitThenElse();
- MOZ_MUST_USE bool emitElse();
- MOZ_MUST_USE bool emitElseIf();
+ [[nodiscard]] bool emitElse();
+ [[nodiscard]] bool emitElseIf();
- MOZ_MUST_USE bool emitEnd();
+ [[nodiscard]] bool emitEnd();
#ifdef DEBUG
// Returns the number of values pushed onto the value stack inside
@@ -197,9 +197,9 @@ class MOZ_STACK_CLASS IfEmitter
#endif
private:
- MOZ_MUST_USE bool emitIfInternal(SrcNoteType type);
+ [[nodiscard]] bool emitIfInternal(SrcNoteType type);
void calculateOrCheckPushed();
- MOZ_MUST_USE bool emitElseInternal();
+ [[nodiscard]] bool emitElseInternal();
};
// Class for emitting bytecode for blocks like if-then-else which doesn't touch
diff --git a/js/src/frontend/LexicalScopeEmitter.h b/js/src/frontend/LexicalScopeEmitter.h
index be92b75654..60331a8f91 100644
--- a/js/src/frontend/LexicalScopeEmitter.h
+++ b/js/src/frontend/LexicalScopeEmitter.h
@@ -7,7 +7,7 @@
#define frontend_LexicalScopeEmitter_h
#include "mozilla/Assertions.h" // MOZ_ASSERT
-#include "mozilla/Attributes.h" // MOZ_STACK_CLASS, MOZ_MUST_USE
+#include "mozilla/Attributes.h" // MOZ_STACK_CLASS
#include "mozilla/Maybe.h" // Maybe
#include "frontend/EmitterScope.h" // EmitterScope
@@ -85,11 +85,11 @@ class MOZ_STACK_CLASS LexicalScopeEmitter
return *emitterScope_;
}
- MOZ_MUST_USE bool emitScope(ScopeKind kind,
+ [[nodiscard]] bool emitScope(ScopeKind kind,
JS::Handle<LexicalScope::Data*> bindings);
- MOZ_MUST_USE bool emitEmptyScope();
+ [[nodiscard]] bool emitEmptyScope();
- MOZ_MUST_USE bool emitEnd();
+ [[nodiscard]] bool emitEnd();
};
} /* namespace frontend */
diff --git a/js/src/frontend/NameFunctions.h b/js/src/frontend/NameFunctions.h
index a880cc1604..95e6cd4865 100644
--- a/js/src/frontend/NameFunctions.h
+++ b/js/src/frontend/NameFunctions.h
@@ -18,7 +18,7 @@ namespace frontend {
class ParseNode;
-MOZ_MUST_USE bool
+[[nodiscard]] bool
NameFunctions(ExclusiveContext* cx, ParseNode* pn);
} /* namespace frontend */
diff --git a/js/src/frontend/NameOpEmitter.h b/js/src/frontend/NameOpEmitter.h
index 57fe5fe544..f620876a37 100644
--- a/js/src/frontend/NameOpEmitter.h
+++ b/js/src/frontend/NameOpEmitter.h
@@ -136,54 +136,54 @@ class MOZ_STACK_CLASS NameOpEmitter
NameOpEmitter(BytecodeEmitter* bce, JSAtom* name, const NameLocation& loc, Kind kind);
private:
- MOZ_MUST_USE bool isCall() const {
+ [[nodiscard]] bool isCall() const {
return kind_ == Kind::Call;
}
- MOZ_MUST_USE bool isSimpleAssignment() const {
+ [[nodiscard]] bool isSimpleAssignment() const {
return kind_ == Kind::SimpleAssignment;
}
- MOZ_MUST_USE bool isCompoundAssignment() const {
+ [[nodiscard]] bool isCompoundAssignment() const {
return kind_ == Kind::CompoundAssignment;
}
- MOZ_MUST_USE bool isIncDec() const {
+ [[nodiscard]] bool isIncDec() const {
return isPostIncDec() || isPreIncDec();
}
- MOZ_MUST_USE bool isPostIncDec() const {
+ [[nodiscard]] bool isPostIncDec() const {
return kind_ == Kind::PostIncrement ||
kind_ == Kind::PostDecrement;
}
- MOZ_MUST_USE bool isPreIncDec() const {
+ [[nodiscard]] bool isPreIncDec() const {
return kind_ == Kind::PreIncrement ||
kind_ == Kind::PreDecrement;
}
- MOZ_MUST_USE bool isInc() const {
+ [[nodiscard]] bool isInc() const {
return kind_ == Kind::PostIncrement ||
kind_ == Kind::PreIncrement;
}
- MOZ_MUST_USE bool isInitialize() const {
+ [[nodiscard]] bool isInitialize() const {
return kind_ == Kind::Initialize;
}
public:
- MOZ_MUST_USE bool emittedBindOp() const {
+ [[nodiscard]] bool emittedBindOp() const {
return emittedBindOp_;
}
- MOZ_MUST_USE const NameLocation& loc() const {
+ [[nodiscard]] const NameLocation& loc() const {
return loc_;
}
- MOZ_MUST_USE bool emitGet();
- MOZ_MUST_USE bool prepareForRhs();
- MOZ_MUST_USE bool emitAssignment();
- MOZ_MUST_USE bool emitIncDec();
+ [[nodiscard]] bool emitGet();
+ [[nodiscard]] bool prepareForRhs();
+ [[nodiscard]] bool emitAssignment();
+ [[nodiscard]] bool emitIncDec();
};
} /* namespace frontend */
diff --git a/js/src/frontend/ObjectEmitter.h b/js/src/frontend/ObjectEmitter.h
index e17043affa..8549602982 100644
--- a/js/src/frontend/ObjectEmitter.h
+++ b/js/src/frontend/ObjectEmitter.h
@@ -6,7 +6,7 @@
#ifndef frontend_ObjectEmitter_h
#define frontend_ObjectEmitter_h
-#include "mozilla/Attributes.h" // MOZ_MUST_USE, MOZ_STACK_CLASS, MOZ_ALWAYS_INLINE, MOZ_RAII
+#include "mozilla/Attributes.h" // MOZ_STACK_CLASS, MOZ_ALWAYS_INLINE, MOZ_RAII
#include "mozilla/Maybe.h" // Maybe
#include <stddef.h> // size_t, ptrdiff_t
@@ -211,42 +211,42 @@ class MOZ_STACK_CLASS PropertyEmitter
// ^
// |
// keyPos
- MOZ_MUST_USE bool prepareForProtoValue(
+ [[nodiscard]] bool prepareForProtoValue(
const mozilla::Maybe<uint32_t>& keyPos);
- MOZ_MUST_USE bool emitMutateProto();
+ [[nodiscard]] bool emitMutateProto();
// { ...obj }
// ^
// |
// spreadPos
- MOZ_MUST_USE bool prepareForSpreadOperand(
+ [[nodiscard]] bool prepareForSpreadOperand(
const mozilla::Maybe<uint32_t>& spreadPos);
- MOZ_MUST_USE bool emitSpread();
+ [[nodiscard]] bool emitSpread();
// { key: value }
// ^
// |
// keyPos
- MOZ_MUST_USE bool prepareForPropValue(const mozilla::Maybe<uint32_t>& keyPos,
+ [[nodiscard]] bool prepareForPropValue(const mozilla::Maybe<uint32_t>& keyPos,
Kind kind = Kind::Prototype);
// { 1: value }
// ^
// |
// keyPos
- MOZ_MUST_USE bool prepareForIndexPropKey(
+ [[nodiscard]] bool prepareForIndexPropKey(
const mozilla::Maybe<uint32_t>& keyPos, Kind kind = Kind::Prototype);
- MOZ_MUST_USE bool prepareForIndexPropValue();
+ [[nodiscard]] bool prepareForIndexPropValue();
// { [ key ]: value }
// ^
// |
// keyPos
- MOZ_MUST_USE bool prepareForComputedPropKey(
+ [[nodiscard]] bool prepareForComputedPropKey(
const mozilla::Maybe<uint32_t>& keyPos, Kind kind = Kind::Prototype);
- MOZ_MUST_USE bool prepareForComputedPropValue();
+ [[nodiscard]] bool prepareForComputedPropValue();
- MOZ_MUST_USE bool emitInitHomeObject(
+ [[nodiscard]] bool emitInitHomeObject(
FunctionAsyncKind kind = FunctionAsyncKind::SyncFunction);
// @param key
@@ -256,24 +256,24 @@ class MOZ_STACK_CLASS PropertyEmitter
// an anonymous class
// @param anonFunction
// The anonymous function object for property value
- MOZ_MUST_USE bool emitInitProp(
+ [[nodiscard]] bool emitInitProp(
JS::Handle<JSAtom*> key, bool isPropertyAnonFunctionOrClass = false,
JS::Handle<JSFunction*> anonFunction = nullptr);
- MOZ_MUST_USE bool emitInitGetter(JS::Handle<JSAtom*> key);
- MOZ_MUST_USE bool emitInitSetter(JS::Handle<JSAtom*> key);
+ [[nodiscard]] bool emitInitGetter(JS::Handle<JSAtom*> key);
+ [[nodiscard]] bool emitInitSetter(JS::Handle<JSAtom*> key);
- MOZ_MUST_USE bool emitInitIndexProp(
+ [[nodiscard]] bool emitInitIndexProp(
bool isPropertyAnonFunctionOrClass = false);
- MOZ_MUST_USE bool emitInitIndexGetter();
- MOZ_MUST_USE bool emitInitIndexSetter();
+ [[nodiscard]] bool emitInitIndexGetter();
+ [[nodiscard]] bool emitInitIndexSetter();
- MOZ_MUST_USE bool emitInitComputedProp(
+ [[nodiscard]] bool emitInitComputedProp(
bool isPropertyAnonFunctionOrClass = false);
- MOZ_MUST_USE bool emitInitComputedGetter();
- MOZ_MUST_USE bool emitInitComputedSetter();
+ [[nodiscard]] bool emitInitComputedGetter();
+ [[nodiscard]] bool emitInitComputedSetter();
private:
- MOZ_MUST_USE MOZ_ALWAYS_INLINE bool prepareForProp(
+ [[nodiscard]] MOZ_ALWAYS_INLINE bool prepareForProp(
const mozilla::Maybe<uint32_t>& keyPos, bool isStatic, bool isComputed);
// @param op
@@ -287,14 +287,14 @@ class MOZ_STACK_CLASS PropertyEmitter
// anonymous class
// @param anonFunction
// Anonymous function object for the property
- MOZ_MUST_USE bool emitInit(JSOp op, JS::Handle<JSAtom*> key,
+ [[nodiscard]] bool emitInit(JSOp op, JS::Handle<JSAtom*> key,
bool isPropertyAnonFunctionOrClass,
JS::Handle<JSFunction*> anonFunction);
- MOZ_MUST_USE bool emitInitIndexOrComputed(JSOp op,
+ [[nodiscard]] bool emitInitIndexOrComputed(JSOp op,
FunctionPrefixKind prefixKind,
bool isPropertyAnonFunctionOrClass);
- MOZ_MUST_USE bool emitPopClassConstructor();
+ [[nodiscard]] bool emitPopClassConstructor();
};
// Class for emitting bytecode for object literal.
@@ -439,8 +439,8 @@ class MOZ_STACK_CLASS ObjectEmitter : public PropertyEmitter
public:
explicit ObjectEmitter(BytecodeEmitter* bce);
- MOZ_MUST_USE bool emitObject(size_t propertyCount);
- MOZ_MUST_USE bool emitEnd();
+ [[nodiscard]] bool emitObject(size_t propertyCount);
+ [[nodiscard]] bool emitEnd();
};
// Save and restore the strictness.
@@ -813,16 +813,16 @@ class MOZ_STACK_CLASS ClassEmitter : public PropertyEmitter
public:
explicit ClassEmitter(BytecodeEmitter* bce);
- MOZ_MUST_USE bool emitScope(JS::Handle<LexicalScope::Data*> scopeBindings);
+ [[nodiscard]] bool emitScope(JS::Handle<LexicalScope::Data*> scopeBindings);
// @param name
// Name of the class (nullptr if this is anonymous class)
- MOZ_MUST_USE bool emitClass(JS::Handle<JSAtom*> name);
- MOZ_MUST_USE bool emitDerivedClass(JS::Handle<JSAtom*> name);
+ [[nodiscard]] bool emitClass(JS::Handle<JSAtom*> name);
+ [[nodiscard]] bool emitDerivedClass(JS::Handle<JSAtom*> name);
// @param needsHomeObject
// True if the constructor contains `super.foo`
- MOZ_MUST_USE bool emitInitConstructor(bool needsHomeObject);
+ [[nodiscard]] bool emitInitConstructor(bool needsHomeObject);
// Parameters are the offset in the source code for each character below:
//
@@ -833,23 +833,23 @@ class MOZ_STACK_CLASS ClassEmitter : public PropertyEmitter
// |
// classStart
//
- MOZ_MUST_USE bool emitInitDefaultConstructor(
+ [[nodiscard]] bool emitInitDefaultConstructor(
const mozilla::Maybe<uint32_t>& classStart,
const mozilla::Maybe<uint32_t>& classEnd);
- MOZ_MUST_USE bool prepareForFieldInitializers(size_t numFields, bool isStatic);
- MOZ_MUST_USE bool prepareForFieldInitializer();
- MOZ_MUST_USE bool emitFieldInitializerHomeObject(bool isStatic);
- MOZ_MUST_USE bool emitStoreFieldInitializer();
- MOZ_MUST_USE bool emitFieldInitializersEnd();
+ [[nodiscard]] bool prepareForFieldInitializers(size_t numFields, bool isStatic);
+ [[nodiscard]] bool prepareForFieldInitializer();
+ [[nodiscard]] bool emitFieldInitializerHomeObject(bool isStatic);
+ [[nodiscard]] bool emitStoreFieldInitializer();
+ [[nodiscard]] bool emitFieldInitializersEnd();
- MOZ_MUST_USE bool emitBinding();
+ [[nodiscard]] bool emitBinding();
- MOZ_MUST_USE bool emitEnd(Kind kind);
+ [[nodiscard]] bool emitEnd(Kind kind);
private:
void setName(JS::Handle<JSAtom*> name);
- MOZ_MUST_USE bool initProtoAndCtor();
+ [[nodiscard]] bool initProtoAndCtor();
};
} /* namespace frontend */
diff --git a/js/src/frontend/ParseNode.h b/js/src/frontend/ParseNode.h
index 439a6d8937..02731847e7 100644
--- a/js/src/frontend/ParseNode.h
+++ b/js/src/frontend/ParseNode.h
@@ -878,7 +878,7 @@ class ParseNode
ForCopyOnWriteArray
};
- MOZ_MUST_USE bool getConstantValue(ExclusiveContext* cx, AllowConstantObjects allowObjects,
+ [[nodiscard]] bool getConstantValue(ExclusiveContext* cx, AllowConstantObjects allowObjects,
MutableHandleValue vp, Value* compare = nullptr,
size_t ncompare = 0, NewObjectKind newKind = TenuredObject);
inline bool isConstant();
@@ -1258,17 +1258,17 @@ class ListNode : public ParseNode
return count() == 0;
}
- MOZ_MUST_USE bool hasTopLevelFunctionDeclarations() const {
+ [[nodiscard]] bool hasTopLevelFunctionDeclarations() const {
MOZ_ASSERT(isKind(PNK_STATEMENTLIST));
return pn_u.list.xflags & hasTopLevelFunctionDeclarationsBit;
}
- MOZ_MUST_USE bool hasArrayHoleOrSpread() const {
+ [[nodiscard]] bool hasArrayHoleOrSpread() const {
MOZ_ASSERT(isKind(PNK_ARRAY));
return pn_u.list.xflags & hasArrayHoleOrSpreadBit;
}
- MOZ_MUST_USE bool hasNonConstInitializer() const {
+ [[nodiscard]] bool hasNonConstInitializer() const {
MOZ_ASSERT(isKind(PNK_ARRAY) ||
isKind(PNK_OBJECT) ||
isKind(PNK_CLASSMEMBERLIST));
@@ -1463,7 +1463,7 @@ class ListNode : public ParseNode
typedef std::function<bool(ParseNode*)> predicate_fun;
#ifdef DEBUG
- MOZ_MUST_USE bool contains(ParseNode* target) const {
+ [[nodiscard]] bool contains(ParseNode* target) const {
MOZ_ASSERT(target);
for (ParseNode* node : contents()) {
if (target == node) {
@@ -2146,7 +2146,7 @@ class CallSiteNode : public ListNode
return match;
}
- MOZ_MUST_USE bool getRawArrayValue(ExclusiveContext* cx, MutableHandleValue vp) {
+ [[nodiscard]] bool getRawArrayValue(ExclusiveContext* cx, MutableHandleValue vp) {
return head()->getConstantValue(cx, AllowObjects, vp);
}
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index 4e3181e06b..96b83f7c48 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -1721,7 +1721,7 @@ NewEmptyBindingData(ExclusiveContext* cx, LifoAlloc& alloc, uint32_t numBindings
* Copy-construct |BindingName|s from |bindings| into |cursor|, then return
* the location one past the newly-constructed |BindingName|s.
*/
-static MOZ_MUST_USE BindingName*
+[[nodiscard]] static BindingName*
FreshlyInitializeBindings(BindingName* cursor, const Vector<BindingName>& bindings)
{
for (const BindingName& binding : bindings)
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
index 4a8e038d6e..f6a304f447 100644
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -140,7 +140,7 @@ class ParseContext : public Nestable<ParseContext>
return id_;
}
- MOZ_MUST_USE bool init(ParseContext* pc) {
+ [[nodiscard]] bool init(ParseContext* pc) {
if (id_ == UINT32_MAX) {
pc->tokenStream_.reportError(JSMSG_NEED_DIET, js_script_str);
return false;
@@ -157,7 +157,7 @@ class ParseContext : public Nestable<ParseContext>
return declared_->lookupForAdd(name);
}
- MOZ_MUST_USE bool addDeclaredName(ParseContext* pc, AddDeclaredNamePtr& p, JSAtom* name,
+ [[nodiscard]] bool addDeclaredName(ParseContext* pc, AddDeclaredNamePtr& p, JSAtom* name,
DeclarationKind kind, uint32_t pos)
{
return maybeReportOOM(pc, declared_->add(p, name, DeclaredNameInfo(kind, pos)));
@@ -379,7 +379,7 @@ class ParseContext : public Nestable<ParseContext>
~ParseContext();
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
SharedContext* sc() {
return sc_;
@@ -446,7 +446,7 @@ class ParseContext : public Nestable<ParseContext>
return *closedOverBindingsForLazy_;
}
- MOZ_MUST_USE bool addInnerFunctionBoxForAnnexB(FunctionBox* funbox);
+ [[nodiscard]] bool addInnerFunctionBoxForAnnexB(FunctionBox* funbox);
void removeInnerFunctionBoxesForAnnexB(JSAtom* name);
void finishInnerFunctionBoxesForAnnexB();
@@ -703,7 +703,7 @@ class UsedNameTracker
scopeCounter_(0)
{ }
- MOZ_MUST_USE bool init() {
+ [[nodiscard]] bool init() {
return map_.init();
}
@@ -722,10 +722,10 @@ class UsedNameTracker
return map_.lookup(name);
}
- MOZ_MUST_USE bool noteUse(ExclusiveContext* cx, JSAtom* name,
+ [[nodiscard]] bool noteUse(ExclusiveContext* cx, JSAtom* name,
uint32_t scriptId, uint32_t scopeId);
- MOZ_MUST_USE bool markAsAlwaysClosedOver(ExclusiveContext* cx, JSAtom* name,
+ [[nodiscard]] bool markAsAlwaysClosedOver(ExclusiveContext* cx, JSAtom* name,
uint32_t scriptId, uint32_t scopeId) {
// This marks a variable as always closed over:
// UsedNameInfo::noteBoundInScope only checks if scriptId and scopeId are
@@ -883,32 +883,32 @@ class ParserBase : public StrictModeGetter
* strict mode code, or warn if not, using the given error number and
* arguments.
*/
- MOZ_MUST_USE bool strictModeError(unsigned errorNumber, ...);
+ [[nodiscard]] bool strictModeError(unsigned errorNumber, ...);
/*
* Handle a strict mode error at the given offset. Report an error if in
* strict mode code, or warn if not, using the given error number and
* arguments.
*/
- MOZ_MUST_USE bool strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...);
+ [[nodiscard]] bool strictModeErrorAt(uint32_t offset, unsigned errorNumber, ...);
/* Report the given warning at the current offset. */
- MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
+ [[nodiscard]] bool warning(unsigned errorNumber, ...);
/* Report the given warning at the given offset. */
- MOZ_MUST_USE bool warningAt(uint32_t offset, unsigned errorNumber, ...);
+ [[nodiscard]] bool warningAt(uint32_t offset, unsigned errorNumber, ...);
/*
* If extra warnings are enabled, report the given warning at the current
* offset.
*/
- MOZ_MUST_USE bool extraWarning(unsigned errorNumber, ...);
+ [[nodiscard]] bool extraWarning(unsigned errorNumber, ...);
/*
* If extra warnings are enabled, report the given warning at the given
* offset.
*/
- MOZ_MUST_USE bool extraWarningAt(uint32_t offset, unsigned errorNumber, ...);
+ [[nodiscard]] bool extraWarningAt(uint32_t offset, unsigned errorNumber, ...);
bool isValidStrictBinding(PropertyName* name);
@@ -1020,11 +1020,11 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
// If there is a pending error, report it and return false, otherwise
// return true.
- MOZ_MUST_USE bool checkForError(ErrorKind kind);
+ [[nodiscard]] bool checkForError(ErrorKind kind);
// If there is a pending warning, report it and return either false or
// true depending on the werror option, otherwise return true.
- MOZ_MUST_USE bool checkForWarning(ErrorKind kind);
+ [[nodiscard]] bool checkForWarning(ErrorKind kind);
// Transfer an existing error to another instance.
void transferErrorTo(ErrorKind kind, PossibleError* other);
@@ -1053,12 +1053,12 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
// If there is a pending destructuring error or warning, report it and
// return false, otherwise return true. Clears any pending expression
// error.
- MOZ_MUST_USE bool checkForDestructuringErrorOrWarning();
+ [[nodiscard]] bool checkForDestructuringErrorOrWarning();
// If there is a pending expression error, report it and return false,
// otherwise return true. Clears any pending destructuring error or
// warning.
- MOZ_MUST_USE bool checkForExpressionError();
+ [[nodiscard]] bool checkForExpressionError();
// Pass pending errors between possible error instances. This is useful
// for extending the lifetime of a pending error beyond the scope of
@@ -1127,7 +1127,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
* the signature of `errorReport` is [...](TokenKind actual).
*/
template<typename ConditionT, typename ErrorReportT>
- MOZ_MUST_USE bool mustMatchTokenInternal(ConditionT condition, Modifier modifier,
+ [[nodiscard]] bool mustMatchTokenInternal(ConditionT condition, Modifier modifier,
ErrorReportT errorReport);
public:
@@ -1141,7 +1141,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
* If error number is passed instead of `errorReport`, it reports an
* error with the passed errorNumber.
*/
- MOZ_MUST_USE bool mustMatchToken(TokenKind expected, Modifier modifier, JSErrNum errorNumber) {
+ [[nodiscard]] bool mustMatchToken(TokenKind expected, Modifier modifier, JSErrNum errorNumber) {
return mustMatchTokenInternal([expected](TokenKind actual) {
return actual == expected;
},
@@ -1151,12 +1151,12 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
});
}
- MOZ_MUST_USE bool mustMatchToken(TokenKind excpected, JSErrNum errorNumber) {
+ [[nodiscard]] bool mustMatchToken(TokenKind excpected, JSErrNum errorNumber) {
return mustMatchToken(excpected, TokenStream::None, errorNumber);
}
template<typename ConditionT>
- MOZ_MUST_USE bool mustMatchToken(ConditionT condition, JSErrNum errorNumber) {
+ [[nodiscard]] bool mustMatchToken(ConditionT condition, JSErrNum errorNumber) {
return mustMatchTokenInternal(condition, TokenStream::None,
[this, errorNumber](TokenKind) {
this->error(errorNumber);
@@ -1164,7 +1164,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
}
template<typename ErrorReportT>
- MOZ_MUST_USE bool mustMatchToken(TokenKind expected, Modifier modifier,
+ [[nodiscard]] bool mustMatchToken(TokenKind expected, Modifier modifier,
ErrorReportT errorReport) {
return mustMatchTokenInternal([expected](TokenKind actual) {
return actual == expected;
@@ -1173,7 +1173,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
}
template<typename ErrorReportT>
- MOZ_MUST_USE bool mustMatchToken(TokenKind expected, ErrorReportT errorReport) {
+ [[nodiscard]] bool mustMatchToken(TokenKind expected, ErrorReportT errorReport) {
return mustMatchToken(expected, TokenStream::None, errorReport);
}
@@ -1519,13 +1519,13 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
// The number of static class fields with computed property names.
size_t staticFieldKeys = 0;
};
- MOZ_MUST_USE bool classMember(YieldHandling yieldHandling,
+ [[nodiscard]] bool classMember(YieldHandling yieldHandling,
const ParseContext::ClassStatement& classStmt,
HandlePropertyName className,
uint32_t classStartOffset, bool hasHeritage,
ClassFields& classFields,
ListNodeType& classMembers, bool* done);
- MOZ_MUST_USE bool finishClassConstructor(
+ [[nodiscard]] bool finishClassConstructor(
const ParseContext::ClassStatement& classStmt,
HandlePropertyName className, bool hasHeritage,
uint32_t classStartOffset, uint32_t classEndOffset,
diff --git a/js/src/frontend/PropOpEmitter.h b/js/src/frontend/PropOpEmitter.h
index 6c56a59f25..eb925c4f56 100644
--- a/js/src/frontend/PropOpEmitter.h
+++ b/js/src/frontend/PropOpEmitter.h
@@ -206,66 +206,66 @@ class MOZ_STACK_CLASS PropOpEmitter
PropOpEmitter(BytecodeEmitter* bce, Kind kind, ObjKind objKind);
private:
- MOZ_MUST_USE bool isCall() const {
+ [[nodiscard]] bool isCall() const {
return kind_ == Kind::Call;
}
- MOZ_MUST_USE bool isSuper() const {
+ [[nodiscard]] bool isSuper() const {
return objKind_ == ObjKind::Super;
}
- MOZ_MUST_USE bool isSimpleAssignment() const {
+ [[nodiscard]] bool isSimpleAssignment() const {
return kind_ == Kind::SimpleAssignment;
}
- MOZ_MUST_USE bool isPropInit() const {
+ [[nodiscard]] bool isPropInit() const {
return kind_ == Kind::PropInit;
}
- MOZ_MUST_USE bool isDelete() const {
+ [[nodiscard]] bool isDelete() const {
return kind_ == Kind::Delete;
}
- MOZ_MUST_USE bool isCompoundAssignment() const {
+ [[nodiscard]] bool isCompoundAssignment() const {
return kind_ == Kind::CompoundAssignment;
}
- MOZ_MUST_USE bool isIncDec() const {
+ [[nodiscard]] bool isIncDec() const {
return isPostIncDec() || isPreIncDec();
}
- MOZ_MUST_USE bool isPostIncDec() const {
+ [[nodiscard]] bool isPostIncDec() const {
return kind_ == Kind::PostIncrement ||
kind_ == Kind::PostDecrement;
}
- MOZ_MUST_USE bool isPreIncDec() const {
+ [[nodiscard]] bool isPreIncDec() const {
return kind_ == Kind::PreIncrement ||
kind_ == Kind::PreDecrement;
}
- MOZ_MUST_USE bool isInc() const {
+ [[nodiscard]] bool isInc() const {
return kind_ == Kind::PostIncrement ||
kind_ == Kind::PreIncrement;
}
- MOZ_MUST_USE bool
+ [[nodiscard]] bool
prepareAtomIndex(JSAtom* prop);
public:
- MOZ_MUST_USE bool prepareForObj();
+ [[nodiscard]] bool prepareForObj();
- MOZ_MUST_USE bool emitGet(JSAtom* prop);
+ [[nodiscard]] bool emitGet(JSAtom* prop);
- MOZ_MUST_USE bool prepareForRhs();
- MOZ_MUST_USE bool skipObjAndRhs();
+ [[nodiscard]] bool prepareForRhs();
+ [[nodiscard]] bool skipObjAndRhs();
- MOZ_MUST_USE bool emitDelete(JSAtom* prop);
+ [[nodiscard]] bool emitDelete(JSAtom* prop);
// `prop` can be nullptr for CompoundAssignment.
- MOZ_MUST_USE bool emitAssignment(JSAtom* prop);
+ [[nodiscard]] bool emitAssignment(JSAtom* prop);
- MOZ_MUST_USE bool emitIncDec(JSAtom* prop);
+ [[nodiscard]] bool emitIncDec(JSAtom* prop);
};
} /* namespace frontend */
diff --git a/js/src/frontend/SwitchEmitter.h b/js/src/frontend/SwitchEmitter.h
index 31dab1eb31..e4b916ffc1 100644
--- a/js/src/frontend/SwitchEmitter.h
+++ b/js/src/frontend/SwitchEmitter.h
@@ -256,16 +256,16 @@ class MOZ_STACK_CLASS SwitchEmitter
void setInvalid() {
valid_ = false;
}
- MOZ_MUST_USE bool isValid() const {
+ [[nodiscard]] bool isValid() const {
return valid_;
}
- MOZ_MUST_USE bool isInvalid() const {
+ [[nodiscard]] bool isInvalid() const {
return !valid_;
}
// Add the given number to the table. The number is the value of
// `expr` for `case expr:` syntax.
- MOZ_MUST_USE bool addNumber(int32_t caseValue);
+ [[nodiscard]] bool addNumber(int32_t caseValue);
// Finish generating the table.
// `caseCount` should be the number of cases in the switch statement,
@@ -438,29 +438,29 @@ class MOZ_STACK_CLASS SwitchEmitter
// switchPos
//
// Can be Nothing() if not available.
- MOZ_MUST_USE bool emitDiscriminant(const mozilla::Maybe<uint32_t>& switchPos);
+ [[nodiscard]] bool emitDiscriminant(const mozilla::Maybe<uint32_t>& switchPos);
// `caseCount` should be the number of cases in the switch statement,
// excluding the default case.
- MOZ_MUST_USE bool validateCaseCount(uint32_t caseCount);
+ [[nodiscard]] bool validateCaseCount(uint32_t caseCount);
// `bindings` is a lexical scope for the entire switch, in case there's
// let/const effectively directly under case or default blocks.
- MOZ_MUST_USE bool emitLexical(Handle<LexicalScope::Data*> bindings);
+ [[nodiscard]] bool emitLexical(Handle<LexicalScope::Data*> bindings);
- MOZ_MUST_USE bool emitCond();
- MOZ_MUST_USE bool emitTable(const TableGenerator& tableGen);
+ [[nodiscard]] bool emitCond();
+ [[nodiscard]] bool emitTable(const TableGenerator& tableGen);
- MOZ_MUST_USE bool emitCaseJump();
+ [[nodiscard]] bool emitCaseJump();
- MOZ_MUST_USE bool emitCaseBody();
- MOZ_MUST_USE bool emitCaseBody(int32_t caseValue, const TableGenerator& tableGen);
- MOZ_MUST_USE bool emitDefaultBody();
- MOZ_MUST_USE bool emitEnd();
+ [[nodiscard]] bool emitCaseBody();
+ [[nodiscard]] bool emitCaseBody(int32_t caseValue, const TableGenerator& tableGen);
+ [[nodiscard]] bool emitDefaultBody();
+ [[nodiscard]] bool emitEnd();
private:
- MOZ_MUST_USE bool emitCaseOrDefaultJump(uint32_t caseIndex, bool isDefault);
- MOZ_MUST_USE bool emitImplicitDefault();
+ [[nodiscard]] bool emitCaseOrDefaultJump(uint32_t caseIndex, bool isDefault);
+ [[nodiscard]] bool emitImplicitDefault();
};
} /* namespace frontend */
diff --git a/js/src/frontend/SyntaxParseHandler.h b/js/src/frontend/SyntaxParseHandler.h
index 80ca13ce45..f0c4c5b360 100644
--- a/js/src/frontend/SyntaxParseHandler.h
+++ b/js/src/frontend/SyntaxParseHandler.h
@@ -306,8 +306,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
// Expressions
ListNodeType newArrayLiteral(uint32_t begin) { return NodeUnparenthesizedArray; }
- MOZ_MUST_USE bool addElision(ListNodeType literal, const TokenPos& pos) { return true; }
- MOZ_MUST_USE bool addSpreadElement(ListNodeType literal, uint32_t begin, Node inner) { return true; }
+ [[nodiscard]] bool addElision(ListNodeType literal, const TokenPos& pos) { return true; }
+ [[nodiscard]] bool addSpreadElement(ListNodeType literal, uint32_t begin, Node inner) { return true; }
void addArrayElement(ListNodeType literal, Node element) { }
BinaryNodeType newCall(Node callee, Node args) { return NodeFunctionCall; }
@@ -332,15 +332,15 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
NullaryNodeType newPosHolder(const TokenPos& pos) { return NodeGeneric; }
UnaryNodeType newSuperBase(Node thisName, const TokenPos& pos) { return NodeSuperBase; }
- MOZ_MUST_USE bool addPrototypeMutation(ListNodeType literal, uint32_t begin, Node expr) { return true; }
- MOZ_MUST_USE bool addPropertyDefinition(ListNodeType literal, Node name, Node expr) { return true; }
- MOZ_MUST_USE bool addShorthand(ListNodeType literal, NameNodeType name, NameNodeType expr) { return true; }
- MOZ_MUST_USE bool addSpreadProperty(ListNodeType literal, uint32_t begin, Node inner) { return true; }
- MOZ_MUST_USE bool addObjectMethodDefinition(ListNodeType literal, Node name, FunctionNodeType funNode, JSOp op) { return true; }
- MOZ_MUST_USE Node newClassMethodDefinition(Node key, FunctionNodeType funNode, JSOp op, bool isStatic) { return NodeGeneric; }
- MOZ_MUST_USE Node newClassFieldDefinition(Node name, FunctionNodeType initializer, bool isStatic) { return NodeGeneric; }
- MOZ_MUST_USE Node newStaticClassBlock(FunctionNodeType block) { return NodeGeneric; }
- MOZ_MUST_USE bool addClassMemberDefinition(ListNodeType memberList, Node member) { return true; }
+ [[nodiscard]] bool addPrototypeMutation(ListNodeType literal, uint32_t begin, Node expr) { return true; }
+ [[nodiscard]] bool addPropertyDefinition(ListNodeType literal, Node name, Node expr) { return true; }
+ [[nodiscard]] bool addShorthand(ListNodeType literal, NameNodeType name, NameNodeType expr) { return true; }
+ [[nodiscard]] bool addSpreadProperty(ListNodeType literal, uint32_t begin, Node inner) { return true; }
+ [[nodiscard]] bool addObjectMethodDefinition(ListNodeType literal, Node name, FunctionNodeType funNode, JSOp op) { return true; }
+ [[nodiscard]] Node newClassMethodDefinition(Node key, FunctionNodeType funNode, JSOp op, bool isStatic) { return NodeGeneric; }
+ [[nodiscard]] Node newClassFieldDefinition(Node name, FunctionNodeType initializer, bool isStatic) { return NodeGeneric; }
+ [[nodiscard]] Node newStaticClassBlock(FunctionNodeType block) { return NodeGeneric; }
+ [[nodiscard]] bool addClassMemberDefinition(ListNodeType memberList, Node member) { return true; }
UnaryNodeType newYieldExpression(uint32_t begin, Node value) { return NodeGeneric; }
UnaryNodeType newYieldStarExpression(uint32_t begin, Node value) { return NodeGeneric; }
UnaryNodeType newAwaitExpression(uint32_t begin, Node value) { return NodeGeneric; }
@@ -351,7 +351,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
ListNodeType newStatementList(const TokenPos& pos) { return NodeGeneric; }
void addStatementToList(ListNodeType list, Node stmt) {}
void addCaseStatementToList(ListNodeType list, CaseClauseType caseClause) {}
- MOZ_MUST_USE bool prependInitialYield(ListNodeType stmtList, Node genName) { return true; }
+ [[nodiscard]] bool prependInitialYield(ListNodeType stmtList, Node genName) { return true; }
UnaryNodeType newEmptyStatement(const TokenPos& pos) { return NodeEmptyStatement; }
UnaryNodeType newExportDeclaration(Node kid, const TokenPos& pos) {
@@ -419,10 +419,10 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
Node newOptionalPropertyByValue(Node pn, Node kid, uint32_t end) { return NodeOptionalElement; }
- MOZ_MUST_USE bool addCatchBlock(ListNodeType catchList, LexicalScopeNodeType lexicalScope,
+ [[nodiscard]] bool addCatchBlock(ListNodeType catchList, LexicalScopeNodeType lexicalScope,
Node catchBinding, Node catchGuard, Node catchBody) { return true; }
- MOZ_MUST_USE bool setLastFunctionFormalParameterDefault(FunctionNodeType funNode, Node pn) { return true; }
+ [[nodiscard]] bool setLastFunctionFormalParameterDefault(FunctionNodeType funNode, Node pn) { return true; }
void checkAndSetIsDirectRHSAnonFunction(Node pn) {}
@@ -458,7 +458,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return NodeGeneric;
}
- MOZ_MUST_USE bool finishInitializerAssignment(NameNodeType nameNode, Node init) { return true; }
+ [[nodiscard]] bool finishInitializerAssignment(NameNodeType nameNode, Node init) { return true; }
void setBeginPosition(Node pn, Node oth) {}
void setBeginPosition(Node pn, uint32_t begin) {}
@@ -577,7 +577,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
void setOp(Node pn, JSOp op) {}
void setListHasNonConstInitializer(ListNodeType literal) {}
- MOZ_MUST_USE Node parenthesize(Node node) {
+ [[nodiscard]] Node parenthesize(Node node) {
// A number of nodes have different behavior upon parenthesization, but
// only in some circumstances. Convert these nodes to special
// parenthesized forms.
@@ -608,7 +608,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
return node;
}
template <typename NodeType>
- MOZ_MUST_USE NodeType setLikelyIIFE(NodeType node) {
+ [[nodiscard]] NodeType setLikelyIIFE(NodeType node) {
return node; // Remain in syntax-parse mode.
}
void setInDirectivePrologue(UnaryNodeType exprStmt) {}
diff --git a/js/src/frontend/TDZCheckCache.h b/js/src/frontend/TDZCheckCache.h
index 0de53ae1e5..ffc4812da8 100644
--- a/js/src/frontend/TDZCheckCache.h
+++ b/js/src/frontend/TDZCheckCache.h
@@ -39,13 +39,13 @@ class TDZCheckCache : public Nestable<TDZCheckCache>
{
PooledMapPtr<CheckTDZMap> cache_;
- MOZ_MUST_USE bool ensureCache(BytecodeEmitter* bce);
+ [[nodiscard]] bool ensureCache(BytecodeEmitter* bce);
public:
explicit TDZCheckCache(BytecodeEmitter* bce);
mozilla::Maybe<MaybeCheckTDZ> needsTDZCheck(BytecodeEmitter* bce, JSAtom* name);
- MOZ_MUST_USE bool noteTDZCheck(BytecodeEmitter* bce, JSAtom* name, MaybeCheckTDZ check);
+ [[nodiscard]] bool noteTDZCheck(BytecodeEmitter* bce, JSAtom* name, MaybeCheckTDZ check);
};
} /* namespace frontend */
diff --git a/js/src/frontend/TokenKind.h b/js/src/frontend/TokenKind.h
index 3e1ff68bbd..c1deb0b67b 100644
--- a/js/src/frontend/TokenKind.h
+++ b/js/src/frontend/TokenKind.h
@@ -283,7 +283,7 @@ TokenKindIsAssignment(TokenKind tt)
return TOK_ASSIGNMENT_START <= tt && tt <= TOK_ASSIGNMENT_LAST;
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsKeyword(TokenKind tt)
{
return (TOK_KEYWORD_FIRST <= tt && tt <= TOK_KEYWORD_LAST) ||
@@ -291,31 +291,31 @@ TokenKindIsKeyword(TokenKind tt)
(TOK_KEYWORD_UNOP_FIRST <= tt && tt <= TOK_KEYWORD_UNOP_LAST);
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsContextualKeyword(TokenKind tt)
{
return TOK_CONTEXTUAL_KEYWORD_FIRST <= tt && tt <= TOK_CONTEXTUAL_KEYWORD_LAST;
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsFutureReservedWord(TokenKind tt)
{
return TOK_FUTURE_RESERVED_KEYWORD_FIRST <= tt && tt <= TOK_FUTURE_RESERVED_KEYWORD_LAST;
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsStrictReservedWord(TokenKind tt)
{
return TOK_STRICT_RESERVED_KEYWORD_FIRST <= tt && tt <= TOK_STRICT_RESERVED_KEYWORD_LAST;
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsReservedWordLiteral(TokenKind tt)
{
return TOK_RESERVED_WORD_LITERAL_FIRST <= tt && tt <= TOK_RESERVED_WORD_LITERAL_LAST;
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsReservedWord(TokenKind tt)
{
return TokenKindIsKeyword(tt) ||
@@ -323,7 +323,7 @@ TokenKindIsReservedWord(TokenKind tt)
TokenKindIsReservedWordLiteral(tt);
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsPossibleIdentifier(TokenKind tt)
{
return tt == TOK_NAME ||
@@ -332,7 +332,7 @@ TokenKindIsPossibleIdentifier(TokenKind tt)
TokenKindIsStrictReservedWord(tt);
}
-inline MOZ_MUST_USE bool
+[[nodiscard]] inline bool
TokenKindIsPossibleIdentifierName(TokenKind tt)
{
return TokenKindIsPossibleIdentifier(tt) ||
diff --git a/js/src/frontend/TokenStream.h b/js/src/frontend/TokenStream.h
index e7a3f7b808..3a8053cc05 100644
--- a/js/src/frontend/TokenStream.h
+++ b/js/src/frontend/TokenStream.h
@@ -328,7 +328,7 @@ class MOZ_STACK_CLASS TokenStream
~TokenStream();
- MOZ_MUST_USE bool checkOptions();
+ [[nodiscard]] bool checkOptions();
// Accessors.
const Token& currentToken() const { return tokens[cursor]; }
@@ -411,7 +411,7 @@ class MOZ_STACK_CLASS TokenStream
void errorAt(uint32_t offset, unsigned errorNumber, ...);
// Warn at the current offset.
- MOZ_MUST_USE bool warning(unsigned errorNumber, ...);
+ [[nodiscard]] bool warning(unsigned errorNumber, ...);
static const uint32_t NoOffset = UINT32_MAX;
@@ -490,7 +490,7 @@ class MOZ_STACK_CLASS TokenStream
}
static JSAtom* atomize(ExclusiveContext* cx, CharBuffer& cb);
- MOZ_MUST_USE bool putIdentInTokenbuf(const char16_t* identStart);
+ [[nodiscard]] bool putIdentInTokenbuf(const char16_t* identStart);
struct Flags
{
@@ -586,7 +586,7 @@ class MOZ_STACK_CLASS TokenStream
// Advance to the next token. If the token stream encountered an error,
// return false. Otherwise return true and store the token kind in |*ttp|.
- MOZ_MUST_USE bool getToken(TokenKind* ttp, Modifier modifier = None) {
+ [[nodiscard]] bool getToken(TokenKind* ttp, Modifier modifier = None) {
// Check for a pushed-back token resulting from mismatching lookahead.
if (lookahead != 0) {
MOZ_ASSERT(!flags.hadError);
@@ -609,7 +609,7 @@ class MOZ_STACK_CLASS TokenStream
cursor = (cursor - 1) & ntokensMask;
}
- MOZ_MUST_USE bool peekToken(TokenKind* ttp, Modifier modifier = None) {
+ [[nodiscard]] bool peekToken(TokenKind* ttp, Modifier modifier = None) {
if (lookahead > 0) {
MOZ_ASSERT(!flags.hadError);
verifyConsistentModifier(modifier, nextToken());
@@ -622,7 +622,7 @@ class MOZ_STACK_CLASS TokenStream
return true;
}
- MOZ_MUST_USE bool peekTokenPos(TokenPos* posp, Modifier modifier = None) {
+ [[nodiscard]] bool peekTokenPos(TokenPos* posp, Modifier modifier = None) {
if (lookahead == 0) {
TokenKind tt;
if (!getTokenInternal(&tt, modifier))
@@ -637,7 +637,7 @@ class MOZ_STACK_CLASS TokenStream
return true;
}
- MOZ_MUST_USE bool peekOffset(uint32_t* offset, Modifier modifier = None) {
+ [[nodiscard]] bool peekOffset(uint32_t* offset, Modifier modifier = None) {
TokenPos pos;
if (!peekTokenPos(&pos, modifier))
return false;
@@ -651,7 +651,7 @@ class MOZ_STACK_CLASS TokenStream
// TOK_EOL is actually created, just a TOK_EOL TokenKind is returned, and
// currentToken() shouldn't be consulted. (This is the only place TOK_EOL
// is produced.)
- MOZ_ALWAYS_INLINE MOZ_MUST_USE bool
+ [[nodiscard]] MOZ_ALWAYS_INLINE bool
peekTokenSameLine(TokenKind* ttp, Modifier modifier = None) {
const Token& curr = currentToken();
@@ -692,7 +692,7 @@ class MOZ_STACK_CLASS TokenStream
}
// Get the next token from the stream if its kind is |tt|.
- MOZ_MUST_USE bool matchToken(bool* matchedp, TokenKind tt, Modifier modifier = None) {
+ [[nodiscard]] bool matchToken(bool* matchedp, TokenKind tt, Modifier modifier = None) {
TokenKind token;
if (!getToken(&token, modifier))
return false;
@@ -712,7 +712,7 @@ class MOZ_STACK_CLASS TokenStream
MOZ_ALWAYS_TRUE(matched);
}
- MOZ_MUST_USE bool nextTokenEndsExpr(bool* endsExpr) {
+ [[nodiscard]] bool nextTokenEndsExpr(bool* endsExpr) {
TokenKind tt;
if (!peekToken(&tt))
return false;
@@ -743,10 +743,10 @@ class MOZ_STACK_CLASS TokenStream
Token lookaheadTokens[maxLookahead];
};
- MOZ_MUST_USE bool advance(size_t position);
+ [[nodiscard]] bool advance(size_t position);
void tell(Position*);
void seek(const Position& pos);
- MOZ_MUST_USE bool seek(const Position& pos, const TokenStream& other);
+ [[nodiscard]] bool seek(const Position& pos, const TokenStream& other);
#ifdef DEBUG
inline bool debugHasNoLookahead() const {
return lookahead == 0;
@@ -830,8 +830,8 @@ class MOZ_STACK_CLASS TokenStream
public:
SourceCoords(ExclusiveContext* cx, uint32_t ln);
- MOZ_MUST_USE bool add(uint32_t lineNum, uint32_t lineStartOffset);
- MOZ_MUST_USE bool fill(const SourceCoords& other);
+ [[nodiscard]] bool add(uint32_t lineNum, uint32_t lineStartOffset);
+ [[nodiscard]] bool fill(const SourceCoords& other);
bool isOnThisLine(uint32_t offset, uint32_t lineNum, bool* onThisLine) const {
uint32_t lineIndex = lineNumToIndex(lineNum);
@@ -970,9 +970,9 @@ class MOZ_STACK_CLASS TokenStream
const char16_t* ptr; // next char to get
};
- MOZ_MUST_USE bool getTokenInternal(TokenKind* ttp, Modifier modifier);
+ [[nodiscard]] bool getTokenInternal(TokenKind* ttp, Modifier modifier);
- MOZ_MUST_USE bool getStringOrTemplateToken(int untilChar, Token** tp);
+ [[nodiscard]] bool getStringOrTemplateToken(int untilChar, Token** tp);
int32_t getChar();
int32_t getCharIgnoreEOL();
@@ -986,13 +986,13 @@ class MOZ_STACK_CLASS TokenStream
bool matchTrailForLeadSurrogate(char16_t lead, char16_t* trail, uint32_t* codePoint);
bool peekChars(int n, char16_t* cp);
- MOZ_MUST_USE bool getDirectives(bool isMultiline, bool shouldWarnDeprecated);
- MOZ_MUST_USE bool getDirective(bool isMultiline, bool shouldWarnDeprecated,
+ [[nodiscard]] bool getDirectives(bool isMultiline, bool shouldWarnDeprecated);
+ [[nodiscard]] bool getDirective(bool isMultiline, bool shouldWarnDeprecated,
const char* directive, uint8_t directiveLength,
const char* errorMsgPragma,
UniquePtr<char16_t[], JS::FreePolicy>* destination);
- MOZ_MUST_USE bool getDisplayURL(bool isMultiline, bool shouldWarnDeprecated);
- MOZ_MUST_USE bool getSourceMappingURL(bool isMultiline, bool shouldWarnDeprecated);
+ [[nodiscard]] bool getDisplayURL(bool isMultiline, bool shouldWarnDeprecated);
+ [[nodiscard]] bool getSourceMappingURL(bool isMultiline, bool shouldWarnDeprecated);
// |expect| cannot be an EOL char.
bool matchChar(int32_t expect) {
@@ -1006,7 +1006,7 @@ class MOZ_STACK_CLASS TokenStream
MOZ_ASSERT(c == expect);
}
- MOZ_MUST_USE bool peekChar(int32_t* c) {
+ [[nodiscard]] bool peekChar(int32_t* c) {
*c = getChar();
ungetChar(*c);
return true;
diff --git a/js/src/frontend/TryEmitter.h b/js/src/frontend/TryEmitter.h
index c852e3556d..58f9af5e57 100644
--- a/js/src/frontend/TryEmitter.h
+++ b/js/src/frontend/TryEmitter.h
@@ -95,19 +95,19 @@ class MOZ_STACK_CLASS TryEmitter
TryEmitter(BytecodeEmitter* bce, Kind kind,
ShouldUseRetVal retValKind = UseRetVal, ShouldUseControl controlKind = UseControl);
- MOZ_MUST_USE bool emitJumpOverCatchAndFinally();
+ [[nodiscard]] bool emitJumpOverCatchAndFinally();
- MOZ_MUST_USE bool emitTry();
- MOZ_MUST_USE bool emitCatch();
+ [[nodiscard]] bool emitTry();
+ [[nodiscard]] bool emitCatch();
- MOZ_MUST_USE bool emitFinally(const mozilla::Maybe<uint32_t>& finallyPos = mozilla::Nothing());
+ [[nodiscard]] bool emitFinally(const mozilla::Maybe<uint32_t>& finallyPos = mozilla::Nothing());
- MOZ_MUST_USE bool emitEnd();
+ [[nodiscard]] bool emitEnd();
private:
- MOZ_MUST_USE bool emitTryEnd();
- MOZ_MUST_USE bool emitCatchEnd(bool hasNext);
- MOZ_MUST_USE bool emitFinallyEnd();
+ [[nodiscard]] bool emitTryEnd();
+ [[nodiscard]] bool emitCatchEnd(bool hasNext);
+ [[nodiscard]] bool emitFinallyEnd();
};
} /* namespace frontend */
diff --git a/js/src/gc/GCRuntime.h b/js/src/gc/GCRuntime.h
index cf2f7b036a..a7080bac94 100644
--- a/js/src/gc/GCRuntime.h
+++ b/js/src/gc/GCRuntime.h
@@ -217,7 +217,7 @@ class GCSchedulingTunables
unsigned minEmptyChunkCount(const AutoLockGC&) const { return minEmptyChunkCount_; }
unsigned maxEmptyChunkCount() const { return maxEmptyChunkCount_; }
- MOZ_MUST_USE bool setParameter(JSGCParamKey key, uint32_t value, const AutoLockGC& lock);
+ [[nodiscard]] bool setParameter(JSGCParamKey key, uint32_t value, const AutoLockGC& lock);
};
/*
@@ -599,18 +599,18 @@ class GCRuntime
{
public:
explicit GCRuntime(JSRuntime* rt);
- MOZ_MUST_USE bool init(uint32_t maxbytes, uint32_t maxNurseryBytes);
+ [[nodiscard]] bool init(uint32_t maxbytes, uint32_t maxNurseryBytes);
void finishRoots();
void finish();
- MOZ_MUST_USE bool addRoot(Value* vp, const char* name);
+ [[nodiscard]] bool addRoot(Value* vp, const char* name);
void removeRoot(Value* vp);
void setMarkStackLimit(size_t limit, AutoLockGC& lock);
- MOZ_MUST_USE bool setParameter(JSGCParamKey key, uint32_t value, AutoLockGC& lock);
+ [[nodiscard]] bool setParameter(JSGCParamKey key, uint32_t value, AutoLockGC& lock);
uint32_t getParameter(JSGCParamKey key, const AutoLockGC& lock);
- MOZ_MUST_USE bool triggerGC(JS::gcreason::Reason reason);
+ [[nodiscard]] bool triggerGC(JS::gcreason::Reason reason);
void maybeAllocTriggerZoneGC(Zone* zone, const AutoLockGC& lock);
// The return value indicates if we were able to do the GC.
bool triggerZoneGC(Zone* zone, JS::gcreason::Reason reason);
@@ -746,7 +746,7 @@ class GCRuntime
static bool initializeSweepActions();
void setGrayRootsTracer(JSTraceDataOp traceOp, void* data);
- MOZ_MUST_USE bool addBlackRootsTracer(JSTraceDataOp traceOp, void* data);
+ [[nodiscard]] bool addBlackRootsTracer(JSTraceDataOp traceOp, void* data);
void removeBlackRootsTracer(JSTraceDataOp traceOp, void* data);
void setMaxMallocBytes(size_t value);
@@ -763,12 +763,12 @@ class GCRuntime
void setObjectsTenuredCallback(JSObjectsTenuredCallback callback,
void* data);
void callObjectsTenuredCallback();
- MOZ_MUST_USE bool addFinalizeCallback(JSFinalizeCallback callback, void* data);
+ [[nodiscard]] bool addFinalizeCallback(JSFinalizeCallback callback, void* data);
void removeFinalizeCallback(JSFinalizeCallback func);
- MOZ_MUST_USE bool addWeakPointerZoneGroupCallback(JSWeakPointerZoneGroupCallback callback,
+ [[nodiscard]] bool addWeakPointerZoneGroupCallback(JSWeakPointerZoneGroupCallback callback,
void* data);
void removeWeakPointerZoneGroupCallback(JSWeakPointerZoneGroupCallback callback);
- MOZ_MUST_USE bool addWeakPointerCompartmentCallback(JSWeakPointerCompartmentCallback callback,
+ [[nodiscard]] bool addWeakPointerCompartmentCallback(JSWeakPointerCompartmentCallback callback,
void* data);
void removeWeakPointerCompartmentCallback(JSWeakPointerCompartmentCallback callback);
JS::GCSliceCallback setSliceCallback(JS::GCSliceCallback callback);
@@ -859,7 +859,7 @@ class GCRuntime
// Allocator
template <AllowGC allowGC>
- MOZ_MUST_USE bool checkAllocatorState(JSContext* cx, AllocKind kind);
+ [[nodiscard]] bool checkAllocatorState(JSContext* cx, AllocKind kind);
template <AllowGC allowGC>
JSObject* tryNewNurseryObject(JSContext* cx, size_t thingSize, size_t nDynamicSlots,
const Class* clasp);
@@ -880,7 +880,7 @@ class GCRuntime
void arenaAllocatedDuringGC(JS::Zone* zone, Arena* arena);
// Allocator internals
- MOZ_MUST_USE bool gcIfNeededPerAllocation(JSContext* cx);
+ [[nodiscard]] bool gcIfNeededPerAllocation(JSContext* cx);
template <typename T>
static void checkIncrementalZoneState(ExclusiveContext* cx, T* t);
static TenuredCell* refillFreeListFromAnyThread(ExclusiveContext* cx, AllocKind thingKind,
@@ -915,18 +915,18 @@ class GCRuntime
// Check if the system state is such that GC has been supressed
// or otherwise delayed.
- MOZ_MUST_USE bool checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason);
+ [[nodiscard]] bool checkIfGCAllowedInCurrentState(JS::gcreason::Reason reason);
gcstats::ZoneGCStats scanZonesBeforeGC();
void collect(bool nonincrementalByAPI, SliceBudget budget, JS::gcreason::Reason reason) JS_HAZ_GC_CALL;
- MOZ_MUST_USE bool gcCycle(bool nonincrementalByAPI, SliceBudget& budget,
+ [[nodiscard]] bool gcCycle(bool nonincrementalByAPI, SliceBudget& budget,
JS::gcreason::Reason reason);
bool shouldRepeatForDeadZone(JS::gcreason::Reason reason);
void incrementalCollectSlice(SliceBudget& budget, JS::gcreason::Reason reason,
AutoLockForExclusiveAccess& lock);
void purgeRuntime(AutoLockForExclusiveAccess& lock);
- MOZ_MUST_USE bool beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAccess& lock);
+ [[nodiscard]] bool beginMarkPhase(JS::gcreason::Reason reason, AutoLockForExclusiveAccess& lock);
bool shouldPreserveJITCode(JSCompartment* comp, int64_t currentTime,
JS::gcreason::Reason reason, bool canAllocateMoreCode);
void traceRuntimeForMajorGC(JSTracer* trc, AutoLockForExclusiveAccess& lock);
@@ -947,7 +947,7 @@ class GCRuntime
void beginSweepPhase(bool lastGC, AutoLockForExclusiveAccess& lock);
void findZoneGroups(AutoLockForExclusiveAccess& lock);
- MOZ_MUST_USE bool findInterZoneEdges();
+ [[nodiscard]] bool findInterZoneEdges();
void getNextZoneGroup();
void endMarkingZoneGroup();
void beginSweepingZoneGroup(AutoLockForExclusiveAccess& lock);
@@ -976,7 +976,7 @@ class GCRuntime
void endCompactPhase(JS::gcreason::Reason reason);
void sweepTypesAfterCompacting(Zone* zone);
void sweepZoneAfterCompacting(Zone* zone);
- MOZ_MUST_USE bool relocateArenas(Zone* zone, JS::gcreason::Reason reason,
+ [[nodiscard]] bool relocateArenas(Zone* zone, JS::gcreason::Reason reason,
Arena*& relocatedListOut, SliceBudget& sliceBudget);
void updateTypeDescrObjects(MovingTracer* trc, Zone* zone);
void updateCellPointers(MovingTracer* trc, Zone* zone, AllocKinds kinds, size_t bgTaskCount);
diff --git a/js/src/gc/GCTrace.h b/js/src/gc/GCTrace.h
index 4ebb74ee6f..14d684f63d 100644
--- a/js/src/gc/GCTrace.h
+++ b/js/src/gc/GCTrace.h
@@ -16,7 +16,7 @@ namespace gc {
#ifdef JS_GC_TRACE
-extern MOZ_MUST_USE bool InitTrace(GCRuntime& gc);
+[[nodiscard]] extern bool InitTrace(GCRuntime& gc);
extern void FinishTrace();
extern bool TraceEnabled();
extern void TraceNurseryAlloc(Cell* thing, size_t size);
@@ -32,7 +32,7 @@ extern void TraceTypeNewScript(js::ObjectGroup* group);
#else
-inline MOZ_MUST_USE bool InitTrace(GCRuntime& gc) { return true; }
+[[nodiscard]] inline bool InitTrace(GCRuntime& gc) { return true; }
inline void FinishTrace() {}
inline bool TraceEnabled() { return false; }
inline void TraceNurseryAlloc(Cell* thing, size_t size) {}
diff --git a/js/src/gc/Heap.h b/js/src/gc/Heap.h
index 3e14ed906f..b24896d100 100644
--- a/js/src/gc/Heap.h
+++ b/js/src/gc/Heap.h
@@ -1020,7 +1020,7 @@ struct Chunk
void releaseArena(JSRuntime* rt, Arena* arena, const AutoLockGC& lock);
void recycleArena(Arena* arena, SortedArenaList& dest, size_t thingsPerArena);
- MOZ_MUST_USE bool decommitOneFreeArena(JSRuntime* rt, AutoLockGC& lock);
+ [[nodiscard]] bool decommitOneFreeArena(JSRuntime* rt, AutoLockGC& lock);
void decommitAllArenasWithoutUnlocking(const AutoLockGC& lock);
static Chunk* allocate(JSRuntime* rt);
diff --git a/js/src/gc/Marking.h b/js/src/gc/Marking.h
index 414079f799..8d5f353a54 100644
--- a/js/src/gc/Marking.h
+++ b/js/src/gc/Marking.h
@@ -86,13 +86,13 @@ class MarkStack
end_ = stack + capacity;
}
- MOZ_MUST_USE bool init(JSGCMode gcMode);
+ [[nodiscard]] bool init(JSGCMode gcMode);
void setBaseCapacity(JSGCMode mode);
size_t maxCapacity() const { return maxCapacity_; }
void setMaxCapacity(size_t maxCapacity);
- MOZ_MUST_USE bool push(uintptr_t item) {
+ [[nodiscard]] bool push(uintptr_t item) {
if (tos_ == end_) {
if (!enlarge(1))
return false;
@@ -102,7 +102,7 @@ class MarkStack
return true;
}
- MOZ_MUST_USE bool push(uintptr_t item1, uintptr_t item2, uintptr_t item3) {
+ [[nodiscard]] bool push(uintptr_t item1, uintptr_t item2, uintptr_t item3) {
uintptr_t* nextTos = tos_ + 3;
if (nextTos > end_) {
if (!enlarge(3))
@@ -129,7 +129,7 @@ class MarkStack
void reset();
/* Grow the stack, ensuring there is space for at least count elements. */
- MOZ_MUST_USE bool enlarge(unsigned count);
+ [[nodiscard]] bool enlarge(unsigned count);
void setGCMode(JSGCMode gcMode);
@@ -169,7 +169,7 @@ class GCMarker : public JSTracer
{
public:
explicit GCMarker(JSRuntime* rt);
- MOZ_MUST_USE bool init(JSGCMode gcMode);
+ [[nodiscard]] bool init(JSGCMode gcMode);
void setMaxCapacity(size_t maxCap) { stack.setMaxCapacity(maxCap); }
size_t maxCapacity() const { return stack.maxCapacity(); }
@@ -217,7 +217,7 @@ class GCMarker : public JSTracer
void delayMarkingArena(gc::Arena* arena);
void delayMarkingChildren(const void* thing);
void markDelayedChildren(gc::Arena* arena);
- MOZ_MUST_USE bool markDelayedChildren(SliceBudget& budget);
+ [[nodiscard]] bool markDelayedChildren(SliceBudget& budget);
bool hasDelayedChildren() const {
return !!unmarkedArenaStackTop;
}
@@ -226,7 +226,7 @@ class GCMarker : public JSTracer
return isMarkStackEmpty() && !unmarkedArenaStackTop;
}
- MOZ_MUST_USE bool drainMarkStack(SliceBudget& budget);
+ [[nodiscard]] bool drainMarkStack(SliceBudget& budget);
void setGCMode(JSGCMode mode) { stack.setGCMode(mode); }
@@ -291,7 +291,7 @@ class GCMarker : public JSTracer
// Mark the given GC thing, but do not trace its children. Return true
// if the thing became marked.
template <typename T>
- MOZ_MUST_USE bool mark(T* thing);
+ [[nodiscard]] bool mark(T* thing);
void pushTaggedPtr(StackTag tag, void* ptr) {
checkZone(ptr);
@@ -321,7 +321,7 @@ class GCMarker : public JSTracer
return stack.isEmpty();
}
- MOZ_MUST_USE bool restoreValueArray(JSObject* obj, void** vpp, void** endp);
+ [[nodiscard]] bool restoreValueArray(JSObject* obj, void** vpp, void** endp);
void saveValueRanges();
inline void processMarkStackTop(SliceBudget& budget);
diff --git a/js/src/gc/Nursery.h b/js/src/gc/Nursery.h
index 2935890c03..621b07dcaa 100644
--- a/js/src/gc/Nursery.h
+++ b/js/src/gc/Nursery.h
@@ -133,7 +133,7 @@ class Nursery
explicit Nursery(JSRuntime* rt);
~Nursery();
- MOZ_MUST_USE bool init(uint32_t maxNurseryBytes, AutoLockGC& lock);
+ [[nodiscard]] bool init(uint32_t maxNurseryBytes, AutoLockGC& lock);
unsigned maxChunks() const { return maxNurseryChunks_; }
unsigned numChunks() const { return chunks_.length(); }
@@ -198,7 +198,7 @@ class Nursery
* sets |*ref| to the new location of the object and returns true. Otherwise
* returns false and leaves |*ref| unset.
*/
- MOZ_ALWAYS_INLINE MOZ_MUST_USE bool getForwardedPointer(JSObject** ref) const;
+ [[nodiscard]] MOZ_ALWAYS_INLINE bool getForwardedPointer(JSObject** ref) const;
/* Forward a slots/elements pointer stored in an Ion frame. */
void forwardBufferPointer(HeapSlot** pSlotsElems);
@@ -215,7 +215,7 @@ class Nursery
void waitBackgroundFreeEnd();
- MOZ_MUST_USE bool addedUniqueIdToCell(gc::Cell* cell) {
+ [[nodiscard]] bool addedUniqueIdToCell(gc::Cell* cell) {
if (!IsInsideNursery(cell) || !isEnabled())
return true;
MOZ_ASSERT(cellsWithUid_.initialized());
@@ -226,7 +226,7 @@ class Nursery
using SweepThunk = void (*)(void *data);
void queueSweepAction(SweepThunk thunk, void* data);
- MOZ_MUST_USE bool queueDictionaryModeObjectToSweep(NativeObject* obj);
+ [[nodiscard]] bool queueDictionaryModeObjectToSweep(NativeObject* obj);
size_t sizeOfHeapCommitted() const {
return numChunks() * gc::ChunkSize;
diff --git a/js/src/gc/NurseryAwareHashMap.h b/js/src/gc/NurseryAwareHashMap.h
index 9f9486deaa..9f24e51616 100644
--- a/js/src/gc/NurseryAwareHashMap.h
+++ b/js/src/gc/NurseryAwareHashMap.h
@@ -83,7 +83,7 @@ class NurseryAwareHashMap
explicit NurseryAwareHashMap(AllocPolicy a = AllocPolicy()) : map(a) {}
- MOZ_MUST_USE bool init(uint32_t len = 16) { return map.init(len); }
+ [[nodiscard]] bool init(uint32_t len = 16) { return map.init(len); }
bool empty() const { return map.empty(); }
Ptr lookup(const Lookup& l) const { return map.lookup(l); }
@@ -99,7 +99,7 @@ class NurseryAwareHashMap
return map.sizeOfIncludingThis(mallocSizeOf);
}
- MOZ_MUST_USE bool put(const Key& k, const Value& v) {
+ [[nodiscard]] bool put(const Key& k, const Value& v) {
auto p = map.lookupForAdd(k);
if (p) {
if (!JS::GCPolicy<Key>::isTenured(k) || !JS::GCPolicy<Value>::isTenured(v)) {
diff --git a/js/src/gc/Statistics.h b/js/src/gc/Statistics.h
index 9e28be9f97..6eaac75649 100644
--- a/js/src/gc/Statistics.h
+++ b/js/src/gc/Statistics.h
@@ -184,7 +184,7 @@ struct Statistics
/* Create a convenient type for referring to tables of phase times. */
using PhaseTimeTable = int64_t[NumTimingArrays][PHASE_LIMIT];
- static MOZ_MUST_USE bool initialize();
+ [[nodiscard]] static bool initialize();
explicit Statistics(JSRuntime* rt);
~Statistics();
@@ -213,8 +213,8 @@ struct Statistics
SliceBudget budget, JS::gcreason::Reason reason);
void endSlice();
- MOZ_MUST_USE bool startTimingMutator();
- MOZ_MUST_USE bool stopTimingMutator(double& mutator_ms, double& gc_ms);
+ [[nodiscard]] bool startTimingMutator();
+ [[nodiscard]] bool stopTimingMutator(double& mutator_ms, double& gc_ms);
// Note when we sweep a zone or compartment.
void sweptZone() { ++zoneStats.sweptZoneCount; }
diff --git a/js/src/gc/StoreBuffer.h b/js/src/gc/StoreBuffer.h
index f9158ef9c2..053a203f65 100644
--- a/js/src/gc/StoreBuffer.h
+++ b/js/src/gc/StoreBuffer.h
@@ -79,7 +79,7 @@ class StoreBuffer
explicit MonoTypeBuffer() : last_(T()) {}
~MonoTypeBuffer() { stores_.finish(); }
- MOZ_MUST_USE bool init() {
+ [[nodiscard]] bool init() {
if (!stores_.initialized() && !stores_.init())
return false;
clear();
@@ -146,7 +146,7 @@ class StoreBuffer
explicit GenericBuffer() : storage_(nullptr) {}
~GenericBuffer() { js_delete(storage_); }
- MOZ_MUST_USE bool init() {
+ [[nodiscard]] bool init() {
if (!storage_)
storage_ = js_new<LifoAlloc>(LifoAllocBlockSize);
clear();
@@ -387,7 +387,7 @@ class StoreBuffer
{
}
- MOZ_MUST_USE bool enable();
+ [[nodiscard]] bool enable();
void disable();
bool isEnabled() const { return enabled_; }
diff --git a/js/src/gc/Zone.h b/js/src/gc/Zone.h
index 323aa27758..6b5edbdcac 100644
--- a/js/src/gc/Zone.h
+++ b/js/src/gc/Zone.h
@@ -140,7 +140,7 @@ struct Zone : public JS::shadow::Zone,
{
explicit Zone(JSRuntime* rt);
~Zone();
- MOZ_MUST_USE bool init(bool isSystem);
+ [[nodiscard]] bool init(bool isSystem);
void findOutgoingEdges(js::gc::ZoneComponentFinder& finder);
@@ -172,7 +172,7 @@ struct Zone : public JS::shadow::Zone,
bool isTooMuchMalloc() const { return gcMallocBytes <= 0; }
void onTooMuchMalloc();
- MOZ_MUST_USE void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes,
+ [[nodiscard]] void* onOutOfMemory(js::AllocFunction allocFunc, size_t nbytes,
void* reallocPtr = nullptr) {
if (!js::CurrentThreadCanAccessRuntime(runtime_))
return nullptr;
@@ -422,7 +422,7 @@ struct Zone : public JS::shadow::Zone,
}
// Creates a HashNumber based on getUniqueId. Returns false on OOM.
- MOZ_MUST_USE bool getHashCode(js::gc::Cell* cell, js::HashNumber* hashp) {
+ [[nodiscard]] bool getHashCode(js::gc::Cell* cell, js::HashNumber* hashp) {
uint64_t uid;
if (!getUniqueId(cell, &uid))
return false;
@@ -432,7 +432,7 @@ struct Zone : public JS::shadow::Zone,
// Puts an existing UID in |uidp|, or creates a new UID for this Cell and
// puts that into |uidp|. Returns false on OOM.
- MOZ_MUST_USE bool getUniqueId(js::gc::Cell* cell, uint64_t* uidp) {
+ [[nodiscard]] bool getUniqueId(js::gc::Cell* cell, uint64_t* uidp) {
MOZ_ASSERT(uidp);
MOZ_ASSERT(js::CurrentThreadCanAccessZone(this));
@@ -472,7 +472,7 @@ struct Zone : public JS::shadow::Zone,
}
// Return true if this cell has a UID associated with it.
- MOZ_MUST_USE bool hasUniqueId(js::gc::Cell* cell) {
+ [[nodiscard]] bool hasUniqueId(js::gc::Cell* cell) {
MOZ_ASSERT(js::CurrentThreadCanAccessZone(this));
return uniqueIds_.has(cell);
}
@@ -731,7 +731,7 @@ class ZoneAllocPolicy
void free_(void* p) { js_free(p); }
void reportAllocOverflow() const {}
- MOZ_MUST_USE bool checkSimulatedOOM() const {
+ [[nodiscard]] bool checkSimulatedOOM() const {
return !js::oom::ShouldFailWithOOM();
}
};
diff --git a/js/src/irregexp/InfallibleVector.h b/js/src/irregexp/InfallibleVector.h
index eafa576acf..4172a55956 100644
--- a/js/src/irregexp/InfallibleVector.h
+++ b/js/src/irregexp/InfallibleVector.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-// Copyright 2012 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors.
+// Copyright 2023 Moonchild Productions.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -38,7 +39,7 @@ namespace irregexp {
// InfallibleVector is like Vector, but all its methods are infallible (they
// crash on OOM). We use this class instead of Vector to avoid a ton of
-// MOZ_MUST_USE warnings in irregexp code (imported from V8).
+// [[nodiscard]] warnings in irregexp code (imported from V8).
template<typename T, size_t N>
class InfallibleVector
{
diff --git a/js/src/jit/AliasAnalysis.h b/js/src/jit/AliasAnalysis.h
index 778bab4946..7370c7e693 100644
--- a/js/src/jit/AliasAnalysis.h
+++ b/js/src/jit/AliasAnalysis.h
@@ -21,7 +21,7 @@ class AliasAnalysis : public AliasAnalysisShared
public:
AliasAnalysis(MIRGenerator* mir, MIRGraph& graph);
- MOZ_MUST_USE bool analyze() override;
+ [[nodiscard]] bool analyze() override;
};
} // namespace jit
diff --git a/js/src/jit/AliasAnalysisShared.h b/js/src/jit/AliasAnalysisShared.h
index ba3e335eff..3c91cd449c 100644
--- a/js/src/jit/AliasAnalysisShared.h
+++ b/js/src/jit/AliasAnalysisShared.h
@@ -26,7 +26,7 @@ class AliasAnalysisShared
graph_(graph)
{}
- virtual MOZ_MUST_USE bool analyze() {
+ [[nodiscard]] virtual bool analyze() {
return true;
}
diff --git a/js/src/jit/AlignmentMaskAnalysis.h b/js/src/jit/AlignmentMaskAnalysis.h
index 4cee7683ff..30543b6b76 100644
--- a/js/src/jit/AlignmentMaskAnalysis.h
+++ b/js/src/jit/AlignmentMaskAnalysis.h
@@ -22,7 +22,7 @@ class AlignmentMaskAnalysis
: graph_(graph)
{}
- MOZ_MUST_USE bool analyze();
+ [[nodiscard]] bool analyze();
};
} /* namespace jit */
diff --git a/js/src/jit/BacktrackingAllocator.h b/js/src/jit/BacktrackingAllocator.h
index cbf7fca9ae..7f35ee8f4b 100644
--- a/js/src/jit/BacktrackingAllocator.h
+++ b/js/src/jit/BacktrackingAllocator.h
@@ -94,7 +94,7 @@ class Requirement
int priority() const;
- MOZ_MUST_USE bool merge(const Requirement& newRequirement) {
+ [[nodiscard]] bool merge(const Requirement& newRequirement) {
// Merge newRequirement with any existing requirement, returning false
// if the new and old requirements conflict.
MOZ_ASSERT(newRequirement.kind() != Requirement::MUST_REUSE_INPUT);
@@ -382,7 +382,7 @@ class SpillSet : public TempObject
return new(alloc) SpillSet(alloc);
}
- MOZ_MUST_USE bool addSpilledBundle(LiveBundle* bundle) {
+ [[nodiscard]] bool addSpilledBundle(LiveBundle* bundle) {
return list_.append(bundle);
}
size_t numSpilledBundles() const {
@@ -450,9 +450,9 @@ class LiveBundle : public TempObject
ranges_.removeAndIncrement(iter);
}
void addRange(LiveRange* range);
- MOZ_MUST_USE bool addRange(TempAllocator& alloc, uint32_t vreg,
+ [[nodiscard]] bool addRange(TempAllocator& alloc, uint32_t vreg,
CodePosition from, CodePosition to);
- MOZ_MUST_USE bool addRangeAndDistributeUses(TempAllocator& alloc, LiveRange* oldRange,
+ [[nodiscard]] bool addRangeAndDistributeUses(TempAllocator& alloc, LiveRange* oldRange,
CodePosition from, CodePosition to);
LiveRange* popFirstRange();
#ifdef DEBUG
@@ -576,7 +576,7 @@ class VirtualRegister
return firstRange()->bundle();
}
- MOZ_MUST_USE bool addInitialRange(TempAllocator& alloc, CodePosition from, CodePosition to);
+ [[nodiscard]] bool addInitialRange(TempAllocator& alloc, CodePosition from, CodePosition to);
void addInitialUse(UsePosition* use);
void setInitialDefinition(CodePosition from);
};
@@ -681,7 +681,7 @@ class BacktrackingAllocator : protected RegisterAllocator
callRanges(nullptr)
{ }
- MOZ_MUST_USE bool go();
+ [[nodiscard]] bool go();
private:
@@ -689,10 +689,10 @@ class BacktrackingAllocator : protected RegisterAllocator
typedef Vector<LiveBundle*, 4, SystemAllocPolicy> LiveBundleVector;
// Liveness methods.
- MOZ_MUST_USE bool init();
- MOZ_MUST_USE bool buildLivenessInfo();
+ [[nodiscard]] bool init();
+ [[nodiscard]] bool buildLivenessInfo();
- MOZ_MUST_USE bool addInitialFixedRange(AnyRegister reg, CodePosition from, CodePosition to);
+ [[nodiscard]] bool addInitialFixedRange(AnyRegister reg, CodePosition from, CodePosition to);
VirtualRegister& vreg(const LDefinition* def) {
return vregs[def->virtualRegister()];
@@ -703,42 +703,42 @@ class BacktrackingAllocator : protected RegisterAllocator
}
// Allocation methods.
- MOZ_MUST_USE bool tryMergeBundles(LiveBundle* bundle0, LiveBundle* bundle1);
- MOZ_MUST_USE bool tryMergeReusedRegister(VirtualRegister& def, VirtualRegister& input);
- MOZ_MUST_USE bool mergeAndQueueRegisters();
- MOZ_MUST_USE bool tryAllocateFixed(LiveBundle* bundle, Requirement requirement,
+ [[nodiscard]] bool tryMergeBundles(LiveBundle* bundle0, LiveBundle* bundle1);
+ [[nodiscard]] bool tryMergeReusedRegister(VirtualRegister& def, VirtualRegister& input);
+ [[nodiscard]] bool mergeAndQueueRegisters();
+ [[nodiscard]] bool tryAllocateFixed(LiveBundle* bundle, Requirement requirement,
bool* success, bool* pfixed, LiveBundleVector& conflicting);
- MOZ_MUST_USE bool tryAllocateNonFixed(LiveBundle* bundle, Requirement requirement,
+ [[nodiscard]] bool tryAllocateNonFixed(LiveBundle* bundle, Requirement requirement,
Requirement hint, bool* success, bool* pfixed,
LiveBundleVector& conflicting);
- MOZ_MUST_USE bool processBundle(MIRGenerator* mir, LiveBundle* bundle);
- MOZ_MUST_USE bool computeRequirement(LiveBundle* bundle, Requirement *prequirement,
+ [[nodiscard]] bool processBundle(MIRGenerator* mir, LiveBundle* bundle);
+ [[nodiscard]] bool computeRequirement(LiveBundle* bundle, Requirement *prequirement,
Requirement *phint);
- MOZ_MUST_USE bool tryAllocateRegister(PhysicalRegister& r, LiveBundle* bundle, bool* success,
+ [[nodiscard]] bool tryAllocateRegister(PhysicalRegister& r, LiveBundle* bundle, bool* success,
bool* pfixed, LiveBundleVector& conflicting);
- MOZ_MUST_USE bool evictBundle(LiveBundle* bundle);
- MOZ_MUST_USE bool splitAndRequeueBundles(LiveBundle* bundle,
+ [[nodiscard]] bool evictBundle(LiveBundle* bundle);
+ [[nodiscard]] bool splitAndRequeueBundles(LiveBundle* bundle,
const LiveBundleVector& newBundles);
- MOZ_MUST_USE bool spill(LiveBundle* bundle);
+ [[nodiscard]] bool spill(LiveBundle* bundle);
bool isReusedInput(LUse* use, LNode* ins, bool considerCopy);
bool isRegisterUse(UsePosition* use, LNode* ins, bool considerCopy = false);
bool isRegisterDefinition(LiveRange* range);
- MOZ_MUST_USE bool pickStackSlot(SpillSet* spill);
- MOZ_MUST_USE bool insertAllRanges(LiveRangeSet& set, LiveBundle* bundle);
+ [[nodiscard]] bool pickStackSlot(SpillSet* spill);
+ [[nodiscard]] bool insertAllRanges(LiveRangeSet& set, LiveBundle* bundle);
// Reification methods.
- MOZ_MUST_USE bool pickStackSlots();
- MOZ_MUST_USE bool resolveControlFlow();
- MOZ_MUST_USE bool reifyAllocations();
- MOZ_MUST_USE bool populateSafepoints();
- MOZ_MUST_USE bool annotateMoveGroups();
- MOZ_MUST_USE bool deadRange(LiveRange* range);
+ [[nodiscard]] bool pickStackSlots();
+ [[nodiscard]] bool resolveControlFlow();
+ [[nodiscard]] bool reifyAllocations();
+ [[nodiscard]] bool populateSafepoints();
+ [[nodiscard]] bool annotateMoveGroups();
+ [[nodiscard]] bool deadRange(LiveRange* range);
size_t findFirstNonCallSafepoint(CodePosition from);
size_t findFirstSafepoint(CodePosition pos, size_t startFrom);
void addLiveRegistersForRange(VirtualRegister& reg, LiveRange* range);
- MOZ_MUST_USE bool addMove(LMoveGroup* moves, LiveRange* from, LiveRange* to,
+ [[nodiscard]] bool addMove(LMoveGroup* moves, LiveRange* from, LiveRange* to,
LDefinition::Type type) {
LAllocation fromAlloc = from->bundle()->allocation();
LAllocation toAlloc = to->bundle()->allocation();
@@ -746,7 +746,7 @@ class BacktrackingAllocator : protected RegisterAllocator
return moves->add(fromAlloc, toAlloc, type);
}
- MOZ_MUST_USE bool moveInput(LInstruction* ins, LiveRange* from, LiveRange* to,
+ [[nodiscard]] bool moveInput(LInstruction* ins, LiveRange* from, LiveRange* to,
LDefinition::Type type) {
if (from->bundle()->allocation() == to->bundle()->allocation()) {
return true;
@@ -755,7 +755,7 @@ class BacktrackingAllocator : protected RegisterAllocator
return addMove(moves, from, to, type);
}
- MOZ_MUST_USE bool moveAfter(LInstruction* ins, LiveRange* from, LiveRange* to,
+ [[nodiscard]] bool moveAfter(LInstruction* ins, LiveRange* from, LiveRange* to,
LDefinition::Type type) {
if (from->bundle()->allocation() == to->bundle()->allocation()) {
return true;
@@ -764,7 +764,7 @@ class BacktrackingAllocator : protected RegisterAllocator
return addMove(moves, from, to, type);
}
- MOZ_MUST_USE bool moveAtExit(LBlock* block, LiveRange* from, LiveRange* to,
+ [[nodiscard]] bool moveAtExit(LBlock* block, LiveRange* from, LiveRange* to,
LDefinition::Type type) {
if (from->bundle()->allocation() == to->bundle()->allocation()) {
return true;
@@ -773,7 +773,7 @@ class BacktrackingAllocator : protected RegisterAllocator
return addMove(moves, from, to, type);
}
- MOZ_MUST_USE bool moveAtEntry(LBlock* block, LiveRange* from, LiveRange* to,
+ [[nodiscard]] bool moveAtEntry(LBlock* block, LiveRange* from, LiveRange* to,
LDefinition::Type type) {
if (from->bundle()->allocation() == to->bundle()->allocation()) {
return true;
@@ -782,7 +782,7 @@ class BacktrackingAllocator : protected RegisterAllocator
return addMove(moves, from, to, type);
}
- MOZ_MUST_USE bool moveAtEdge(LBlock* predecessor, LBlock* successor, LiveRange* from,
+ [[nodiscard]] bool moveAtEdge(LBlock* predecessor, LBlock* successor, LiveRange* from,
LiveRange* to, LDefinition::Type type);
// Debugging methods.
@@ -801,15 +801,15 @@ class BacktrackingAllocator : protected RegisterAllocator
size_t maximumSpillWeight(const LiveBundleVector& bundles);
- MOZ_MUST_USE bool chooseBundleSplit(LiveBundle* bundle, bool fixed, LiveBundle* conflict);
+ [[nodiscard]] bool chooseBundleSplit(LiveBundle* bundle, bool fixed, LiveBundle* conflict);
- MOZ_MUST_USE bool splitAt(LiveBundle* bundle, const SplitPositionVector& splitPositions);
- MOZ_MUST_USE bool trySplitAcrossHotcode(LiveBundle* bundle, bool* success);
- MOZ_MUST_USE bool trySplitAfterLastRegisterUse(LiveBundle* bundle, LiveBundle* conflict,
+ [[nodiscard]] bool splitAt(LiveBundle* bundle, const SplitPositionVector& splitPositions);
+ [[nodiscard]] bool trySplitAcrossHotcode(LiveBundle* bundle, bool* success);
+ [[nodiscard]] bool trySplitAfterLastRegisterUse(LiveBundle* bundle, LiveBundle* conflict,
bool* success);
- MOZ_MUST_USE bool trySplitBeforeFirstRegisterUse(LiveBundle* bundle, LiveBundle* conflict,
+ [[nodiscard]] bool trySplitBeforeFirstRegisterUse(LiveBundle* bundle, LiveBundle* conflict,
bool* success);
- MOZ_MUST_USE bool splitAcrossCalls(LiveBundle* bundle);
+ [[nodiscard]] bool splitAcrossCalls(LiveBundle* bundle);
bool compilingWasm() {
return mir->info().compilingWasm();
diff --git a/js/src/jit/Bailouts.h b/js/src/jit/Bailouts.h
index d8727b917d..923c03e63e 100644
--- a/js/src/jit/Bailouts.h
+++ b/js/src/jit/Bailouts.h
@@ -150,7 +150,7 @@ class BailoutFrameInfo
}
};
-MOZ_MUST_USE bool EnsureHasEnvironmentObjects(JSContext* cx, AbstractFramePtr fp);
+[[nodiscard]] bool EnsureHasEnvironmentObjects(JSContext* cx, AbstractFramePtr fp);
struct BaselineBailoutInfo;
diff --git a/js/src/jit/BaselineBailouts.cpp b/js/src/jit/BaselineBailouts.cpp
index 4bcaadee47..7b1bdc8c3f 100644
--- a/js/src/jit/BaselineBailouts.cpp
+++ b/js/src/jit/BaselineBailouts.cpp
@@ -116,7 +116,7 @@ struct BaselineStackBuilder
js_free(buffer_);
}
- MOZ_MUST_USE bool init() {
+ [[nodiscard]] bool init() {
MOZ_ASSERT(!buffer_);
MOZ_ASSERT(bufferUsed_ == 0);
buffer_ = reinterpret_cast<uint8_t*>(js_calloc(bufferTotal_));
@@ -142,7 +142,7 @@ struct BaselineStackBuilder
return true;
}
- MOZ_MUST_USE bool enlarge() {
+ [[nodiscard]] bool enlarge() {
MOZ_ASSERT(buffer_ != nullptr);
if (bufferTotal_ & mozilla::tl::MulOverflowMask<2>::value)
return false;
@@ -182,7 +182,7 @@ struct BaselineStackBuilder
return framePushed_;
}
- MOZ_MUST_USE bool subtract(size_t size, const char* info = nullptr) {
+ [[nodiscard]] bool subtract(size_t size, const char* info = nullptr) {
// enlarge the buffer if need be.
while (size > bufferAvail_) {
if (!enlarge())
@@ -203,7 +203,7 @@ struct BaselineStackBuilder
}
template <typename T>
- MOZ_MUST_USE bool write(const T& t) {
+ [[nodiscard]] bool write(const T& t) {
MOZ_ASSERT(!(uintptr_t(&t) >= uintptr_t(header_->copyStackBottom) &&
uintptr_t(&t) < uintptr_t(header_->copyStackTop)),
"Should not reference memory that can be freed");
@@ -214,7 +214,7 @@ struct BaselineStackBuilder
}
template <typename T>
- MOZ_MUST_USE bool writePtr(T* t, const char* info) {
+ [[nodiscard]] bool writePtr(T* t, const char* info) {
if (!write<T*>(t))
return false;
if (info)
@@ -224,7 +224,7 @@ struct BaselineStackBuilder
return true;
}
- MOZ_MUST_USE bool writeWord(size_t w, const char* info) {
+ [[nodiscard]] bool writeWord(size_t w, const char* info) {
if (!write<size_t>(w))
return false;
if (info) {
@@ -241,7 +241,7 @@ struct BaselineStackBuilder
return true;
}
- MOZ_MUST_USE bool writeValue(const Value& val, const char* info) {
+ [[nodiscard]] bool writeValue(const Value& val, const char* info) {
if (!write<Value>(val))
return false;
if (info) {
@@ -253,7 +253,7 @@ struct BaselineStackBuilder
return true;
}
- MOZ_MUST_USE bool maybeWritePadding(size_t alignment, size_t after, const char* info) {
+ [[nodiscard]] bool maybeWritePadding(size_t alignment, size_t after, const char* info) {
MOZ_ASSERT(framePushed_ % sizeof(Value) == 0);
MOZ_ASSERT(after % sizeof(Value) == 0);
size_t offset = ComputeByteAlignment(after, alignment);
diff --git a/js/src/jit/BaselineCacheIR.cpp b/js/src/jit/BaselineCacheIR.cpp
index 5317f0e4e5..a2cb20111b 100644
--- a/js/src/jit/BaselineCacheIR.cpp
+++ b/js/src/jit/BaselineCacheIR.cpp
@@ -168,7 +168,7 @@ class MOZ_RAII CacheRegisterAllocator
writer_(writer)
{}
- MOZ_MUST_USE bool init(const AllocatableGeneralRegisterSet& available) {
+ [[nodiscard]] bool init(const AllocatableGeneralRegisterSet& available) {
availableRegs_ = available;
if (!origInputLocations_.resize(writer_.numInputOperands()))
return false;
@@ -394,12 +394,12 @@ class MOZ_RAII BaselineCacheIRCompiler : public CacheIRCompiler
stubDataOffset_(stubDataOffset)
{}
- MOZ_MUST_USE bool init(CacheKind kind);
+ [[nodiscard]] bool init(CacheKind kind);
JitCode* compile();
private:
-#define DEFINE_OP(op) MOZ_MUST_USE bool emit##op();
+#define DEFINE_OP(op) [[nodiscard]] bool emit##op();
CACHE_IR_OPS(DEFINE_OP)
#undef DEFINE_OP
diff --git a/js/src/jit/BaselineCompiler.h b/js/src/jit/BaselineCompiler.h
index 30da13d9c1..de1b75d29a 100644
--- a/js/src/jit/BaselineCompiler.h
+++ b/js/src/jit/BaselineCompiler.h
@@ -285,43 +285,43 @@ class BaselineCompiler : public BaselineCompilerSpecific
public:
BaselineCompiler(JSContext* cx, TempAllocator& alloc, JSScript* script);
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
MethodStatus compile();
private:
MethodStatus emitBody();
- MOZ_MUST_USE bool emitCheckThis(ValueOperand val);
+ [[nodiscard]] bool emitCheckThis(ValueOperand val);
void emitLoadReturnValue(ValueOperand val);
void emitInitializeLocals();
- MOZ_MUST_USE bool emitPrologue();
- MOZ_MUST_USE bool emitEpilogue();
- MOZ_MUST_USE bool emitOutOfLinePostBarrierSlot();
- MOZ_MUST_USE bool emitIC(ICStub* stub, ICEntry::Kind kind);
- MOZ_MUST_USE bool emitOpIC(ICStub* stub) {
+ [[nodiscard]] bool emitPrologue();
+ [[nodiscard]] bool emitEpilogue();
+ [[nodiscard]] bool emitOutOfLinePostBarrierSlot();
+ [[nodiscard]] bool emitIC(ICStub* stub, ICEntry::Kind kind);
+ [[nodiscard]] bool emitOpIC(ICStub* stub) {
return emitIC(stub, ICEntry::Kind_Op);
}
- MOZ_MUST_USE bool emitNonOpIC(ICStub* stub) {
+ [[nodiscard]] bool emitNonOpIC(ICStub* stub) {
return emitIC(stub, ICEntry::Kind_NonOp);
}
- MOZ_MUST_USE bool emitStackCheck(bool earlyCheck=false);
- MOZ_MUST_USE bool emitInterruptCheck();
- MOZ_MUST_USE bool emitWarmUpCounterIncrement(bool allowOsr=true);
- MOZ_MUST_USE bool emitArgumentTypeChecks();
+ [[nodiscard]] bool emitStackCheck(bool earlyCheck=false);
+ [[nodiscard]] bool emitInterruptCheck();
+ [[nodiscard]] bool emitWarmUpCounterIncrement(bool allowOsr=true);
+ [[nodiscard]] bool emitArgumentTypeChecks();
void emitIsDebuggeeCheck();
- MOZ_MUST_USE bool emitDebugPrologue();
- MOZ_MUST_USE bool emitDebugTrap();
- MOZ_MUST_USE bool emitTraceLoggerEnter();
- MOZ_MUST_USE bool emitTraceLoggerExit();
- MOZ_MUST_USE bool emitTraceLoggerResume(Register script, AllocatableGeneralRegisterSet& regs);
+ [[nodiscard]] bool emitDebugPrologue();
+ [[nodiscard]] bool emitDebugTrap();
+ [[nodiscard]] bool emitTraceLoggerEnter();
+ [[nodiscard]] bool emitTraceLoggerExit();
+ [[nodiscard]] bool emitTraceLoggerResume(Register script, AllocatableGeneralRegisterSet& regs);
void emitProfilerEnterFrame();
void emitProfilerExitFrame();
- MOZ_MUST_USE bool initEnvironmentChain();
+ [[nodiscard]] bool initEnvironmentChain();
void storeValue(const StackValue* source, const Address& dest,
const ValueOperand& scratch);
@@ -331,35 +331,35 @@ class BaselineCompiler : public BaselineCompilerSpecific
#undef EMIT_OP
// JSOP_NEG, JSOP_BITNOT, JSOP_INC, JSOP_DEC
- MOZ_MUST_USE bool emitUnaryArith();
+ [[nodiscard]] bool emitUnaryArith();
// JSOP_BITXOR, JSOP_LSH, JSOP_ADD etc.
- MOZ_MUST_USE bool emitBinaryArith();
+ [[nodiscard]] bool emitBinaryArith();
// Handles JSOP_LT, JSOP_GT, and friends
- MOZ_MUST_USE bool emitCompare();
+ [[nodiscard]] bool emitCompare();
- MOZ_MUST_USE bool emitReturn();
+ [[nodiscard]] bool emitReturn();
- MOZ_MUST_USE bool emitToBoolean();
- MOZ_MUST_USE bool emitTest(bool branchIfTrue);
- MOZ_MUST_USE bool emitAndOr(bool branchIfTrue);
- MOZ_MUST_USE bool emitCall();
- MOZ_MUST_USE bool emitSpreadCall();
+ [[nodiscard]] bool emitToBoolean();
+ [[nodiscard]] bool emitTest(bool branchIfTrue);
+ [[nodiscard]] bool emitAndOr(bool branchIfTrue);
+ [[nodiscard]] bool emitCall();
+ [[nodiscard]] bool emitSpreadCall();
- MOZ_MUST_USE bool emitInitPropGetterSetter();
- MOZ_MUST_USE bool emitInitElemGetterSetter();
+ [[nodiscard]] bool emitInitPropGetterSetter();
+ [[nodiscard]] bool emitInitElemGetterSetter();
- MOZ_MUST_USE bool emitFormalArgAccess(uint32_t arg, bool get);
+ [[nodiscard]] bool emitFormalArgAccess(uint32_t arg, bool get);
- MOZ_MUST_USE bool emitThrowConstAssignment();
- MOZ_MUST_USE bool emitUninitializedLexicalCheck(const ValueOperand& val);
+ [[nodiscard]] bool emitThrowConstAssignment();
+ [[nodiscard]] bool emitUninitializedLexicalCheck(const ValueOperand& val);
- MOZ_MUST_USE bool emitIsMagicValue();
+ [[nodiscard]] bool emitIsMagicValue();
- MOZ_MUST_USE bool addPCMappingEntry(bool addIndexEntry);
+ [[nodiscard]] bool addPCMappingEntry(bool addIndexEntry);
- MOZ_MUST_USE bool addYieldAndAwaitOffset();
+ [[nodiscard]] bool addYieldAndAwaitOffset();
void getEnvironmentCoordinateObject(Register reg);
Address getEnvironmentCoordinateAddressFromObject(Register objReg, Register reg);
diff --git a/js/src/jit/BaselineDebugModeOSR.h b/js/src/jit/BaselineDebugModeOSR.h
index 5ffc988f3e..1cbfc51e03 100644
--- a/js/src/jit/BaselineDebugModeOSR.h
+++ b/js/src/jit/BaselineDebugModeOSR.h
@@ -134,7 +134,7 @@ struct BaselineDebugModeOSRInfo
void popValueInto(PCMappingSlotInfo::SlotLocation loc, Value* vp);
};
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RecompileOnStackBaselineScriptsForDebugMode(JSContext* cx,
const Debugger::ExecutionObservableSet& obs,
Debugger::IsObserving observing);
diff --git a/js/src/jit/BaselineFrame.h b/js/src/jit/BaselineFrame.h
index c54569627f..165b78ab25 100644
--- a/js/src/jit/BaselineFrame.h
+++ b/js/src/jit/BaselineFrame.h
@@ -102,7 +102,7 @@ class BaselineFrame
// This is the old frame pointer saved in the prologue.
static const uint32_t FramePointerOffset = sizeof(void*);
- MOZ_MUST_USE bool initForOsr(InterpreterFrame* fp, uint32_t numStackValues);
+ [[nodiscard]] bool initForOsr(InterpreterFrame* fp, uint32_t numStackValues);
uint32_t frameSize() const {
return frameSize_;
@@ -259,12 +259,12 @@ class BaselineFrame
return &flags_;
}
- inline MOZ_MUST_USE bool pushLexicalEnvironment(JSContext* cx, Handle<LexicalScope*> scope);
- inline MOZ_MUST_USE bool freshenLexicalEnvironment(JSContext* cx);
- inline MOZ_MUST_USE bool recreateLexicalEnvironment(JSContext* cx);
+ [[nodiscard]] inline bool pushLexicalEnvironment(JSContext* cx, Handle<LexicalScope*> scope);
+ [[nodiscard]] inline bool freshenLexicalEnvironment(JSContext* cx);
+ [[nodiscard]] inline bool recreateLexicalEnvironment(JSContext* cx);
- MOZ_MUST_USE bool initFunctionEnvironmentObjects(JSContext* cx);
- MOZ_MUST_USE bool pushVarEnvironment(JSContext* cx, HandleScope scope);
+ [[nodiscard]] bool initFunctionEnvironmentObjects(JSContext* cx);
+ [[nodiscard]] bool pushVarEnvironment(JSContext* cx, HandleScope scope);
void initArgsObjUnchecked(ArgumentsObject& argsobj) {
flags_ |= HAS_ARGS_OBJ;
diff --git a/js/src/jit/BaselineFrameInfo.h b/js/src/jit/BaselineFrameInfo.h
index f407a9276d..6a1e47322f 100644
--- a/js/src/jit/BaselineFrameInfo.h
+++ b/js/src/jit/BaselineFrameInfo.h
@@ -178,7 +178,7 @@ class FrameInfo
spIndex(0)
{ }
- MOZ_MUST_USE bool init(TempAllocator& alloc);
+ [[nodiscard]] bool init(TempAllocator& alloc);
size_t nlocals() const {
return script->nfixed();
diff --git a/js/src/jit/BaselineIC.h b/js/src/jit/BaselineIC.h
index bd30ec0369..183644ab3a 100644
--- a/js/src/jit/BaselineIC.h
+++ b/js/src/jit/BaselineIC.h
@@ -41,7 +41,7 @@ class ICWarmUpCounter_Fallback : public ICFallbackStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -73,7 +73,7 @@ class ICTypeUpdate_Fallback : public ICStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -97,7 +97,7 @@ class ICTypeUpdate_PrimitiveSet : public TypeCheckPrimitiveSetStub
public:
class Compiler : public TypeCheckPrimitiveSetStub::Compiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, ICTypeUpdate_PrimitiveSet* existingStub, JSValueType type)
@@ -141,7 +141,7 @@ class ICTypeUpdate_SingleObject : public ICStub
class Compiler : public ICStubCompiler {
protected:
HandleObject obj_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, HandleObject obj)
@@ -176,7 +176,7 @@ class ICTypeUpdate_ObjectGroup : public ICStub
class Compiler : public ICStubCompiler {
protected:
HandleObjectGroup group_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, HandleObjectGroup group)
@@ -206,7 +206,7 @@ class ICToBool_Fallback : public ICFallbackStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -229,7 +229,7 @@ class ICToBool_Int32 : public ICStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -252,7 +252,7 @@ class ICToBool_String : public ICStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -275,7 +275,7 @@ class ICToBool_NullUndefined : public ICStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -298,7 +298,7 @@ class ICToBool_Double : public ICStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -321,7 +321,7 @@ class ICToBool_Object : public ICStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -374,7 +374,7 @@ class ICGetElem_Fallback : public ICMonitoredFallbackStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -699,10 +699,10 @@ class ICGetElemNativeCompiler : public ICStubCompiler
HandleFunction getter_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool emitCheckKey(MacroAssembler& masm, Label& failure);
- MOZ_MUST_USE bool emitCallNative(MacroAssembler& masm, Register objReg);
- MOZ_MUST_USE bool emitCallScripted(MacroAssembler& masm, Register objReg);
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool emitCheckKey(MacroAssembler& masm, Label& failure);
+ [[nodiscard]] bool emitCallNative(MacroAssembler& masm, Register objReg);
+ [[nodiscard]] bool emitCallScripted(MacroAssembler& masm, Register objReg);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
protected:
virtual int32_t getKey() const {
@@ -808,7 +808,7 @@ class ICGetElem_String : public ICStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -845,7 +845,7 @@ class ICGetElem_Dense : public ICMonitoredStub
RootedShape shape_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -891,7 +891,7 @@ class ICGetElem_UnboxedArray : public ICMonitoredStub
JSValueType elementType_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -938,7 +938,7 @@ class ICGetElem_TypedArray : public ICStub
TypedThingLayout layout_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -987,7 +987,7 @@ class ICGetElem_Arguments : public ICMonitoredStub
Which which_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -1033,7 +1033,7 @@ class ICSetElem_Fallback : public ICFallbackStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -1075,7 +1075,7 @@ class ICSetElem_DenseOrUnboxedArray : public ICUpdatedStub
RootedObjectGroup group_;
JSValueType unboxedType_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
virtual int32_t getKey() const {
@@ -1183,7 +1183,7 @@ class ICSetElemDenseOrUnboxedArrayAddCompiler : public ICStubCompiler {
size_t protoChainDepth_;
JSValueType unboxedType_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
protected:
virtual int32_t getKey() const {
@@ -1248,7 +1248,7 @@ class ICSetElem_TypedArray : public ICStub
bool expectOutOfBounds_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -1289,7 +1289,7 @@ class ICIn_Fallback : public ICFallbackStub
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -1373,7 +1373,7 @@ class ICInNativeCompiler : public ICStubCompiler
RootedObject holder_;
RootedPropertyName name_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
ICInNativeCompiler(JSContext* cx, ICStub::Kind kind, HandleObject obj, HandleObject holder,
@@ -1474,7 +1474,7 @@ class ICInNativeDoesNotExistCompiler : public ICStubCompiler
(static_cast<int32_t>(protoChainDepth_) << 17);
}
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
ICInNativeDoesNotExistCompiler(JSContext* cx, HandleObject obj, HandlePropertyName name,
@@ -1508,7 +1508,7 @@ class ICIn_Dense : public ICStub
RootedShape shape_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, Shape* shape)
@@ -1546,7 +1546,7 @@ class ICGetName_Fallback : public ICMonitoredFallbackStub
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -1582,7 +1582,7 @@ class ICGetName_GlobalLexical : public ICMonitoredStub
uint32_t slot_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, ICStub* firstMonitorStub, uint32_t slot)
@@ -1639,7 +1639,7 @@ class ICGetName_Env : public ICMonitoredStub
uint32_t offset_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
protected:
virtual int32_t getKey() const {
@@ -1679,7 +1679,7 @@ class ICBindName_Fallback : public ICFallbackStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -1705,7 +1705,7 @@ class ICGetIntrinsic_Fallback : public ICMonitoredFallbackStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -1741,7 +1741,7 @@ class ICGetIntrinsic_Constant : public ICStub
}
class Compiler : public ICStubCompiler {
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
HandleValue value_;
@@ -1790,7 +1790,7 @@ class ICSetProp_Fallback : public ICFallbackStub
protected:
uint32_t returnOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
void postGenerateStubCode(MacroAssembler& masm, Handle<JitCode*> code);
public:
@@ -1852,7 +1852,7 @@ class ICSetProp_Native : public ICUpdatedStub
(static_cast<int32_t>(obj_->is<UnboxedPlainObject>()) << 18);
}
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, HandleObject obj, bool isFixedSlot, uint32_t offset)
@@ -1958,7 +1958,7 @@ class ICSetPropNativeAddCompiler : public ICStubCompiler
(static_cast<int32_t>(protoChainDepth_) << 19);
}
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
ICSetPropNativeAddCompiler(JSContext* cx, HandleObject obj,
@@ -2024,7 +2024,7 @@ class ICSetProp_Unboxed : public ICUpdatedStub
uint32_t fieldOffset_;
JSValueType fieldType_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2104,7 +2104,7 @@ class ICSetProp_TypedObject : public ICUpdatedStub
TypedThingLayout layout_;
Rooted<SimpleTypeDescr*> fieldDescr_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2251,7 +2251,7 @@ class ICSetProp_CallScripted : public ICSetPropCallSetter
class Compiler : public ICSetPropCallSetter::Compiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, HandleObject obj, HandleObject holder, HandleFunction setter,
@@ -2288,7 +2288,7 @@ class ICSetProp_CallNative : public ICSetPropCallSetter
class Compiler : public ICSetPropCallSetter::Compiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, HandleObject obj, HandleObject holder, HandleFunction setter,
@@ -2398,7 +2398,7 @@ class ICCall_Fallback : public ICMonitoredFallbackStub
bool isConstructing_;
bool isSpread_;
uint32_t returnOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
void postGenerateStubCode(MacroAssembler& masm, Handle<JitCode*> code);
virtual int32_t getKey() const {
@@ -2491,7 +2491,7 @@ class ICCallScriptedCompiler : public ICCallStubCompiler {
RootedFunction callee_;
RootedObject templateObject_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2584,7 +2584,7 @@ class ICCall_Native : public ICMonitoredStub
RootedFunction callee_;
RootedObject templateObject_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2662,7 +2662,7 @@ class ICCall_ClassHook : public ICMonitoredStub
Native native_;
RootedObject templateObject_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2723,7 +2723,7 @@ class ICCall_ScriptedApplyArray : public ICMonitoredStub
protected:
ICStub* firstMonitorStub_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2771,7 +2771,7 @@ class ICCall_ScriptedApplyArguments : public ICMonitoredStub
protected:
ICStub* firstMonitorStub_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2818,7 +2818,7 @@ class ICCall_ScriptedFunCall : public ICMonitoredStub
protected:
ICStub* firstMonitorStub_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2889,7 +2889,7 @@ class ICCall_StringSplit : public ICMonitoredStub
RootedString expectedSep_;
RootedObject templateObject_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2926,7 +2926,7 @@ class ICCall_IsSuspendedStarGenerator : public ICStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -2960,7 +2960,7 @@ class ICTableSwitch : public ICStub
void fixupJumpTable(JSScript* script, BaselineScript* baseline);
class Compiler : public ICStubCompiler {
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
jsbytecode* pc_;
@@ -2985,7 +2985,7 @@ class ICIteratorNew_Fallback : public ICFallbackStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -3018,7 +3018,7 @@ class ICIteratorMore_Fallback : public ICFallbackStub
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -3043,7 +3043,7 @@ class ICIteratorMore_Native : public ICStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -3068,7 +3068,7 @@ class ICIteratorClose_Fallback : public ICFallbackStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -3105,7 +3105,7 @@ class ICInstanceOf_Fallback : public ICFallbackStub
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -3154,7 +3154,7 @@ class ICInstanceOf_Function : public ICStub
uint32_t slot_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, Shape* shape, JSObject* prototypeObj, uint32_t slot)
@@ -3185,7 +3185,7 @@ class ICTypeOf_Fallback : public ICFallbackStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -3218,7 +3218,7 @@ class ICTypeOf_Typed : public ICFallbackStub
protected:
JSType type_;
RootedString typeString_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -3259,7 +3259,7 @@ class ICRest_Fallback : public ICFallbackStub
class Compiler : public ICStubCompiler {
protected:
RootedArrayObject templateObject;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, ArrayObject* templateObject)
@@ -3287,7 +3287,7 @@ class ICRetSub_Fallback : public ICFallbackStub
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx)
@@ -3328,7 +3328,7 @@ class ICRetSub_Resume : public ICStub
uint32_t pcOffset_;
uint8_t* addr_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, uint32_t pcOffset, uint8_t* addr)
diff --git a/js/src/jit/BaselineInspector.h b/js/src/jit/BaselineInspector.h
index 556f28ee5b..9e027c5850 100644
--- a/js/src/jit/BaselineInspector.h
+++ b/js/src/jit/BaselineInspector.h
@@ -89,12 +89,12 @@ class BaselineInspector
}
ICStub* monomorphicStub(jsbytecode* pc);
- MOZ_MUST_USE bool dimorphicStub(jsbytecode* pc, ICStub** pfirst, ICStub** psecond);
+ [[nodiscard]] bool dimorphicStub(jsbytecode* pc, ICStub** pfirst, ICStub** psecond);
public:
typedef Vector<ReceiverGuard, 4, JitAllocPolicy> ReceiverVector;
typedef Vector<ObjectGroup*, 4, JitAllocPolicy> ObjectGroupVector;
- MOZ_MUST_USE bool maybeInfoForPropertyOp(jsbytecode* pc, ReceiverVector& receivers,
+ [[nodiscard]] bool maybeInfoForPropertyOp(jsbytecode* pc, ReceiverVector& receivers,
ObjectGroupVector& convertUnboxedGroups);
SetElemICInspector setElemICInspector(jsbytecode* pc) {
@@ -112,7 +112,7 @@ class BaselineInspector
bool hasSeenDoubleResult(jsbytecode* pc);
bool hasSeenNonStringIterMore(jsbytecode* pc);
- MOZ_MUST_USE bool isOptimizableCallStringSplit(jsbytecode* pc, JSString** strOut,
+ [[nodiscard]] bool isOptimizableCallStringSplit(jsbytecode* pc, JSString** strOut,
JSString** sepOut, JSObject** objOut);
JSObject* getTemplateObject(jsbytecode* pc);
JSObject* getTemplateObjectForNative(jsbytecode* pc, Native native);
@@ -127,16 +127,16 @@ class BaselineInspector
LexicalEnvironmentObject* templateNamedLambdaObject();
CallObject* templateCallObject();
- MOZ_MUST_USE bool commonGetPropFunction(jsbytecode* pc, JSObject** holder, Shape** holderShape,
+ [[nodiscard]] bool commonGetPropFunction(jsbytecode* pc, JSObject** holder, Shape** holderShape,
JSFunction** commonGetter, Shape** globalShape,
bool* isOwnProperty, ReceiverVector& receivers,
ObjectGroupVector& convertUnboxedGroups);
- MOZ_MUST_USE bool commonSetPropFunction(jsbytecode* pc, JSObject** holder, Shape** holderShape,
+ [[nodiscard]] bool commonSetPropFunction(jsbytecode* pc, JSObject** holder, Shape** holderShape,
JSFunction** commonSetter, bool* isOwnProperty,
ReceiverVector& receivers,
ObjectGroupVector& convertUnboxedGroups);
- MOZ_MUST_USE bool instanceOfData(jsbytecode* pc, Shape** shape, uint32_t* slot,
+ [[nodiscard]] bool instanceOfData(jsbytecode* pc, Shape** shape, uint32_t* slot,
JSObject** prototypeObject);
};
diff --git a/js/src/jit/BaselineJIT.h b/js/src/jit/BaselineJIT.h
index dd7a92c6d9..234e60ff96 100644
--- a/js/src/jit/BaselineJIT.h
+++ b/js/src/jit/BaselineJIT.h
@@ -416,7 +416,7 @@ struct BaselineScript
// the result may not be accurate.
jsbytecode* approximatePcForNativeAddress(JSScript* script, uint8_t* nativeAddress);
- MOZ_MUST_USE bool addDependentWasmImport(JSContext* cx, wasm::Instance& instance, uint32_t idx);
+ [[nodiscard]] bool addDependentWasmImport(JSContext* cx, wasm::Instance& instance, uint32_t idx);
void removeDependentWasmImport(wasm::Instance& instance, uint32_t idx);
void unlinkDependentWasmImports(FreeOp* fop);
void clearDependentWasmImports();
diff --git a/js/src/jit/BitSet.h b/js/src/jit/BitSet.h
index d0adeeddd4..9551736344 100644
--- a/js/src/jit/BitSet.h
+++ b/js/src/jit/BitSet.h
@@ -52,7 +52,7 @@ class BitSet
bits_(nullptr),
numBits_(numBits) {}
- MOZ_MUST_USE bool init(TempAllocator& alloc);
+ [[nodiscard]] bool init(TempAllocator& alloc);
unsigned int getNumBits() const {
return numBits_;
diff --git a/js/src/jit/BytecodeAnalysis.h b/js/src/jit/BytecodeAnalysis.h
index 3e9251b7dc..6e3a21ea25 100644
--- a/js/src/jit/BytecodeAnalysis.h
+++ b/js/src/jit/BytecodeAnalysis.h
@@ -44,7 +44,7 @@ class BytecodeAnalysis
public:
explicit BytecodeAnalysis(TempAllocator& alloc, JSScript* script);
- MOZ_MUST_USE bool init(TempAllocator& alloc, GSNCache& gsn);
+ [[nodiscard]] bool init(TempAllocator& alloc, GSNCache& gsn);
BytecodeInfo& info(jsbytecode* pc) {
MOZ_ASSERT(infos_[script_->pcToOffset(pc)].initialized);
diff --git a/js/src/jit/CacheIR.h b/js/src/jit/CacheIR.h
index 4bc523a972..69cc4a4577 100644
--- a/js/src/jit/CacheIR.h
+++ b/js/src/jit/CacheIR.h
@@ -409,18 +409,18 @@ class MOZ_RAII GetPropIRGenerator
enum class PreliminaryObjectAction { None, Unlink, NotePreliminary };
PreliminaryObjectAction preliminaryObjectAction_;
- MOZ_MUST_USE bool tryAttachNative(CacheIRWriter& writer, HandleObject obj, ObjOperandId objId);
- MOZ_MUST_USE bool tryAttachUnboxed(CacheIRWriter& writer, HandleObject obj, ObjOperandId objId);
- MOZ_MUST_USE bool tryAttachUnboxedExpando(CacheIRWriter& writer, HandleObject obj,
+ [[nodiscard]] bool tryAttachNative(CacheIRWriter& writer, HandleObject obj, ObjOperandId objId);
+ [[nodiscard]] bool tryAttachUnboxed(CacheIRWriter& writer, HandleObject obj, ObjOperandId objId);
+ [[nodiscard]] bool tryAttachUnboxedExpando(CacheIRWriter& writer, HandleObject obj,
ObjOperandId objId);
- MOZ_MUST_USE bool tryAttachTypedObject(CacheIRWriter& writer, HandleObject obj,
+ [[nodiscard]] bool tryAttachTypedObject(CacheIRWriter& writer, HandleObject obj,
ObjOperandId objId);
- MOZ_MUST_USE bool tryAttachObjectLength(CacheIRWriter& writer, HandleObject obj,
+ [[nodiscard]] bool tryAttachObjectLength(CacheIRWriter& writer, HandleObject obj,
ObjOperandId objId);
- MOZ_MUST_USE bool tryAttachModuleNamespace(CacheIRWriter& writer, HandleObject obj,
+ [[nodiscard]] bool tryAttachModuleNamespace(CacheIRWriter& writer, HandleObject obj,
ObjOperandId objId);
- MOZ_MUST_USE bool tryAttachPrimitive(CacheIRWriter& writer, ValOperandId valId);
+ [[nodiscard]] bool tryAttachPrimitive(CacheIRWriter& writer, ValOperandId valId);
GetPropIRGenerator(const GetPropIRGenerator&) = delete;
GetPropIRGenerator& operator=(const GetPropIRGenerator&) = delete;
@@ -431,7 +431,7 @@ class MOZ_RAII GetPropIRGenerator
bool emitted() const { return emitted_; }
- MOZ_MUST_USE bool tryAttachStub(mozilla::Maybe<CacheIRWriter>& writer);
+ [[nodiscard]] bool tryAttachStub(mozilla::Maybe<CacheIRWriter>& writer);
bool shouldUnlinkPreliminaryObjectStubs() const {
return preliminaryObjectAction_ == PreliminaryObjectAction::Unlink;
diff --git a/js/src/jit/CodeGenerator.h b/js/src/jit/CodeGenerator.h
index b0fd03538d..bd8549842a 100644
--- a/js/src/jit/CodeGenerator.h
+++ b/js/src/jit/CodeGenerator.h
@@ -56,7 +56,7 @@ class OutOfLineNaNToZero;
class CodeGenerator final : public CodeGeneratorSpecific
{
void generateArgumentsChecks(bool bailout = true);
- MOZ_MUST_USE bool generateBody();
+ [[nodiscard]] bool generateBody();
ConstantOrRegister toConstantOrRegister(LInstruction* lir, size_t n, MIRType type);
@@ -65,11 +65,11 @@ class CodeGenerator final : public CodeGeneratorSpecific
~CodeGenerator();
public:
- MOZ_MUST_USE bool generate();
- MOZ_MUST_USE bool generateWasm(wasm::SigIdDesc sigId, wasm::TrapOffset trapOffset,
+ [[nodiscard]] bool generate();
+ [[nodiscard]] bool generateWasm(wasm::SigIdDesc sigId, wasm::TrapOffset trapOffset,
wasm::FuncOffsets *offsets);
- MOZ_MUST_USE bool link(JSContext* cx, CompilerConstraintList* constraints);
- MOZ_MUST_USE bool linkSharedStubs(JSContext* cx);
+ [[nodiscard]] bool link(JSContext* cx, CompilerConstraintList* constraints);
+ [[nodiscard]] bool linkSharedStubs(JSContext* cx);
void visitOsiPoint(LOsiPoint* lir);
void visitGoto(LGoto* lir);
@@ -466,7 +466,7 @@ class CodeGenerator final : public CodeGeneratorSpecific
bool strict, bool needsTypeBarrier, bool guardHoles,
jsbytecode* profilerLeavePc);
- MOZ_MUST_USE bool generateBranchV(const ValueOperand& value, Label* ifTrue, Label* ifFalse,
+ [[nodiscard]] bool generateBranchV(const ValueOperand& value, Label* ifTrue, Label* ifFalse,
FloatRegister fr);
void emitLambdaInit(Register resultReg, Register envChainReg,
diff --git a/js/src/jit/EdgeCaseAnalysis.h b/js/src/jit/EdgeCaseAnalysis.h
index 86e10d83e5..bc6827a16b 100644
--- a/js/src/jit/EdgeCaseAnalysis.h
+++ b/js/src/jit/EdgeCaseAnalysis.h
@@ -20,7 +20,7 @@ class EdgeCaseAnalysis
public:
EdgeCaseAnalysis(MIRGenerator* mir, MIRGraph& graph);
- MOZ_MUST_USE bool analyzeLate();
+ [[nodiscard]] bool analyzeLate();
};
diff --git a/js/src/jit/EffectiveAddressAnalysis.h b/js/src/jit/EffectiveAddressAnalysis.h
index a912cc34d1..f2cf933027 100644
--- a/js/src/jit/EffectiveAddressAnalysis.h
+++ b/js/src/jit/EffectiveAddressAnalysis.h
@@ -19,7 +19,7 @@ class EffectiveAddressAnalysis
MIRGraph& graph_;
template <typename AsmJSMemoryAccess>
- MOZ_MUST_USE bool tryAddDisplacement(AsmJSMemoryAccess* ins, int32_t o);
+ [[nodiscard]] bool tryAddDisplacement(AsmJSMemoryAccess* ins, int32_t o);
template <typename AsmJSMemoryAccess>
void analyzeAsmJSHeapAccess(AsmJSMemoryAccess* ins);
@@ -29,7 +29,7 @@ class EffectiveAddressAnalysis
: mir_(mir), graph_(graph)
{}
- MOZ_MUST_USE bool analyze();
+ [[nodiscard]] bool analyze();
};
} /* namespace jit */
diff --git a/js/src/jit/ExecutableAllocator.h b/js/src/jit/ExecutableAllocator.h
index c16809c818..7932602c79 100644
--- a/js/src/jit/ExecutableAllocator.h
+++ b/js/src/jit/ExecutableAllocator.h
@@ -190,13 +190,13 @@ class ExecutableAllocator
static void reprotectPool(JSRuntime* rt, ExecutablePool* pool, ProtectionSetting protection);
public:
- MOZ_MUST_USE
+ [[nodiscard]]
static bool makeWritable(void* start, size_t size)
{
return ReprotectRegion(start, size, ProtectionSetting::Writable);
}
- MOZ_MUST_USE
+ [[nodiscard]]
static bool makeExecutable(void* start, size_t size)
{
return ReprotectRegion(start, size, ProtectionSetting::Executable);
diff --git a/js/src/jit/FixedList.h b/js/src/jit/FixedList.h
index 23f4367dc7..9780d58c9f 100644
--- a/js/src/jit/FixedList.h
+++ b/js/src/jit/FixedList.h
@@ -31,7 +31,7 @@ class FixedList
{ }
// Dynamic memory allocation requires the ability to report failure.
- MOZ_MUST_USE bool init(TempAllocator& alloc, size_t length) {
+ [[nodiscard]] bool init(TempAllocator& alloc, size_t length) {
if (length == 0)
return true;
@@ -59,7 +59,7 @@ class FixedList
length_ -= num;
}
- MOZ_MUST_USE bool growBy(TempAllocator& alloc, size_t num) {
+ [[nodiscard]] bool growBy(TempAllocator& alloc, size_t num) {
size_t newlength = length_ + num;
if (newlength < length_)
return false;
diff --git a/js/src/jit/FlowAliasAnalysis.h b/js/src/jit/FlowAliasAnalysis.h
index 91309d0d49..3779014b02 100644
--- a/js/src/jit/FlowAliasAnalysis.h
+++ b/js/src/jit/FlowAliasAnalysis.h
@@ -32,34 +32,34 @@ class FlowAliasAnalysis : public AliasAnalysisShared
public:
FlowAliasAnalysis(MIRGenerator* mir, MIRGraph& graph);
- MOZ_MUST_USE bool analyze() override;
+ [[nodiscard]] bool analyze() override;
protected:
/* Process instructions. */
- MOZ_MUST_USE bool processStore(BlockStoreInfo& stores, MDefinition* store);
- MOZ_MUST_USE bool processLoad(BlockStoreInfo& stores, MDefinition* load);
- MOZ_MUST_USE bool processDeferredLoads(LoopInfo* info);
+ [[nodiscard]] bool processStore(BlockStoreInfo& stores, MDefinition* store);
+ [[nodiscard]] bool processLoad(BlockStoreInfo& stores, MDefinition* load);
+ [[nodiscard]] bool processDeferredLoads(LoopInfo* info);
/* Improve dependency and helpers. */
- MOZ_MUST_USE bool improveDependency(MDefinition* load, MDefinitionVector& inputStores,
- MDefinitionVector& outputStores);
- MOZ_MUST_USE bool improveNonAliasedStores(MDefinition* load, MDefinitionVector& inputStores,
- MDefinitionVector& outputStores, bool* improved,
- bool onlyControlInstructions = false);
- MOZ_MUST_USE bool improveStoresInFinishedLoops(MDefinition* load, MDefinitionVector& stores,
- bool* improved);
-
- MOZ_MUST_USE bool improveLoopDependency(MDefinition* load, MDefinitionVector& inputStores,
- MDefinitionVector& outputStores);
- MOZ_MUST_USE bool deferImproveDependency(MDefinitionVector& stores);
+ [[nodiscard]] bool improveDependency(MDefinition* load, MDefinitionVector& inputStores,
+ MDefinitionVector& outputStores);
+ [[nodiscard]] bool improveNonAliasedStores(MDefinition* load, MDefinitionVector& inputStores,
+ MDefinitionVector& outputStores, bool* improved,
+ bool onlyControlInstructions = false);
+ [[nodiscard]] bool improveStoresInFinishedLoops(MDefinition* load, MDefinitionVector& stores,
+ bool* improved);
+
+ [[nodiscard]] bool improveLoopDependency(MDefinition* load, MDefinitionVector& inputStores,
+ MDefinitionVector& outputStores);
+ [[nodiscard]] bool deferImproveDependency(MDefinitionVector& stores);
/* Save dependency info. */
void saveLoadDependency(MDefinition* load, MDefinitionVector& dependencies);
- MOZ_MUST_USE bool saveStoreDependency(MDefinition* store, BlockStoreInfo& prevStores);
+ [[nodiscard]] bool saveStoreDependency(MDefinition* store, BlockStoreInfo& prevStores);
/* Helper functions. */
- MOZ_MUST_USE bool computeBlockStores(MBasicBlock* block);
- MOZ_MUST_USE bool isLoopInvariant(MDefinition* load, MDefinition* store, bool* loopinvariant);
+ [[nodiscard]] bool computeBlockStores(MBasicBlock* block);
+ [[nodiscard]] bool isLoopInvariant(MDefinition* load, MDefinition* store, bool* loopinvariant);
bool loopIsFinished(MBasicBlock* loopheader);
};
diff --git a/js/src/jit/FoldLinearArithConstants.h b/js/src/jit/FoldLinearArithConstants.h
index 2a493e1b9e..67a0980b6c 100644
--- a/js/src/jit/FoldLinearArithConstants.h
+++ b/js/src/jit/FoldLinearArithConstants.h
@@ -12,8 +12,7 @@
namespace js {
namespace jit {
-MOZ_MUST_USE bool
-FoldLinearArithConstants(MIRGenerator* mir, MIRGraph& graph);
+[[nodiscard]] bool FoldLinearArithConstants(MIRGenerator* mir, MIRGraph& graph);
} /* namespace jit */
} /* namespace js */
diff --git a/js/src/jit/InstructionReordering.h b/js/src/jit/InstructionReordering.h
index b43b9f55e9..baa904dfcd 100644
--- a/js/src/jit/InstructionReordering.h
+++ b/js/src/jit/InstructionReordering.h
@@ -11,8 +11,7 @@
namespace js {
namespace jit {
-MOZ_MUST_USE bool
-ReorderInstructions(MIRGenerator* mir, MIRGraph& graph);
+[[nodiscard]] bool ReorderInstructions(MIRGenerator* mir, MIRGraph& graph);
} // namespace jit
} // namespace js
diff --git a/js/src/jit/Ion.h b/js/src/jit/Ion.h
index 59a7823499..55709414ba 100644
--- a/js/src/jit/Ion.h
+++ b/js/src/jit/Ion.h
@@ -81,7 +81,7 @@ class JitContext
};
// Initialize Ion statically for all JSRuntimes.
-MOZ_MUST_USE bool InitializeIon();
+[[nodiscard]] bool InitializeIon();
// Get and set the current JIT context.
JitContext* GetJitContext();
@@ -91,7 +91,7 @@ void SetJitContext(JitContext* ctx);
bool CanIonCompileScript(JSContext* cx, JSScript* script, bool osr);
-MOZ_MUST_USE bool IonCompileScriptForBaseline(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
+[[nodiscard]] bool IonCompileScriptForBaseline(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
MethodStatus CanEnter(JSContext* cx, RunState& state);
MethodStatus CanEnterUsingFastInvoke(JSContext* cx, HandleScript script, uint32_t numActualArgs);
@@ -122,8 +122,8 @@ IsErrorStatus(JitExecStatus status)
struct EnterJitData;
-MOZ_MUST_USE bool SetEnterJitData(JSContext* cx, EnterJitData& data, RunState& state,
- MutableHandle<GCVector<Value>> vals);
+[[nodiscard]] bool SetEnterJitData(JSContext* cx, EnterJitData& data, RunState& state,
+ MutableHandle<GCVector<Value>> vals);
JitExecStatus IonCannon(JSContext* cx, RunState& state);
@@ -146,7 +146,7 @@ class MIRGenerator;
class LIRGraph;
class CodeGenerator;
-MOZ_MUST_USE bool OptimizeMIR(MIRGenerator* mir);
+[[nodiscard]] bool OptimizeMIR(MIRGenerator* mir);
LIRGraph* GenerateLIR(MIRGenerator* mir);
CodeGenerator* GenerateCode(MIRGenerator* mir, LIRGraph* lir);
CodeGenerator* CompileBackEnd(MIRGenerator* mir);
diff --git a/js/src/jit/IonAnalysis.cpp b/js/src/jit/IonAnalysis.cpp
index aa8f8164b5..ded3ea17ad 100644
--- a/js/src/jit/IonAnalysis.cpp
+++ b/js/src/jit/IonAnalysis.cpp
@@ -4465,7 +4465,7 @@ JS_FOR_EACH_TRACEKIND(TRACE_ROOTS)
#undef TRACE_ROOTS
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
jit::CreateMIRRootList(IonBuilder& builder)
{
MOZ_ASSERT(!builder.info().isAnalysis());
diff --git a/js/src/jit/IonAnalysis.h b/js/src/jit/IonAnalysis.h
index e6b7fa2aa2..6434da6a67 100644
--- a/js/src/jit/IonAnalysis.h
+++ b/js/src/jit/IonAnalysis.h
@@ -17,13 +17,13 @@ namespace jit {
class MIRGenerator;
class MIRGraph;
-MOZ_MUST_USE bool
+[[nodiscard]] bool
PruneUnusedBranches(MIRGenerator* mir, MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
FoldTests(MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
SplitCriticalEdges(MIRGraph& graph);
bool
@@ -34,7 +34,7 @@ enum Observability {
AggressiveObservability
};
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EliminatePhis(MIRGenerator* mir, MIRGraph& graph, Observability observe);
size_t
@@ -43,38 +43,38 @@ MarkLoopBlocks(MIRGraph& graph, MBasicBlock* header, bool* canOsr);
void
UnmarkLoopBlocks(MIRGraph& graph, MBasicBlock* header);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
MakeLoopsContiguous(MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EliminateDeadResumePointOperands(MIRGenerator* mir, MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EliminateDeadCode(MIRGenerator* mir, MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ApplyTypeInformation(MIRGenerator* mir, MIRGraph& graph);
void
RenumberBlocks(MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AccountForCFGChanges(MIRGenerator* mir, MIRGraph& graph, bool updateAliasAnalysis,
bool underValueNumberer = false);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RemoveUnmarkedBlocks(MIRGenerator* mir, MIRGraph& graph, uint32_t numMarkedBlocks);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CreateMIRRootList(IonBuilder& builder);
void
ClearDominatorTree(MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BuildDominatorTree(MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BuildPhiReverseMapping(MIRGraph& graph);
void
@@ -86,10 +86,10 @@ AssertGraphCoherency(MIRGraph& graph);
void
AssertExtendedGraphCoherency(MIRGraph& graph, bool underValueNumberer = false);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EliminateRedundantChecks(MIRGraph& graph);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AddKeepAliveInstructions(MIRGraph& graph);
class MDefinition;
@@ -121,7 +121,7 @@ enum class MathSpace {
SimpleLinearSum
ExtractLinearSum(MDefinition* ins, MathSpace space = MathSpace::Unknown);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ExtractLinearInequality(MTest* test, BranchDirection direction,
SimpleLinearSum* plhs, MDefinition** prhs, bool* plessEqual);
@@ -157,15 +157,15 @@ class LinearSum
// These return false on an integer overflow, and afterwards the sum must
// not be used.
- MOZ_MUST_USE bool multiply(int32_t scale);
- MOZ_MUST_USE bool add(const LinearSum& other, int32_t scale = 1);
- MOZ_MUST_USE bool add(SimpleLinearSum other, int32_t scale = 1);
- MOZ_MUST_USE bool add(MDefinition* term, int32_t scale);
- MOZ_MUST_USE bool add(int32_t constant);
+ [[nodiscard]] bool multiply(int32_t scale);
+ [[nodiscard]] bool add(const LinearSum& other, int32_t scale = 1);
+ [[nodiscard]] bool add(SimpleLinearSum other, int32_t scale = 1);
+ [[nodiscard]] bool add(MDefinition* term, int32_t scale);
+ [[nodiscard]] bool add(int32_t constant);
// Unlike the above function, on failure this leaves the sum unchanged and
// it can still be used.
- MOZ_MUST_USE bool divide(uint32_t scale);
+ [[nodiscard]] bool divide(uint32_t scale);
int32_t constant() const { return constant_; }
size_t numTerms() const { return terms_.length(); }
@@ -191,7 +191,7 @@ ConvertLinearSum(TempAllocator& alloc, MBasicBlock* block, const LinearSum& sum,
MCompare*
ConvertLinearInequality(TempAllocator& alloc, MBasicBlock* block, const LinearSum& sum);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AnalyzeNewScriptDefiniteProperties(JSContext* cx,
DPAConstraintInfo& constraintInfo,
HandleFunction fun,
@@ -199,7 +199,7 @@ AnalyzeNewScriptDefiniteProperties(JSContext* cx,
HandlePlainObject baseobj,
Vector<TypeNewScript::Initializer>* initializerList);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
AnalyzeArgumentsUsage(JSContext* cx, JSScript* script);
bool
diff --git a/js/src/jit/IonBuilder.h b/js/src/jit/IonBuilder.h
index 8f616b74eb..c5275d7b89 100644
--- a/js/src/jit/IonBuilder.h
+++ b/js/src/jit/IonBuilder.h
@@ -217,15 +217,15 @@ class IonBuilder
// Callers of build() and buildInline() should always check whether the
// call overrecursed, if false is returned. Overrecursion is not
// signaled as OOM and will not in general be caught by OOM paths.
- MOZ_MUST_USE bool build();
- MOZ_MUST_USE bool buildInline(IonBuilder* callerBuilder, MResumePoint* callerResumePoint,
+ [[nodiscard]] bool build();
+ [[nodiscard]] bool buildInline(IonBuilder* callerBuilder, MResumePoint* callerResumePoint,
CallInfo& callInfo);
private:
- MOZ_MUST_USE bool traverseBytecode();
+ [[nodiscard]] bool traverseBytecode();
ControlStatus snoopControlFlow(JSOp op);
- MOZ_MUST_USE bool processIterators();
- MOZ_MUST_USE bool inspectOpcode(JSOp op);
+ [[nodiscard]] bool processIterators();
+ [[nodiscard]] bool inspectOpcode(JSOp op);
uint32_t readIndex(jsbytecode* pc);
JSAtom* readAtom(jsbytecode* pc);
bool abort(const char* message, ...) MOZ_FORMAT_PRINTF(2, 3);
@@ -233,12 +233,12 @@ class IonBuilder
void spew(const char* message);
JSFunction* getSingleCallTarget(TemporaryTypeSet* calleeTypes);
- MOZ_MUST_USE bool getPolyCallTargets(TemporaryTypeSet* calleeTypes, bool constructing,
+ [[nodiscard]] bool getPolyCallTargets(TemporaryTypeSet* calleeTypes, bool constructing,
ObjectVector& targets, uint32_t maxTargets);
void popCfgStack();
DeferredEdge* filterDeadDeferredEdges(DeferredEdge* edge);
- MOZ_MUST_USE bool processDeferredContinues(CFGState& state);
+ [[nodiscard]] bool processDeferredContinues(CFGState& state);
ControlStatus processControlEnd();
ControlStatus processCfgStack();
ControlStatus processCfgEntry(CFGState& state);
@@ -265,11 +265,11 @@ class IonBuilder
ControlStatus processContinue(JSOp op);
ControlStatus processBreak(JSOp op, jssrcnote* sn);
ControlStatus maybeLoop(JSOp op, jssrcnote* sn);
- MOZ_MUST_USE bool pushLoop(CFGState::State state, jsbytecode* stopAt, MBasicBlock* entry,
+ [[nodiscard]] bool pushLoop(CFGState::State state, jsbytecode* stopAt, MBasicBlock* entry,
bool osr, jsbytecode* loopHead, jsbytecode* initialPc,
jsbytecode* bodyStart, jsbytecode* bodyEnd,
jsbytecode* exitpc, jsbytecode* continuepc);
- MOZ_MUST_USE bool analyzeNewLoopTypes(MBasicBlock* entry, jsbytecode* start, jsbytecode* end);
+ [[nodiscard]] bool analyzeNewLoopTypes(MBasicBlock* entry, jsbytecode* start, jsbytecode* end);
MBasicBlock* addBlock(MBasicBlock* block, uint32_t loopDepth);
MBasicBlock* newBlock(MBasicBlock* predecessor, jsbytecode* pc);
@@ -310,9 +310,9 @@ class IonBuilder
// Incorporates a type/typeSet into an OSR value for a loop, after the loop
// body has been processed.
- MOZ_MUST_USE bool addOsrValueTypeBarrier(uint32_t slot, MInstruction** def,
+ [[nodiscard]] bool addOsrValueTypeBarrier(uint32_t slot, MInstruction** def,
MIRType type, TemporaryTypeSet* typeSet);
- MOZ_MUST_USE bool maybeAddOsrTypeBarriers();
+ [[nodiscard]] bool maybeAddOsrTypeBarriers();
// Restarts processing of a loop if the type information at its header was
// incomplete.
@@ -328,19 +328,19 @@ class IonBuilder
// Please see the Big Honkin' Comment about how resume points work in
// IonBuilder.cpp, near the definition for this function.
- MOZ_MUST_USE bool resume(MInstruction* ins, jsbytecode* pc, MResumePoint::Mode mode);
- MOZ_MUST_USE bool resumeAt(MInstruction* ins, jsbytecode* pc);
- MOZ_MUST_USE bool resumeAfter(MInstruction* ins);
- MOZ_MUST_USE bool maybeInsertResume();
+ [[nodiscard]] bool resume(MInstruction* ins, jsbytecode* pc, MResumePoint::Mode mode);
+ [[nodiscard]] bool resumeAt(MInstruction* ins, jsbytecode* pc);
+ [[nodiscard]] bool resumeAfter(MInstruction* ins);
+ [[nodiscard]] bool maybeInsertResume();
void insertRecompileCheck();
- MOZ_MUST_USE bool initParameters();
+ [[nodiscard]] bool initParameters();
void initLocals();
void rewriteParameter(uint32_t slotIdx, MDefinition* param, int32_t argIndex);
- MOZ_MUST_USE bool rewriteParameters();
- MOZ_MUST_USE bool initEnvironmentChain(MDefinition* callee = nullptr);
- MOZ_MUST_USE bool initArgumentsObject();
+ [[nodiscard]] bool rewriteParameters();
+ [[nodiscard]] bool initEnvironmentChain(MDefinition* callee = nullptr);
+ [[nodiscard]] bool initArgumentsObject();
void pushConstant(const Value& v);
MConstant* constant(const Value& v);
@@ -350,27 +350,27 @@ class IonBuilder
MInstruction* setInitializedLength(MDefinition* obj, JSValueType unboxedType, size_t count);
// Improve the type information at tests
- MOZ_MUST_USE bool improveTypesAtTest(MDefinition* ins, bool trueBranch, MTest* test);
- MOZ_MUST_USE bool improveTypesAtCompare(MCompare* ins, bool trueBranch, MTest* test);
- MOZ_MUST_USE bool improveTypesAtNullOrUndefinedCompare(MCompare* ins, bool trueBranch,
+ [[nodiscard]] bool improveTypesAtTest(MDefinition* ins, bool trueBranch, MTest* test);
+ [[nodiscard]] bool improveTypesAtCompare(MCompare* ins, bool trueBranch, MTest* test);
+ [[nodiscard]] bool improveTypesAtNullOrUndefinedCompare(MCompare* ins, bool trueBranch,
MTest* test);
- MOZ_MUST_USE bool improveTypesAtTypeOfCompare(MCompare* ins, bool trueBranch, MTest* test);
+ [[nodiscard]] bool improveTypesAtTypeOfCompare(MCompare* ins, bool trueBranch, MTest* test);
// Used to detect triangular structure at test.
- MOZ_MUST_USE bool detectAndOrStructure(MPhi* ins, bool* branchIsTrue);
- MOZ_MUST_USE bool replaceTypeSet(MDefinition* subject, TemporaryTypeSet* type, MTest* test);
+ [[nodiscard]] bool detectAndOrStructure(MPhi* ins, bool* branchIsTrue);
+ [[nodiscard]] bool replaceTypeSet(MDefinition* subject, TemporaryTypeSet* type, MTest* test);
// Add a guard which ensure that the set of type which goes through this
// generated code correspond to the observed types for the bytecode.
MDefinition* addTypeBarrier(MDefinition* def, TemporaryTypeSet* observed,
BarrierKind kind, MTypeBarrier** pbarrier = nullptr);
- MOZ_MUST_USE bool pushTypeBarrier(MDefinition* def, TemporaryTypeSet* observed,
+ [[nodiscard]] bool pushTypeBarrier(MDefinition* def, TemporaryTypeSet* observed,
BarrierKind kind);
// As pushTypeBarrier, but will compute the needBarrier boolean itself based
// on observed and the JSFunction that we're planning to call. The
// JSFunction must be a DOM method or getter.
- MOZ_MUST_USE bool pushDOMTypeBarrier(MInstruction* ins, TemporaryTypeSet* observed,
+ [[nodiscard]] bool pushDOMTypeBarrier(MInstruction* ins, TemporaryTypeSet* observed,
JSFunction* func);
// If definiteType is not known or def already has the right type, just
@@ -412,13 +412,13 @@ class IonBuilder
bool invalidatedIdempotentCache();
bool hasStaticEnvironmentObject(EnvironmentCoordinate ec, JSObject** pcall);
- MOZ_MUST_USE bool loadSlot(MDefinition* obj, size_t slot, size_t nfixed, MIRType rvalType,
+ [[nodiscard]] bool loadSlot(MDefinition* obj, size_t slot, size_t nfixed, MIRType rvalType,
BarrierKind barrier, TemporaryTypeSet* types);
- MOZ_MUST_USE bool loadSlot(MDefinition* obj, Shape* shape, MIRType rvalType,
+ [[nodiscard]] bool loadSlot(MDefinition* obj, Shape* shape, MIRType rvalType,
BarrierKind barrier, TemporaryTypeSet* types);
- MOZ_MUST_USE bool storeSlot(MDefinition* obj, size_t slot, size_t nfixed, MDefinition* value,
+ [[nodiscard]] bool storeSlot(MDefinition* obj, size_t slot, size_t nfixed, MDefinition* value,
bool needsBarrier, MIRType slotType = MIRType::None);
- MOZ_MUST_USE bool storeSlot(MDefinition* obj, Shape* shape, MDefinition* value,
+ [[nodiscard]] bool storeSlot(MDefinition* obj, Shape* shape, MDefinition* value,
bool needsBarrier, MIRType slotType = MIRType::None);
bool shouldAbortOnPreliminaryGroups(MDefinition *obj);
@@ -426,135 +426,135 @@ class IonBuilder
MDefinition* maybeUnboxForPropertyAccess(MDefinition* def);
// jsop_getprop() helpers.
- MOZ_MUST_USE bool checkIsDefinitelyOptimizedArguments(MDefinition* obj, bool* isOptimizedArgs);
- MOZ_MUST_USE bool getPropTryInferredConstant(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool checkIsDefinitelyOptimizedArguments(MDefinition* obj, bool* isOptimizedArgs);
+ [[nodiscard]] bool getPropTryInferredConstant(bool* emitted, MDefinition* obj,
PropertyName* name, TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryArgumentsLength(bool* emitted, MDefinition* obj);
- MOZ_MUST_USE bool getPropTryArgumentsCallee(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool getPropTryArgumentsLength(bool* emitted, MDefinition* obj);
+ [[nodiscard]] bool getPropTryArgumentsCallee(bool* emitted, MDefinition* obj,
PropertyName* name);
- MOZ_MUST_USE bool getPropTryConstant(bool* emitted, MDefinition* obj, jsid id,
+ [[nodiscard]] bool getPropTryConstant(bool* emitted, MDefinition* obj, jsid id,
TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryNotDefined(bool* emitted, MDefinition* obj, jsid id,
+ [[nodiscard]] bool getPropTryNotDefined(bool* emitted, MDefinition* obj, jsid id,
TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryDefiniteSlot(bool* emitted, MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool getPropTryDefiniteSlot(bool* emitted, MDefinition* obj, PropertyName* name,
BarrierKind barrier, TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryModuleNamespace(bool* emitted, MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool getPropTryModuleNamespace(bool* emitted, MDefinition* obj, PropertyName* name,
BarrierKind barrier, TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryUnboxed(bool* emitted, MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool getPropTryUnboxed(bool* emitted, MDefinition* obj, PropertyName* name,
BarrierKind barrier, TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryCommonGetter(bool* emitted, MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool getPropTryCommonGetter(bool* emitted, MDefinition* obj, PropertyName* name,
TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryInlineAccess(bool* emitted, MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool getPropTryInlineAccess(bool* emitted, MDefinition* obj, PropertyName* name,
BarrierKind barrier, TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryTypedObject(bool* emitted, MDefinition* obj, PropertyName* name);
- MOZ_MUST_USE bool getPropTryScalarPropOfTypedObject(bool* emitted, MDefinition* typedObj,
+ [[nodiscard]] bool getPropTryTypedObject(bool* emitted, MDefinition* obj, PropertyName* name);
+ [[nodiscard]] bool getPropTryScalarPropOfTypedObject(bool* emitted, MDefinition* typedObj,
int32_t fieldOffset,
TypedObjectPrediction fieldTypeReprs);
- MOZ_MUST_USE bool getPropTryReferencePropOfTypedObject(bool* emitted, MDefinition* typedObj,
+ [[nodiscard]] bool getPropTryReferencePropOfTypedObject(bool* emitted, MDefinition* typedObj,
int32_t fieldOffset,
TypedObjectPrediction fieldPrediction,
PropertyName* name);
- MOZ_MUST_USE bool getPropTryComplexPropOfTypedObject(bool* emitted, MDefinition* typedObj,
+ [[nodiscard]] bool getPropTryComplexPropOfTypedObject(bool* emitted, MDefinition* typedObj,
int32_t fieldOffset,
TypedObjectPrediction fieldTypeReprs,
size_t fieldIndex);
- MOZ_MUST_USE bool getPropTryInnerize(bool* emitted, MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool getPropTryInnerize(bool* emitted, MDefinition* obj, PropertyName* name,
TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTryCache(bool* emitted, MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool getPropTryCache(bool* emitted, MDefinition* obj, PropertyName* name,
BarrierKind barrier, TemporaryTypeSet* types);
- MOZ_MUST_USE bool getPropTrySharedStub(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool getPropTrySharedStub(bool* emitted, MDefinition* obj,
TemporaryTypeSet* types);
// jsop_setprop() helpers.
- MOZ_MUST_USE bool setPropTryCommonSetter(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryCommonSetter(bool* emitted, MDefinition* obj,
PropertyName* name, MDefinition* value);
- MOZ_MUST_USE bool setPropTryCommonDOMSetter(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryCommonDOMSetter(bool* emitted, MDefinition* obj,
MDefinition* value, JSFunction* setter,
TemporaryTypeSet* objTypes);
- MOZ_MUST_USE bool setPropTryDefiniteSlot(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryDefiniteSlot(bool* emitted, MDefinition* obj,
PropertyName* name, MDefinition* value,
bool barrier, TemporaryTypeSet* objTypes);
- MOZ_MUST_USE bool setPropTryUnboxed(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryUnboxed(bool* emitted, MDefinition* obj,
PropertyName* name, MDefinition* value,
bool barrier, TemporaryTypeSet* objTypes);
- MOZ_MUST_USE bool setPropTryInlineAccess(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryInlineAccess(bool* emitted, MDefinition* obj,
PropertyName* name, MDefinition* value,
bool barrier, TemporaryTypeSet* objTypes);
- MOZ_MUST_USE bool setPropTryTypedObject(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryTypedObject(bool* emitted, MDefinition* obj,
PropertyName* name, MDefinition* value);
- MOZ_MUST_USE bool setPropTryReferencePropOfTypedObject(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryReferencePropOfTypedObject(bool* emitted, MDefinition* obj,
int32_t fieldOffset, MDefinition* value,
TypedObjectPrediction fieldPrediction,
PropertyName* name);
- MOZ_MUST_USE bool setPropTryScalarPropOfTypedObject(bool* emitted,
+ [[nodiscard]] bool setPropTryScalarPropOfTypedObject(bool* emitted,
MDefinition* obj,
int32_t fieldOffset,
MDefinition* value,
TypedObjectPrediction fieldTypeReprs);
- MOZ_MUST_USE bool setPropTryCache(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setPropTryCache(bool* emitted, MDefinition* obj,
PropertyName* name, MDefinition* value,
bool barrier, TemporaryTypeSet* objTypes);
// jsop_binary_arith helpers.
MBinaryArithInstruction* binaryArithInstruction(JSOp op, MDefinition* left, MDefinition* right);
MIRType binaryArithNumberSpecialization(MDefinition* left, MDefinition* right);
- MOZ_MUST_USE bool binaryArithTryConcat(bool* emitted, JSOp op, MDefinition* left,
+ [[nodiscard]] bool binaryArithTryConcat(bool* emitted, JSOp op, MDefinition* left,
MDefinition* right);
- MOZ_MUST_USE MBinaryArithInstruction* binaryArithEmitSpecialized(MDefinition::Opcode op,
+ [[nodiscard]] MBinaryArithInstruction* binaryArithEmitSpecialized(MDefinition::Opcode op,
MIRType specialization,
MDefinition* left,
MDefinition* right);
- MOZ_MUST_USE bool binaryArithTrySpecialized(bool* emitted, JSOp op, MDefinition* left,
+ [[nodiscard]] bool binaryArithTrySpecialized(bool* emitted, JSOp op, MDefinition* left,
MDefinition* right);
- MOZ_MUST_USE bool binaryArithTrySpecializedOnBaselineInspector(bool* emitted, JSOp op,
+ [[nodiscard]] bool binaryArithTrySpecializedOnBaselineInspector(bool* emitted, JSOp op,
MDefinition* left,
MDefinition* right);
- MOZ_MUST_USE bool arithTrySharedStub(bool* emitted, JSOp op, MDefinition* left,
+ [[nodiscard]] bool arithTrySharedStub(bool* emitted, JSOp op, MDefinition* left,
MDefinition* right);
// jsop_bitnot helpers.
- MOZ_MUST_USE bool bitnotTrySpecialized(bool* emitted, MDefinition* input);
+ [[nodiscard]] bool bitnotTrySpecialized(bool* emitted, MDefinition* input);
// jsop_inc_or_dec helpers.
MDefinition* unaryArithConvertToBinary(JSOp op, MDefinition::Opcode* defOp);
- MOZ_MUST_USE bool unaryArithTrySpecialized(bool* emitted, JSOp op, MDefinition* value);
- MOZ_MUST_USE bool unaryArithTrySpecializedOnBaselineInspector(bool* emitted, JSOp op,
+ [[nodiscard]] bool unaryArithTrySpecialized(bool* emitted, JSOp op, MDefinition* value);
+ [[nodiscard]] bool unaryArithTrySpecializedOnBaselineInspector(bool* emitted, JSOp op,
MDefinition* value);
// jsop_pow helpers.
- MOZ_MUST_USE bool powTrySpecialized(bool* emitted, MDefinition* base, MDefinition* power,
+ [[nodiscard]] bool powTrySpecialized(bool* emitted, MDefinition* base, MDefinition* power,
MIRType outputType);
// jsop_compare helpers.
- MOZ_MUST_USE bool compareTrySpecialized(bool* emitted, JSOp op, MDefinition* left,
+ [[nodiscard]] bool compareTrySpecialized(bool* emitted, JSOp op, MDefinition* left,
MDefinition* right);
- MOZ_MUST_USE bool compareTryBitwise(bool* emitted, JSOp op, MDefinition* left,
+ [[nodiscard]] bool compareTryBitwise(bool* emitted, JSOp op, MDefinition* left,
MDefinition* right);
- MOZ_MUST_USE bool compareTrySpecializedOnBaselineInspector(bool* emitted, JSOp op,
+ [[nodiscard]] bool compareTrySpecializedOnBaselineInspector(bool* emitted, JSOp op,
MDefinition* left,
MDefinition* right);
- MOZ_MUST_USE bool compareTrySharedStub(bool* emitted, JSOp op, MDefinition* left,
+ [[nodiscard]] bool compareTrySharedStub(bool* emitted, JSOp op, MDefinition* left,
MDefinition* right);
// jsop_newarray helpers.
- MOZ_MUST_USE bool newArrayTrySharedStub(bool* emitted);
- MOZ_MUST_USE bool newArrayTryTemplateObject(bool* emitted, JSObject* templateObject,
+ [[nodiscard]] bool newArrayTrySharedStub(bool* emitted);
+ [[nodiscard]] bool newArrayTryTemplateObject(bool* emitted, JSObject* templateObject,
uint32_t length);
- MOZ_MUST_USE bool newArrayTryVM(bool* emitted, JSObject* templateObject, uint32_t length);
+ [[nodiscard]] bool newArrayTryVM(bool* emitted, JSObject* templateObject, uint32_t length);
// jsop_newobject helpers.
- MOZ_MUST_USE bool newObjectTrySharedStub(bool* emitted);
- MOZ_MUST_USE bool newObjectTryTemplateObject(bool* emitted, JSObject* templateObject);
- MOZ_MUST_USE bool newObjectTryVM(bool* emitted, JSObject* templateObject);
+ [[nodiscard]] bool newObjectTrySharedStub(bool* emitted);
+ [[nodiscard]] bool newObjectTryTemplateObject(bool* emitted, JSObject* templateObject);
+ [[nodiscard]] bool newObjectTryVM(bool* emitted, JSObject* templateObject);
// jsop_in helpers.
- MOZ_MUST_USE bool inTryDense(bool* emitted, MDefinition* obj, MDefinition* id);
- MOZ_MUST_USE bool inTryFold(bool* emitted, MDefinition* obj, MDefinition* id);
+ [[nodiscard]] bool inTryDense(bool* emitted, MDefinition* obj, MDefinition* id);
+ [[nodiscard]] bool inTryFold(bool* emitted, MDefinition* obj, MDefinition* id);
// binary data lookup helpers.
TypedObjectPrediction typedObjectPrediction(MDefinition* typedObj);
TypedObjectPrediction typedObjectPrediction(TemporaryTypeSet* types);
- MOZ_MUST_USE bool typedObjectHasField(MDefinition* typedObj,
+ [[nodiscard]] bool typedObjectHasField(MDefinition* typedObj,
PropertyName* name,
size_t* fieldOffset,
TypedObjectPrediction* fieldTypeReprs,
@@ -572,87 +572,87 @@ class IonBuilder
MDefinition* typeObjectForElementFromArrayStructType(MDefinition* typedObj);
MDefinition* typeObjectForFieldFromStructType(MDefinition* type,
size_t fieldIndex);
- MOZ_MUST_USE bool storeReferenceTypedObjectValue(MDefinition* typedObj,
+ [[nodiscard]] bool storeReferenceTypedObjectValue(MDefinition* typedObj,
const LinearSum& byteOffset,
ReferenceTypeDescr::Type type,
MDefinition* value,
PropertyName* name);
- MOZ_MUST_USE bool storeScalarTypedObjectValue(MDefinition* typedObj,
+ [[nodiscard]] bool storeScalarTypedObjectValue(MDefinition* typedObj,
const LinearSum& byteOffset,
ScalarTypeDescr::Type type,
MDefinition* value);
- MOZ_MUST_USE bool checkTypedObjectIndexInBounds(uint32_t elemSize,
+ [[nodiscard]] bool checkTypedObjectIndexInBounds(uint32_t elemSize,
MDefinition* obj,
MDefinition* index,
TypedObjectPrediction objTypeDescrs,
LinearSum* indexAsByteOffset);
- MOZ_MUST_USE bool pushDerivedTypedObject(bool* emitted,
+ [[nodiscard]] bool pushDerivedTypedObject(bool* emitted,
MDefinition* obj,
const LinearSum& byteOffset,
TypedObjectPrediction derivedTypeDescrs,
MDefinition* derivedTypeObj);
- MOZ_MUST_USE bool pushScalarLoadFromTypedObject(MDefinition* obj,
+ [[nodiscard]] bool pushScalarLoadFromTypedObject(MDefinition* obj,
const LinearSum& byteoffset,
ScalarTypeDescr::Type type);
- MOZ_MUST_USE bool pushReferenceLoadFromTypedObject(MDefinition* typedObj,
+ [[nodiscard]] bool pushReferenceLoadFromTypedObject(MDefinition* typedObj,
const LinearSum& byteOffset,
ReferenceTypeDescr::Type type,
PropertyName* name);
JSObject* getStaticTypedArrayObject(MDefinition* obj, MDefinition* index);
// jsop_setelem() helpers.
- MOZ_MUST_USE bool setElemTryTypedArray(bool* emitted, MDefinition* object,
+ [[nodiscard]] bool setElemTryTypedArray(bool* emitted, MDefinition* object,
MDefinition* index, MDefinition* value);
- MOZ_MUST_USE bool setElemTryTypedObject(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool setElemTryTypedObject(bool* emitted, MDefinition* obj,
MDefinition* index, MDefinition* value);
- MOZ_MUST_USE bool setElemTryTypedStatic(bool* emitted, MDefinition* object,
+ [[nodiscard]] bool setElemTryTypedStatic(bool* emitted, MDefinition* object,
MDefinition* index, MDefinition* value);
- MOZ_MUST_USE bool setElemTryDense(bool* emitted, MDefinition* object,
+ [[nodiscard]] bool setElemTryDense(bool* emitted, MDefinition* object,
MDefinition* index, MDefinition* value, bool writeHole);
- MOZ_MUST_USE bool setElemTryArguments(bool* emitted, MDefinition* object,
+ [[nodiscard]] bool setElemTryArguments(bool* emitted, MDefinition* object,
MDefinition* index, MDefinition* value);
- MOZ_MUST_USE bool setElemTryCache(bool* emitted, MDefinition* object,
+ [[nodiscard]] bool setElemTryCache(bool* emitted, MDefinition* object,
MDefinition* index, MDefinition* value);
- MOZ_MUST_USE bool setElemTryReferenceElemOfTypedObject(bool* emitted,
+ [[nodiscard]] bool setElemTryReferenceElemOfTypedObject(bool* emitted,
MDefinition* obj,
MDefinition* index,
TypedObjectPrediction objPrediction,
MDefinition* value,
TypedObjectPrediction elemPrediction);
- MOZ_MUST_USE bool setElemTryScalarElemOfTypedObject(bool* emitted,
+ [[nodiscard]] bool setElemTryScalarElemOfTypedObject(bool* emitted,
MDefinition* obj,
MDefinition* index,
TypedObjectPrediction objTypeReprs,
MDefinition* value,
TypedObjectPrediction elemTypeReprs,
uint32_t elemSize);
- MOZ_MUST_USE bool initializeArrayElement(MDefinition* obj, size_t index, MDefinition* value,
+ [[nodiscard]] bool initializeArrayElement(MDefinition* obj, size_t index, MDefinition* value,
JSValueType unboxedType,
bool addResumePointAndIncrementInitializedLength);
// jsop_getelem() helpers.
- MOZ_MUST_USE bool getElemTryDense(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryGetProp(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryTypedStatic(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryTypedArray(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryTypedObject(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryString(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryArguments(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryArgumentsInlined(bool* emitted, MDefinition* obj,
+ [[nodiscard]] bool getElemTryDense(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryGetProp(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryTypedStatic(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryTypedArray(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryTypedObject(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryString(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryArguments(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryArgumentsInlined(bool* emitted, MDefinition* obj,
MDefinition* index);
- MOZ_MUST_USE bool getElemTryCache(bool* emitted, MDefinition* obj, MDefinition* index);
- MOZ_MUST_USE bool getElemTryScalarElemOfTypedObject(bool* emitted,
+ [[nodiscard]] bool getElemTryCache(bool* emitted, MDefinition* obj, MDefinition* index);
+ [[nodiscard]] bool getElemTryScalarElemOfTypedObject(bool* emitted,
MDefinition* obj,
MDefinition* index,
TypedObjectPrediction objTypeReprs,
TypedObjectPrediction elemTypeReprs,
uint32_t elemSize);
- MOZ_MUST_USE bool getElemTryReferenceElemOfTypedObject(bool* emitted,
+ [[nodiscard]] bool getElemTryReferenceElemOfTypedObject(bool* emitted,
MDefinition* obj,
MDefinition* index,
TypedObjectPrediction objPrediction,
TypedObjectPrediction elemPrediction);
- MOZ_MUST_USE bool getElemTryComplexElemOfTypedObject(bool* emitted,
+ [[nodiscard]] bool getElemTryComplexElemOfTypedObject(bool* emitted,
MDefinition* obj,
MDefinition* index,
TypedObjectPrediction objTypeReprs,
@@ -683,7 +683,7 @@ class IonBuilder
return length;
}
- MOZ_MUST_USE bool improveThisTypesForCall();
+ [[nodiscard]] bool improveThisTypesForCall();
MDefinition* getCallee();
MDefinition* getAliasedVar(EnvironmentCoordinate ec);
@@ -691,118 +691,118 @@ class IonBuilder
MDefinition* convertToBoolean(MDefinition* input);
- MOZ_MUST_USE bool tryFoldInstanceOf(MDefinition* lhs, JSObject* protoObject);
- MOZ_MUST_USE bool hasOnProtoChain(TypeSet::ObjectKey* key, JSObject* protoObject,
+ [[nodiscard]] bool tryFoldInstanceOf(MDefinition* lhs, JSObject* protoObject);
+ [[nodiscard]] bool hasOnProtoChain(TypeSet::ObjectKey* key, JSObject* protoObject,
bool* hasOnProto);
- MOZ_MUST_USE bool jsop_add(MDefinition* left, MDefinition* right);
- MOZ_MUST_USE bool jsop_bitnot();
- MOZ_MUST_USE bool jsop_bitop(JSOp op);
- MOZ_MUST_USE bool jsop_binary_arith(JSOp op);
- MOZ_MUST_USE bool jsop_binary_arith(JSOp op, MDefinition* left, MDefinition* right);
- MOZ_MUST_USE bool jsop_pow();
- MOZ_MUST_USE bool jsop_pos();
- MOZ_MUST_USE bool jsop_neg();
- MOZ_MUST_USE bool jsop_tonumeric();
- MOZ_MUST_USE bool jsop_inc_or_dec(JSOp op);
- MOZ_MUST_USE bool jsop_tostring();
- MOZ_MUST_USE bool jsop_setarg(uint32_t arg);
- MOZ_MUST_USE bool jsop_defvar(uint32_t index);
- MOZ_MUST_USE bool jsop_deflexical(uint32_t index);
- MOZ_MUST_USE bool jsop_deffun(uint32_t index);
- MOZ_MUST_USE bool jsop_notearg();
- MOZ_MUST_USE bool jsop_throwsetconst();
- MOZ_MUST_USE bool jsop_checklexical();
- MOZ_MUST_USE bool jsop_checkaliasedlexical(EnvironmentCoordinate ec);
- MOZ_MUST_USE bool jsop_funcall(uint32_t argc);
- MOZ_MUST_USE bool jsop_funapply(uint32_t argc);
- MOZ_MUST_USE bool jsop_funapplyarguments(uint32_t argc);
- MOZ_MUST_USE bool jsop_funapplyarray(uint32_t argc);
- MOZ_MUST_USE bool jsop_call(uint32_t argc, bool constructing);
- MOZ_MUST_USE bool jsop_call(uint32_t argc, bool constructing, bool ignoresReturnValue);
- MOZ_MUST_USE bool jsop_eval(uint32_t argc);
- MOZ_MUST_USE bool jsop_ifeq(JSOp op);
- MOZ_MUST_USE bool jsop_try();
- MOZ_MUST_USE bool jsop_label();
- MOZ_MUST_USE bool jsop_condswitch();
- MOZ_MUST_USE bool jsop_logical(JSOp op);
- MOZ_MUST_USE bool jsop_dup2();
- MOZ_MUST_USE bool jsop_loophead(jsbytecode* pc);
- MOZ_MUST_USE bool jsop_compare(JSOp op);
- MOZ_MUST_USE bool jsop_compare(JSOp op, MDefinition* left, MDefinition* right);
- MOZ_MUST_USE bool getStaticName(JSObject* staticObject, PropertyName* name, bool* psucceeded,
+ [[nodiscard]] bool jsop_add(MDefinition* left, MDefinition* right);
+ [[nodiscard]] bool jsop_bitnot();
+ [[nodiscard]] bool jsop_bitop(JSOp op);
+ [[nodiscard]] bool jsop_binary_arith(JSOp op);
+ [[nodiscard]] bool jsop_binary_arith(JSOp op, MDefinition* left, MDefinition* right);
+ [[nodiscard]] bool jsop_pow();
+ [[nodiscard]] bool jsop_pos();
+ [[nodiscard]] bool jsop_neg();
+ [[nodiscard]] bool jsop_tonumeric();
+ [[nodiscard]] bool jsop_inc_or_dec(JSOp op);
+ [[nodiscard]] bool jsop_tostring();
+ [[nodiscard]] bool jsop_setarg(uint32_t arg);
+ [[nodiscard]] bool jsop_defvar(uint32_t index);
+ [[nodiscard]] bool jsop_deflexical(uint32_t index);
+ [[nodiscard]] bool jsop_deffun(uint32_t index);
+ [[nodiscard]] bool jsop_notearg();
+ [[nodiscard]] bool jsop_throwsetconst();
+ [[nodiscard]] bool jsop_checklexical();
+ [[nodiscard]] bool jsop_checkaliasedlexical(EnvironmentCoordinate ec);
+ [[nodiscard]] bool jsop_funcall(uint32_t argc);
+ [[nodiscard]] bool jsop_funapply(uint32_t argc);
+ [[nodiscard]] bool jsop_funapplyarguments(uint32_t argc);
+ [[nodiscard]] bool jsop_funapplyarray(uint32_t argc);
+ [[nodiscard]] bool jsop_call(uint32_t argc, bool constructing);
+ [[nodiscard]] bool jsop_call(uint32_t argc, bool constructing, bool ignoresReturnValue);
+ [[nodiscard]] bool jsop_eval(uint32_t argc);
+ [[nodiscard]] bool jsop_ifeq(JSOp op);
+ [[nodiscard]] bool jsop_try();
+ [[nodiscard]] bool jsop_label();
+ [[nodiscard]] bool jsop_condswitch();
+ [[nodiscard]] bool jsop_logical(JSOp op);
+ [[nodiscard]] bool jsop_dup2();
+ [[nodiscard]] bool jsop_loophead(jsbytecode* pc);
+ [[nodiscard]] bool jsop_compare(JSOp op);
+ [[nodiscard]] bool jsop_compare(JSOp op, MDefinition* left, MDefinition* right);
+ [[nodiscard]] bool getStaticName(JSObject* staticObject, PropertyName* name, bool* psucceeded,
MDefinition* lexicalCheck = nullptr);
- MOZ_MUST_USE bool loadStaticSlot(JSObject* staticObject, BarrierKind barrier,
+ [[nodiscard]] bool loadStaticSlot(JSObject* staticObject, BarrierKind barrier,
TemporaryTypeSet* types, uint32_t slot);
- MOZ_MUST_USE bool setStaticName(JSObject* staticObject, PropertyName* name);
- MOZ_MUST_USE bool jsop_getgname(PropertyName* name);
- MOZ_MUST_USE bool jsop_getname(PropertyName* name);
- MOZ_MUST_USE bool jsop_intrinsic(PropertyName* name);
- MOZ_MUST_USE bool jsop_getimport(PropertyName* name);
- MOZ_MUST_USE bool jsop_bindname(PropertyName* name);
- MOZ_MUST_USE bool jsop_bindvar();
- MOZ_MUST_USE bool jsop_getelem();
- MOZ_MUST_USE bool jsop_getelem_dense(MDefinition* obj, MDefinition* index,
+ [[nodiscard]] bool setStaticName(JSObject* staticObject, PropertyName* name);
+ [[nodiscard]] bool jsop_getgname(PropertyName* name);
+ [[nodiscard]] bool jsop_getname(PropertyName* name);
+ [[nodiscard]] bool jsop_intrinsic(PropertyName* name);
+ [[nodiscard]] bool jsop_getimport(PropertyName* name);
+ [[nodiscard]] bool jsop_bindname(PropertyName* name);
+ [[nodiscard]] bool jsop_bindvar();
+ [[nodiscard]] bool jsop_getelem();
+ [[nodiscard]] bool jsop_getelem_dense(MDefinition* obj, MDefinition* index,
JSValueType unboxedType);
- MOZ_MUST_USE bool jsop_getelem_typed(MDefinition* obj, MDefinition* index,
+ [[nodiscard]] bool jsop_getelem_typed(MDefinition* obj, MDefinition* index,
ScalarTypeDescr::Type arrayType);
- MOZ_MUST_USE bool jsop_setelem();
- MOZ_MUST_USE bool jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion,
+ [[nodiscard]] bool jsop_setelem();
+ [[nodiscard]] bool jsop_setelem_dense(TemporaryTypeSet::DoubleConversion conversion,
MDefinition* object, MDefinition* index,
MDefinition* value, JSValueType unboxedType,
bool writeHole, bool* emitted);
- MOZ_MUST_USE bool jsop_setelem_typed(ScalarTypeDescr::Type arrayType,
+ [[nodiscard]] bool jsop_setelem_typed(ScalarTypeDescr::Type arrayType,
MDefinition* object, MDefinition* index,
MDefinition* value);
- MOZ_MUST_USE bool jsop_length();
- MOZ_MUST_USE bool jsop_length_fastPath();
- MOZ_MUST_USE bool jsop_arguments();
- MOZ_MUST_USE bool jsop_arguments_getelem();
- MOZ_MUST_USE bool jsop_runonce();
- MOZ_MUST_USE bool jsop_rest();
- MOZ_MUST_USE bool jsop_not();
- MOZ_MUST_USE bool jsop_getprop(PropertyName* name);
- MOZ_MUST_USE bool jsop_setprop(PropertyName* name);
- MOZ_MUST_USE bool jsop_delprop(PropertyName* name);
- MOZ_MUST_USE bool jsop_delelem();
- MOZ_MUST_USE bool jsop_newarray(uint32_t length);
- MOZ_MUST_USE bool jsop_newarray(JSObject* templateObject, uint32_t length);
- MOZ_MUST_USE bool jsop_newarray_copyonwrite();
- MOZ_MUST_USE bool jsop_newobject();
- MOZ_MUST_USE bool jsop_initelem();
- MOZ_MUST_USE bool jsop_initelem_array();
- MOZ_MUST_USE bool jsop_initelem_getter_setter();
- MOZ_MUST_USE bool jsop_mutateproto();
- MOZ_MUST_USE bool jsop_initprop(PropertyName* name);
- MOZ_MUST_USE bool jsop_initprop_getter_setter(PropertyName* name);
- MOZ_MUST_USE bool jsop_regexp(RegExpObject* reobj);
- MOZ_MUST_USE bool jsop_object(JSObject* obj);
- MOZ_MUST_USE bool jsop_lambda(JSFunction* fun);
- MOZ_MUST_USE bool jsop_lambda_arrow(JSFunction* fun);
- MOZ_MUST_USE bool jsop_setfunname(uint8_t prefixKind);
- MOZ_MUST_USE bool jsop_functionthis();
- MOZ_MUST_USE bool jsop_globalthis();
- MOZ_MUST_USE bool jsop_typeof();
- MOZ_MUST_USE bool jsop_toasync();
- MOZ_MUST_USE bool jsop_toasyncgen();
- MOZ_MUST_USE bool jsop_toasynciter();
- MOZ_MUST_USE bool jsop_toid();
- MOZ_MUST_USE bool jsop_iter(uint8_t flags);
- MOZ_MUST_USE bool jsop_itermore();
- MOZ_MUST_USE bool jsop_isnoiter();
- MOZ_MUST_USE bool jsop_iterend();
- MOZ_MUST_USE bool jsop_in();
- MOZ_MUST_USE bool jsop_instanceof();
- MOZ_MUST_USE bool jsop_getaliasedvar(EnvironmentCoordinate ec);
- MOZ_MUST_USE bool jsop_setaliasedvar(EnvironmentCoordinate ec);
- MOZ_MUST_USE bool jsop_debugger();
- MOZ_MUST_USE bool jsop_newtarget();
- MOZ_MUST_USE bool jsop_checkisobj(uint8_t kind);
- MOZ_MUST_USE bool jsop_checkiscallable(uint8_t kind);
- MOZ_MUST_USE bool jsop_checkobjcoercible();
- MOZ_MUST_USE bool jsop_pushcallobj();
- MOZ_MUST_USE bool jsop_importmeta();
- MOZ_MUST_USE bool jsop_dynamic_import();
+ [[nodiscard]] bool jsop_length();
+ [[nodiscard]] bool jsop_length_fastPath();
+ [[nodiscard]] bool jsop_arguments();
+ [[nodiscard]] bool jsop_arguments_getelem();
+ [[nodiscard]] bool jsop_runonce();
+ [[nodiscard]] bool jsop_rest();
+ [[nodiscard]] bool jsop_not();
+ [[nodiscard]] bool jsop_getprop(PropertyName* name);
+ [[nodiscard]] bool jsop_setprop(PropertyName* name);
+ [[nodiscard]] bool jsop_delprop(PropertyName* name);
+ [[nodiscard]] bool jsop_delelem();
+ [[nodiscard]] bool jsop_newarray(uint32_t length);
+ [[nodiscard]] bool jsop_newarray(JSObject* templateObject, uint32_t length);
+ [[nodiscard]] bool jsop_newarray_copyonwrite();
+ [[nodiscard]] bool jsop_newobject();
+ [[nodiscard]] bool jsop_initelem();
+ [[nodiscard]] bool jsop_initelem_array();
+ [[nodiscard]] bool jsop_initelem_getter_setter();
+ [[nodiscard]] bool jsop_mutateproto();
+ [[nodiscard]] bool jsop_initprop(PropertyName* name);
+ [[nodiscard]] bool jsop_initprop_getter_setter(PropertyName* name);
+ [[nodiscard]] bool jsop_regexp(RegExpObject* reobj);
+ [[nodiscard]] bool jsop_object(JSObject* obj);
+ [[nodiscard]] bool jsop_lambda(JSFunction* fun);
+ [[nodiscard]] bool jsop_lambda_arrow(JSFunction* fun);
+ [[nodiscard]] bool jsop_setfunname(uint8_t prefixKind);
+ [[nodiscard]] bool jsop_functionthis();
+ [[nodiscard]] bool jsop_globalthis();
+ [[nodiscard]] bool jsop_typeof();
+ [[nodiscard]] bool jsop_toasync();
+ [[nodiscard]] bool jsop_toasyncgen();
+ [[nodiscard]] bool jsop_toasynciter();
+ [[nodiscard]] bool jsop_toid();
+ [[nodiscard]] bool jsop_iter(uint8_t flags);
+ [[nodiscard]] bool jsop_itermore();
+ [[nodiscard]] bool jsop_isnoiter();
+ [[nodiscard]] bool jsop_iterend();
+ [[nodiscard]] bool jsop_in();
+ [[nodiscard]] bool jsop_instanceof();
+ [[nodiscard]] bool jsop_getaliasedvar(EnvironmentCoordinate ec);
+ [[nodiscard]] bool jsop_setaliasedvar(EnvironmentCoordinate ec);
+ [[nodiscard]] bool jsop_debugger();
+ [[nodiscard]] bool jsop_newtarget();
+ [[nodiscard]] bool jsop_checkisobj(uint8_t kind);
+ [[nodiscard]] bool jsop_checkiscallable(uint8_t kind);
+ [[nodiscard]] bool jsop_checkobjcoercible();
+ [[nodiscard]] bool jsop_pushcallobj();
+ [[nodiscard]] bool jsop_importmeta();
+ [[nodiscard]] bool jsop_dynamic_import();
/* Inlining. */
@@ -830,7 +830,7 @@ class IonBuilder
// Oracles.
InliningDecision canInlineTarget(JSFunction* target, CallInfo& callInfo);
InliningDecision makeInliningDecision(JSObject* target, CallInfo& callInfo);
- MOZ_MUST_USE bool selectInliningTargets(const ObjectVector& targets, CallInfo& callInfo,
+ [[nodiscard]] bool selectInliningTargets(const ObjectVector& targets, CallInfo& callInfo,
BoolVector& choiceSet, uint32_t* numInlineable);
// Native inlining helpers.
@@ -962,13 +962,13 @@ class IonBuilder
// Call functions
InliningStatus inlineCallsite(const ObjectVector& targets, CallInfo& callInfo);
- MOZ_MUST_USE bool inlineCalls(CallInfo& callInfo, const ObjectVector& targets,
+ [[nodiscard]] bool inlineCalls(CallInfo& callInfo, const ObjectVector& targets,
BoolVector& choiceSet, MGetPropertyCache* maybeCache);
// Inlining helpers.
- MOZ_MUST_USE bool inlineGenericFallback(JSFunction* target, CallInfo& callInfo,
+ [[nodiscard]] bool inlineGenericFallback(JSFunction* target, CallInfo& callInfo,
MBasicBlock* dispatchBlock);
- MOZ_MUST_USE bool inlineObjectGroupFallback(CallInfo& callInfo, MBasicBlock* dispatchBlock,
+ [[nodiscard]] bool inlineObjectGroupFallback(CallInfo& callInfo, MBasicBlock* dispatchBlock,
MObjectGroupDispatch* dispatch,
MGetPropertyCache* cache,
MBasicBlock** fallbackTarget);
@@ -978,22 +978,22 @@ class IonBuilder
DoCheckAtomicResult
};
- MOZ_MUST_USE bool atomicsMeetsPreconditions(CallInfo& callInfo, Scalar::Type* arrayElementType,
+ [[nodiscard]] bool atomicsMeetsPreconditions(CallInfo& callInfo, Scalar::Type* arrayElementType,
bool* requiresDynamicCheck,
AtomicCheckResult checkResult=DoCheckAtomicResult);
void atomicsCheckBounds(CallInfo& callInfo, MInstruction** elements, MDefinition** index);
- MOZ_MUST_USE bool testNeedsArgumentCheck(JSFunction* target, CallInfo& callInfo);
+ [[nodiscard]] bool testNeedsArgumentCheck(JSFunction* target, CallInfo& callInfo);
MCall* makeCallHelper(JSFunction* target, CallInfo& callInfo);
- MOZ_MUST_USE bool makeCall(JSFunction* target, CallInfo& callInfo);
+ [[nodiscard]] bool makeCall(JSFunction* target, CallInfo& callInfo);
MDefinition* patchInlinedReturn(CallInfo& callInfo, MBasicBlock* exit, MBasicBlock* bottom);
MDefinition* patchInlinedReturns(CallInfo& callInfo, MIRGraphReturns& returns,
MBasicBlock* bottom);
MDefinition* specializeInlinedReturn(MDefinition* rdef, MBasicBlock* exit);
- MOZ_MUST_USE bool objectsHaveCommonPrototype(TemporaryTypeSet* types, PropertyName* name,
+ [[nodiscard]] bool objectsHaveCommonPrototype(TemporaryTypeSet* types, PropertyName* name,
bool isGetter, JSObject* foundProto,
bool* guardGlobal);
void freezePropertiesForCommonPrototype(TemporaryTypeSet* types, PropertyName* name,
@@ -1001,12 +1001,12 @@ class IonBuilder
/*
* Callers must pass a non-null globalGuard if they pass a non-null globalShape.
*/
- MOZ_MUST_USE bool testCommonGetterSetter(TemporaryTypeSet* types, PropertyName* name,
+ [[nodiscard]] bool testCommonGetterSetter(TemporaryTypeSet* types, PropertyName* name,
bool isGetter, JSObject* foundProto,
Shape* lastProperty, JSFunction* getterOrSetter,
MDefinition** guard, Shape* globalShape = nullptr,
MDefinition** globalGuard = nullptr);
- MOZ_MUST_USE bool testShouldDOMCall(TypeSet* inTypes,
+ [[nodiscard]] bool testShouldDOMCall(TypeSet* inTypes,
JSFunction* func, JSJitInfo::OpType opType);
MDefinition*
@@ -1015,7 +1015,7 @@ class IonBuilder
const BaselineInspector::ObjectGroupVector& convertUnboxedGroups,
bool isOwnProperty);
- MOZ_MUST_USE bool annotateGetPropertyCache(MDefinition* obj, PropertyName* name,
+ [[nodiscard]] bool annotateGetPropertyCache(MDefinition* obj, PropertyName* name,
MGetPropertyCache* getPropCache,
TemporaryTypeSet* objTypes,
TemporaryTypeSet* pushedTypes);
@@ -1046,8 +1046,8 @@ class IonBuilder
MDefinition* elements, int32_t elementsOffset,
MDefinition* scaledOffset, JSValueType unboxedType,
MDefinition* value, bool preBarrier = true);
- MOZ_MUST_USE bool checkPreliminaryGroups(MDefinition *obj);
- MOZ_MUST_USE bool freezePropTypeSets(TemporaryTypeSet* types,
+ [[nodiscard]] bool checkPreliminaryGroups(MDefinition *obj);
+ [[nodiscard]] bool freezePropTypeSets(TemporaryTypeSet* types,
JSObject* foundProto, PropertyName* name);
bool canInlinePropertyOpShapes(const BaselineInspector::ReceiverVector& receivers);
@@ -1057,7 +1057,7 @@ class IonBuilder
// updating |current| directly. setCurrent() should only be used in cases
// where the block cannot have phis whose type needs to be computed.
- MOZ_MUST_USE bool setCurrentAndSpecializePhis(MBasicBlock* block) {
+ [[nodiscard]] bool setCurrentAndSpecializePhis(MBasicBlock* block) {
if (block) {
if (!block->specializePhis(alloc()))
return false;
@@ -1140,7 +1140,7 @@ class IonBuilder
void trace(JSTracer* trc);
private:
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
JSContext* analysisContext;
BaselineFrameInspector* baselineFrame_;
@@ -1368,7 +1368,7 @@ class CallInfo
setter_(false)
{ }
- MOZ_MUST_USE bool init(CallInfo& callInfo) {
+ [[nodiscard]] bool init(CallInfo& callInfo) {
MOZ_ASSERT(constructing_ == callInfo.constructing());
fun_ = callInfo.fun();
@@ -1384,7 +1384,7 @@ class CallInfo
return true;
}
- MOZ_MUST_USE bool init(MBasicBlock* current, uint32_t argc) {
+ [[nodiscard]] bool init(MBasicBlock* current, uint32_t argc) {
MOZ_ASSERT(args_.empty());
// Get the arguments in the right order
@@ -1427,7 +1427,7 @@ class CallInfo
return argc() + 2 + constructing();
}
- MOZ_MUST_USE bool setArgs(const MDefinitionVector& args) {
+ [[nodiscard]] bool setArgs(const MDefinitionVector& args) {
MOZ_ASSERT(args_.empty());
return args_.appendAll(args);
}
diff --git a/js/src/jit/IonCaches.h b/js/src/jit/IonCaches.h
index 914965055b..13b0600e1c 100644
--- a/js/src/jit/IonCaches.h
+++ b/js/src/jit/IonCaches.h
@@ -302,7 +302,7 @@ class IonCache
// Combine both linkStub and attachStub into one function. In addition, it
// produces a spew augmented with the attachKind string.
- MOZ_MUST_USE bool linkAndAttachStub(JSContext* cx, MacroAssembler& masm, StubAttacher& attacher,
+ [[nodiscard]] bool linkAndAttachStub(JSContext* cx, MacroAssembler& masm, StubAttacher& attacher,
IonScript* ion, const char* attachKind,
JS::TrackedOutcome = JS::TrackedOutcome::ICOptStub_GenericSuccess);
@@ -504,76 +504,76 @@ class GetPropertyIC : public IonCache
void maybeDisable(bool emitted);
// Attach the proper stub, if possible
- MOZ_MUST_USE bool tryAttachStub(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleValue idval, bool* emitted);
+ [[nodiscard]] bool tryAttachStub(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleValue idval, bool* emitted);
- MOZ_MUST_USE bool tryAttachProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, void* returnAddr,
- bool* emitted);
+ [[nodiscard]] bool tryAttachProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, void* returnAddr,
+ bool* emitted);
- MOZ_MUST_USE bool tryAttachGenericProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, void* returnAddr,
- bool* emitted);
+ [[nodiscard]] bool tryAttachGenericProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, void* returnAddr,
+ bool* emitted);
- MOZ_MUST_USE bool tryAttachDOMProxyShadowed(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- void* returnAddr, bool* emitted);
+ [[nodiscard]] bool tryAttachDOMProxyShadowed(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ void* returnAddr, bool* emitted);
- MOZ_MUST_USE bool tryAttachDOMProxyUnshadowed(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- bool resetNeeded, void* returnAddr,
- bool* emitted);
-
- MOZ_MUST_USE bool tryAttachNative(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, void* returnAddr,
- bool* emitted);
+ [[nodiscard]] bool tryAttachDOMProxyUnshadowed(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ bool resetNeeded, void* returnAddr,
+ bool* emitted);
- MOZ_MUST_USE bool tryAttachUnboxed(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ [[nodiscard]] bool tryAttachNative(JSContext* cx, HandleScript outerScript, IonScript* ion,
HandleObject obj, HandleId id, void* returnAddr,
bool* emitted);
- MOZ_MUST_USE bool tryAttachUnboxedExpando(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- void* returnAddr, bool* emitted);
+ [[nodiscard]] bool tryAttachUnboxed(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, void* returnAddr,
+ bool* emitted);
- MOZ_MUST_USE bool tryAttachUnboxedArrayLength(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- void* returnAddr, bool* emitted);
+ [[nodiscard]] bool tryAttachUnboxedExpando(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ void* returnAddr, bool* emitted);
- MOZ_MUST_USE bool tryAttachTypedArrayLength(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- bool* emitted);
+ [[nodiscard]] bool tryAttachUnboxedArrayLength(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ void* returnAddr, bool* emitted);
- MOZ_MUST_USE bool tryAttachArgumentsLength(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- bool* emitted);
+ [[nodiscard]] bool tryAttachTypedArrayLength(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ bool* emitted);
- MOZ_MUST_USE bool tryAttachArgumentsElement(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleValue idval,
+ [[nodiscard]] bool tryAttachArgumentsLength(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
bool* emitted);
- MOZ_MUST_USE bool tryAttachDenseElement(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleValue idval, bool* emitted);
+ [[nodiscard]] bool tryAttachArgumentsElement(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleValue idval,
+ bool* emitted);
+
+ [[nodiscard]] bool tryAttachDenseElement(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleValue idval, bool* emitted);
static bool canAttachDenseElementHole(JSObject* obj, HandleValue idval,
TypedOrValueRegister output);
- MOZ_MUST_USE bool tryAttachDenseElementHole(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj,
- HandleValue idval, bool* emitted);
+ [[nodiscard]] bool tryAttachDenseElementHole(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj,
+ HandleValue idval, bool* emitted);
static bool canAttachTypedOrUnboxedArrayElement(JSObject* obj, const Value& idval,
TypedOrValueRegister output);
- MOZ_MUST_USE bool tryAttachTypedOrUnboxedArrayElement(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj,
- HandleValue idval, bool* emitted);
+ [[nodiscard]] bool tryAttachTypedOrUnboxedArrayElement(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj,
+ HandleValue idval, bool* emitted);
- MOZ_MUST_USE bool tryAttachModuleNamespace(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- void* returnAddr, bool* emitted);
+ [[nodiscard]] bool tryAttachModuleNamespace(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ void* returnAddr, bool* emitted);
- static MOZ_MUST_USE bool update(JSContext* cx, HandleScript outerScript, size_t cacheIndex,
- HandleObject obj, HandleValue id, MutableHandleValue vp);
+ [[nodiscard]] static bool update(JSContext* cx, HandleScript outerScript, size_t cacheIndex,
+ HandleObject obj, HandleValue id, MutableHandleValue vp);
};
class SetPropertyIC : public IonCache
@@ -673,59 +673,59 @@ class SetPropertyIC : public IonCache
CanAttachCallSetter
};
- MOZ_MUST_USE bool attachSetSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleShape shape, bool checkTypeset);
+ [[nodiscard]] bool attachSetSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleShape shape, bool checkTypeset);
- MOZ_MUST_USE bool attachCallSetter(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleObject holder, HandleShape shape,
- void* returnAddr);
+ [[nodiscard]] bool attachCallSetter(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleObject holder, HandleShape shape,
+ void* returnAddr);
- MOZ_MUST_USE bool attachAddSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, HandleShape oldShape,
- HandleObjectGroup oldGroup, bool checkTypeset);
+ [[nodiscard]] bool attachAddSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, HandleShape oldShape,
+ HandleObjectGroup oldGroup, bool checkTypeset);
- MOZ_MUST_USE bool attachGenericProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleId id, void* returnAddr);
+ [[nodiscard]] bool attachGenericProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleId id, void* returnAddr);
- MOZ_MUST_USE bool attachDOMProxyShadowed(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- void* returnAddr);
+ [[nodiscard]] bool attachDOMProxyShadowed(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ void* returnAddr);
- MOZ_MUST_USE bool attachDOMProxyUnshadowed(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- void* returnAddr);
+ [[nodiscard]] bool attachDOMProxyUnshadowed(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ void* returnAddr);
- static MOZ_MUST_USE bool update(JSContext* cx, HandleScript outerScript, size_t cacheIndex,
- HandleObject obj, HandleValue idval, HandleValue value);
+ [[nodiscard]] static bool update(JSContext* cx, HandleScript outerScript, size_t cacheIndex,
+ HandleObject obj, HandleValue idval, HandleValue value);
- MOZ_MUST_USE bool tryAttachNative(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, bool* emitted,
- bool* tryNativeAddSlot);
+ [[nodiscard]] bool tryAttachNative(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, bool* emitted,
+ bool* tryNativeAddSlot);
- MOZ_MUST_USE bool tryAttachUnboxed(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, bool* emitted);
+ [[nodiscard]] bool tryAttachUnboxed(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, bool* emitted);
- MOZ_MUST_USE bool tryAttachUnboxedExpando(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj, HandleId id,
- bool* emitted);
+ [[nodiscard]] bool tryAttachUnboxedExpando(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj, HandleId id,
+ bool* emitted);
- MOZ_MUST_USE bool tryAttachProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, bool* emitted);
+ [[nodiscard]] bool tryAttachProxy(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, bool* emitted);
- MOZ_MUST_USE bool tryAttachStub(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleValue idval, HandleValue value,
- MutableHandleId id, bool* emitted, bool* tryNativeAddSlot);
+ [[nodiscard]] bool tryAttachStub(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleValue idval, HandleValue value,
+ MutableHandleId id, bool* emitted, bool* tryNativeAddSlot);
- MOZ_MUST_USE bool tryAttachAddSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, HandleId id, HandleObjectGroup oldGroup,
- HandleShape oldShape, bool tryNativeAddSlot, bool* emitted);
+ [[nodiscard]] bool tryAttachAddSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, HandleId id, HandleObjectGroup oldGroup,
+ HandleShape oldShape, bool tryNativeAddSlot, bool* emitted);
- MOZ_MUST_USE bool tryAttachDenseElement(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject obj, const Value& idval, bool* emitted);
+ [[nodiscard]] bool tryAttachDenseElement(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject obj, const Value& idval, bool* emitted);
- MOZ_MUST_USE bool tryAttachTypedArrayElement(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject obj,
- HandleValue idval, HandleValue val, bool* emitted);
+ [[nodiscard]] bool tryAttachTypedArrayElement(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject obj,
+ HandleValue idval, HandleValue val, bool* emitted);
};
class BindNameIC : public IonCache
@@ -755,11 +755,11 @@ class BindNameIC : public IonCache
return output_;
}
- MOZ_MUST_USE bool attachGlobal(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject envChain);
+ [[nodiscard]] bool attachGlobal(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject envChain);
- MOZ_MUST_USE bool attachNonGlobal(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject envChain, HandleObject holder);
+ [[nodiscard]] bool attachNonGlobal(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject envChain, HandleObject holder);
static JSObject*
update(JSContext* cx, HandleScript outerScript, size_t cacheIndex, HandleObject envChain);
@@ -804,19 +804,19 @@ class NameIC : public IonCache
return typeOf_;
}
- MOZ_MUST_USE bool attachReadSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject envChain, HandleObject holderBase,
- HandleNativeObject holder, Handle<PropertyResult> prop);
+ [[nodiscard]] bool attachReadSlot(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject envChain, HandleObject holderBase,
+ HandleNativeObject holder, Handle<PropertyResult> prop);
- MOZ_MUST_USE bool attachCallGetter(JSContext* cx, HandleScript outerScript, IonScript* ion,
- HandleObject envChain, HandleObject obj,
- HandleObject holder, HandleShape shape,
- void* returnAddr);
+ [[nodiscard]] bool attachCallGetter(JSContext* cx, HandleScript outerScript, IonScript* ion,
+ HandleObject envChain, HandleObject obj,
+ HandleObject holder, HandleShape shape,
+ void* returnAddr);
- MOZ_MUST_USE bool attachTypeOfNoProperty(JSContext* cx, HandleScript outerScript,
- IonScript* ion, HandleObject envChain);
+ [[nodiscard]] bool attachTypeOfNoProperty(JSContext* cx, HandleScript outerScript,
+ IonScript* ion, HandleObject envChain);
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
update(JSContext* cx, HandleScript outerScript, size_t cacheIndex, HandleObject envChain,
MutableHandleValue vp);
};
diff --git a/js/src/jit/IonCode.h b/js/src/jit/IonCode.h
index 2d9469dead..ddc0af4bb7 100644
--- a/js/src/jit/IonCode.h
+++ b/js/src/jit/IonCode.h
@@ -434,7 +434,7 @@ struct IonScript
bool hasProfilingInstrumentation() const {
return hasProfilingInstrumentation_;
}
- MOZ_MUST_USE bool addTraceLoggerEvent(TraceLoggerEvent& event) {
+ [[nodiscard]] bool addTraceLoggerEvent(TraceLoggerEvent& event) {
MOZ_ASSERT(event.hasPayload());
return traceLoggerEvents_.append(Move(event));
}
@@ -617,7 +617,7 @@ struct IonBlockCounts
public:
- MOZ_MUST_USE bool init(uint32_t id, uint32_t offset, char* description,
+ [[nodiscard]] bool init(uint32_t id, uint32_t offset, char* description,
uint32_t numSuccessors) {
id_ = id;
offset_ = offset;
@@ -715,7 +715,7 @@ struct IonScriptCounts
}
}
- MOZ_MUST_USE bool init(size_t numBlocks) {
+ [[nodiscard]] bool init(size_t numBlocks) {
blocks_ = js_pod_calloc<IonBlockCounts>(numBlocks);
if (!blocks_)
return false;
diff --git a/js/src/jit/JitAllocPolicy.h b/js/src/jit/JitAllocPolicy.h
index 2befa593f5..195a81b1ec 100644
--- a/js/src/jit/JitAllocPolicy.h
+++ b/js/src/jit/JitAllocPolicy.h
@@ -43,7 +43,7 @@ class TempAllocator
return lifoScope_.alloc().allocInfallible(bytes);
}
- MOZ_MUST_USE void* allocate(size_t bytes)
+ [[nodiscard]] void* allocate(size_t bytes)
{
LifoAlloc::AutoFallibleScope fallibleAllocator(lifoAlloc());
void* p = lifoScope_.alloc().alloc(bytes);
@@ -53,7 +53,7 @@ class TempAllocator
}
template <typename T>
- MOZ_MUST_USE T* allocateArray(size_t n)
+ [[nodiscard]] T* allocateArray(size_t n)
{
LifoAlloc::AutoFallibleScope fallibleAllocator(lifoAlloc());
size_t bytes;
@@ -73,7 +73,7 @@ class TempAllocator
return &lifoScope_.alloc();
}
- MOZ_MUST_USE bool ensureBallast() {
+ [[nodiscard]] bool ensureBallast() {
JS_OOM_POSSIBLY_FAIL_BOOL();
return lifoScope_.alloc().ensureUnusedApproximate(BallastSize);
}
@@ -126,7 +126,7 @@ class JitAllocPolicy
}
void reportAllocOverflow() const {
}
- MOZ_MUST_USE bool checkSimulatedOOM() const {
+ [[nodiscard]] bool checkSimulatedOOM() const {
return !js::oom::ShouldFailWithOOM();
}
};
diff --git a/js/src/jit/JitCompartment.h b/js/src/jit/JitCompartment.h
index a6cbd86719..4ef5cb4e4a 100644
--- a/js/src/jit/JitCompartment.h
+++ b/js/src/jit/JitCompartment.h
@@ -215,14 +215,14 @@ class JitRuntime
public:
explicit JitRuntime(JSRuntime* rt);
~JitRuntime();
- MOZ_MUST_USE bool initialize(JSContext* cx, js::AutoLockForExclusiveAccess& lock);
+ [[nodiscard]] bool initialize(JSContext* cx, js::AutoLockForExclusiveAccess& lock);
uint8_t* allocateOsrTempData(size_t size);
void freeOsrTempData();
static void Mark(JSTracer* trc, js::AutoLockForExclusiveAccess& lock);
static void MarkJitcodeGlobalTableUnconditionally(JSTracer* trc);
- static MOZ_MUST_USE bool MarkJitcodeGlobalTableIteratively(JSTracer* trc);
+ [[nodiscard]] static bool MarkJitcodeGlobalTableIteratively(JSTracer* trc);
static void SweepJitcodeGlobalTable(JSRuntime* rt);
ExecutableAllocator& execAlloc() {
@@ -473,7 +473,7 @@ class JitCompartment
return p->value();
return nullptr;
}
- MOZ_MUST_USE bool putStubCode(JSContext* cx, uint32_t key, Handle<JitCode*> stubCode) {
+ [[nodiscard]] bool putStubCode(JSContext* cx, uint32_t key, Handle<JitCode*> stubCode) {
MOZ_ASSERT(stubCode);
if (!stubCodes_->putNew(key, stubCode.get())) {
ReportOutOfMemory(cx);
@@ -490,7 +490,7 @@ class JitCompartment
*stubInfo = nullptr;
return nullptr;
}
- MOZ_MUST_USE bool putCacheIRStubCode(const CacheIRStubKey::Lookup& lookup, CacheIRStubKey& key,
+ [[nodiscard]] bool putCacheIRStubCode(const CacheIRStubKey::Lookup& lookup, CacheIRStubKey& key,
JitCode* stubCode)
{
CacheIRStubCodeMap::AddPtr p = cacheIRStubCodes_->lookupForAdd(lookup);
@@ -528,10 +528,10 @@ class JitCompartment
JitCompartment();
~JitCompartment();
- MOZ_MUST_USE bool initialize(JSContext* cx);
+ [[nodiscard]] bool initialize(JSContext* cx);
// Initialize code stubs only used by Ion, not Baseline.
- MOZ_MUST_USE bool ensureIonStubsExist(JSContext* cx);
+ [[nodiscard]] bool ensureIonStubsExist(JSContext* cx);
void mark(JSTracer* trc, JSCompartment* compartment);
void sweep(FreeOp* fop, JSCompartment* compartment);
@@ -544,7 +544,7 @@ class JitCompartment
return regExpMatcherStub_;
}
- MOZ_MUST_USE bool ensureRegExpMatcherStubExists(JSContext* cx) {
+ [[nodiscard]] bool ensureRegExpMatcherStubExists(JSContext* cx) {
if (regExpMatcherStub_)
return true;
regExpMatcherStub_ = generateRegExpMatcherStub(cx);
@@ -555,7 +555,7 @@ class JitCompartment
return regExpSearcherStub_;
}
- MOZ_MUST_USE bool ensureRegExpSearcherStubExists(JSContext* cx) {
+ [[nodiscard]] bool ensureRegExpSearcherStubExists(JSContext* cx) {
if (regExpSearcherStub_)
return true;
regExpSearcherStub_ = generateRegExpSearcherStub(cx);
@@ -566,7 +566,7 @@ class JitCompartment
return regExpTesterStub_;
}
- MOZ_MUST_USE bool ensureRegExpTesterStubExists(JSContext* cx) {
+ [[nodiscard]] bool ensureRegExpTesterStubExists(JSContext* cx) {
if (regExpTesterStub_)
return true;
regExpTesterStub_ = generateRegExpTesterStub(cx);
diff --git a/js/src/jit/JitFrameIterator.h b/js/src/jit/JitFrameIterator.h
index abe2dbb231..bff72c844d 100644
--- a/js/src/jit/JitFrameIterator.h
+++ b/js/src/jit/JitFrameIterator.h
@@ -279,9 +279,9 @@ class JitProfilingFrameIterator
inline JitFrameLayout* framePtr();
inline JSScript* frameScript();
- MOZ_MUST_USE bool tryInitWithPC(void* pc);
- MOZ_MUST_USE bool tryInitWithTable(JitcodeGlobalTable* table, void* pc, JSRuntime* rt,
- bool forLastCallSite);
+ [[nodiscard]] bool tryInitWithPC(void* pc);
+ [[nodiscard]] bool tryInitWithTable(JitcodeGlobalTable* table, void* pc, JSRuntime* rt,
+ bool forLastCallSite);
void fixBaselineReturnAddress();
void moveToNextFrame(CommonFrameLayout* frame);
@@ -323,7 +323,7 @@ class RInstructionResults
~RInstructionResults();
- MOZ_MUST_USE bool init(JSContext* cx, uint32_t numResults);
+ [[nodiscard]] bool init(JSContext* cx, uint32_t numResults);
bool isInitialized() const;
size_t length() const;
@@ -444,7 +444,7 @@ class SnapshotIterator
Value fromInstructionResult(uint32_t index) const;
Value allocationValue(const RValueAllocation& a, ReadMethod rm = RM_Normal);
- MOZ_MUST_USE bool allocationReadable(const RValueAllocation& a, ReadMethod rm = RM_Normal);
+ [[nodiscard]] bool allocationReadable(const RValueAllocation& a, ReadMethod rm = RM_Normal);
void writeAllocationValuePayload(const RValueAllocation& a, const Value& v);
void warnUnreadableAllocation();
@@ -481,7 +481,7 @@ class SnapshotIterator
public:
// Exhibits frame properties contained in the snapshot.
uint32_t pcOffset() const;
- inline MOZ_MUST_USE bool resumeAfter() const {
+ [[nodiscard]] inline bool resumeAfter() const {
// Inline frames are inlined on calls, which are considered as being
// resumed on the Call as baseline will push the pc once we return from
// the call.
@@ -514,12 +514,12 @@ class SnapshotIterator
// recover instructions. This vector should be registered before the
// beginning of the iteration. This function is in charge of allocating
// enough space for all instructions results, and return false iff it fails.
- MOZ_MUST_USE bool initInstructionResults(MaybeReadFallback& fallback);
+ [[nodiscard]] bool initInstructionResults(MaybeReadFallback& fallback);
protected:
// This function is used internally for computing the result of the recover
// instructions.
- MOZ_MUST_USE bool computeInstructionResults(JSContext* cx, RInstructionResults* results) const;
+ [[nodiscard]] bool computeInstructionResults(JSContext* cx, RInstructionResults* results) const;
public:
// Handle iterating over frames of the snapshots.
diff --git a/js/src/jit/JitcodeMap.h b/js/src/jit/JitcodeMap.h
index 0f096a9e69..df690abe35 100644
--- a/js/src/jit/JitcodeMap.h
+++ b/js/src/jit/JitcodeMap.h
@@ -319,8 +319,8 @@ class JitcodeGlobalEntry
void* canonicalNativeAddrFor(JSRuntime*rt, void* ptr) const;
- MOZ_MUST_USE bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
- uint32_t* depth) const;
+ [[nodiscard]] bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
+ uint32_t* depth) const;
uint32_t callStackAtAddr(JSRuntime* rt, void* ptr, const char** results,
uint32_t maxResults) const;
@@ -416,8 +416,8 @@ class JitcodeGlobalEntry
void* canonicalNativeAddrFor(JSRuntime* rt, void* ptr) const;
- MOZ_MUST_USE bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
- uint32_t* depth) const;
+ [[nodiscard]] bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
+ uint32_t* depth) const;
uint32_t callStackAtAddr(JSRuntime* rt, void* ptr, const char** results,
uint32_t maxResults) const;
@@ -455,8 +455,8 @@ class JitcodeGlobalEntry
void* canonicalNativeAddrFor(JSRuntime* rt, void* ptr) const;
- MOZ_MUST_USE bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
- uint32_t* depth) const;
+ [[nodiscard]] bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
+ uint32_t* depth) const;
uint32_t callStackAtAddr(JSRuntime* rt, void* ptr, const char** results,
uint32_t maxResults) const;
@@ -494,8 +494,8 @@ class JitcodeGlobalEntry
return nullptr;
}
- MOZ_MUST_USE bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
- uint32_t* depth) const
+ [[nodiscard]] bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
+ uint32_t* depth) const
{
return true;
}
@@ -758,8 +758,8 @@ class JitcodeGlobalEntry
// outermost appended last.
//
// Returns false on memory failure.
- MOZ_MUST_USE bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
- uint32_t* depth) const
+ [[nodiscard]] bool callStackAtAddr(JSRuntime* rt, void* ptr, BytecodeLocationVector& results,
+ uint32_t* depth) const
{
switch (kind()) {
case Ion:
@@ -1041,16 +1041,16 @@ class JitcodeGlobalTable
const JitcodeGlobalEntry& lookupForSamplerInfallible(void* ptr, JSRuntime* rt,
uint32_t sampleBufferGen);
- MOZ_MUST_USE bool addEntry(const JitcodeGlobalEntry::IonEntry& entry, JSRuntime* rt) {
+ [[nodiscard]] bool addEntry(const JitcodeGlobalEntry::IonEntry& entry, JSRuntime* rt) {
return addEntry(JitcodeGlobalEntry(entry), rt);
}
- MOZ_MUST_USE bool addEntry(const JitcodeGlobalEntry::BaselineEntry& entry, JSRuntime* rt) {
+ [[nodiscard]] bool addEntry(const JitcodeGlobalEntry::BaselineEntry& entry, JSRuntime* rt) {
return addEntry(JitcodeGlobalEntry(entry), rt);
}
- MOZ_MUST_USE bool addEntry(const JitcodeGlobalEntry::IonCacheEntry& entry, JSRuntime* rt) {
+ [[nodiscard]] bool addEntry(const JitcodeGlobalEntry::IonCacheEntry& entry, JSRuntime* rt) {
return addEntry(JitcodeGlobalEntry(entry), rt);
}
- MOZ_MUST_USE bool addEntry(const JitcodeGlobalEntry::DummyEntry& entry, JSRuntime* rt) {
+ [[nodiscard]] bool addEntry(const JitcodeGlobalEntry::DummyEntry& entry, JSRuntime* rt) {
return addEntry(JitcodeGlobalEntry(entry), rt);
}
@@ -1059,11 +1059,11 @@ class JitcodeGlobalTable
void setAllEntriesAsExpired(JSRuntime* rt);
void markUnconditionally(JSTracer* trc);
- MOZ_MUST_USE bool markIteratively(JSTracer* trc);
+ [[nodiscard]] bool markIteratively(JSTracer* trc);
void sweep(JSRuntime* rt);
private:
- MOZ_MUST_USE bool addEntry(const JitcodeGlobalEntry& entry, JSRuntime* rt);
+ [[nodiscard]] bool addEntry(const JitcodeGlobalEntry& entry, JSRuntime* rt);
JitcodeGlobalEntry* lookupInternal(void* ptr);
@@ -1229,9 +1229,9 @@ class JitcodeRegionEntry
const CodeGeneratorShared::NativeToBytecode* end);
// Write a run, starting at the given NativeToBytecode entry, into the given buffer writer.
- static MOZ_MUST_USE bool WriteRun(CompactBufferWriter& writer, JSScript** scriptList,
- uint32_t scriptListSize, uint32_t runLength,
- const CodeGeneratorShared::NativeToBytecode* entry);
+ [[nodiscard]] static bool WriteRun(CompactBufferWriter& writer, JSScript** scriptList,
+ uint32_t scriptListSize, uint32_t runLength,
+ const CodeGeneratorShared::NativeToBytecode* entry);
// Delta Run entry formats are encoded little-endian:
//
@@ -1438,8 +1438,8 @@ class JitcodeIonTable
regionOffsets_[i] = 0;
}
- MOZ_MUST_USE bool makeIonEntry(JSContext* cx, JitCode* code, uint32_t numScripts,
- JSScript** scripts, JitcodeGlobalEntry::IonEntry& out);
+ [[nodiscard]] bool makeIonEntry(JSContext* cx, JitCode* code, uint32_t numScripts,
+ JSScript** scripts, JitcodeGlobalEntry::IonEntry& out);
uint32_t numRegions() const {
return numRegions_;
@@ -1478,11 +1478,11 @@ class JitcodeIonTable
return payloadEnd() - regionOffset(0);
}
- static MOZ_MUST_USE bool WriteIonTable(CompactBufferWriter& writer,
- JSScript** scriptList, uint32_t scriptListSize,
- const CodeGeneratorShared::NativeToBytecode* start,
- const CodeGeneratorShared::NativeToBytecode* end,
- uint32_t* tableOffsetOut, uint32_t* numRegionsOut);
+ [[nodiscard]] static bool WriteIonTable(CompactBufferWriter& writer,
+ JSScript** scriptList, uint32_t scriptListSize,
+ const CodeGeneratorShared::NativeToBytecode* start,
+ const CodeGeneratorShared::NativeToBytecode* end,
+ uint32_t* tableOffsetOut, uint32_t* numRegionsOut);
};
diff --git a/js/src/jit/LICM.h b/js/src/jit/LICM.h
index 3c8117bd19..64569450fd 100644
--- a/js/src/jit/LICM.h
+++ b/js/src/jit/LICM.h
@@ -16,7 +16,7 @@ namespace jit {
class MIRGenerator;
class MIRGraph;
-MOZ_MUST_USE bool LICM(MIRGenerator* mir, MIRGraph& graph);
+[[nodiscard]] bool LICM(MIRGenerator* mir, MIRGraph& graph);
} // namespace jit
} // namespace js
diff --git a/js/src/jit/LIR.h b/js/src/jit/LIR.h
index bee3b3ebea..ce911ae958 100644
--- a/js/src/jit/LIR.h
+++ b/js/src/jit/LIR.h
@@ -965,7 +965,7 @@ class LBlock
public:
explicit LBlock(MBasicBlock* block);
- MOZ_MUST_USE bool init(TempAllocator& alloc);
+ [[nodiscard]] bool init(TempAllocator& alloc);
void add(LInstruction* ins) {
ins->setBlock(this);
@@ -1156,7 +1156,7 @@ class LVariadicInstruction : public details::LInstructionFixedDefsTempsHelper<De
FixedList<LAllocation> operands_;
public:
- MOZ_MUST_USE bool init(TempAllocator& alloc, size_t length) {
+ [[nodiscard]] bool init(TempAllocator& alloc, size_t length) {
return operands_.init(alloc, length);
}
size_t numOperands() const final override {
@@ -1193,13 +1193,13 @@ class LRecoverInfo : public TempObject
RecoverOffset recoverOffset_;
explicit LRecoverInfo(TempAllocator& alloc);
- MOZ_MUST_USE bool init(MResumePoint* mir);
+ [[nodiscard]] bool init(MResumePoint* mir);
// Fill the instruction vector such as all instructions needed for the
// recovery are pushed before the current instruction.
- MOZ_MUST_USE bool appendOperands(MNode* ins);
- MOZ_MUST_USE bool appendDefinition(MDefinition* def);
- MOZ_MUST_USE bool appendResumePoint(MResumePoint* rp);
+ [[nodiscard]] bool appendOperands(MNode* ins);
+ [[nodiscard]] bool appendDefinition(MDefinition* def);
+ [[nodiscard]] bool appendResumePoint(MResumePoint* rp);
public:
static LRecoverInfo* New(MIRGenerator* gen, MResumePoint* mir);
@@ -1291,7 +1291,7 @@ class LSnapshot : public TempObject
BailoutKind bailoutKind_;
LSnapshot(LRecoverInfo* recover, BailoutKind kind);
- MOZ_MUST_USE bool init(MIRGenerator* gen);
+ [[nodiscard]] bool init(MIRGenerator* gen);
public:
static LSnapshot* New(MIRGenerator* gen, LRecoverInfo* recover, BailoutKind kind);
@@ -1480,7 +1480,7 @@ class LSafepoint : public TempObject
LiveGeneralRegisterSet gcRegs() const {
return gcRegs_;
}
- MOZ_MUST_USE bool addGcSlot(bool stack, uint32_t slot) {
+ [[nodiscard]] bool addGcSlot(bool stack, uint32_t slot) {
bool result = gcSlots_.append(SlotEntry(stack, slot));
if (result)
assertInvariants();
@@ -1500,13 +1500,13 @@ class LSafepoint : public TempObject
slotsOrElementsRegs_.addUnchecked(reg);
assertInvariants();
}
- MOZ_MUST_USE bool addSlotsOrElementsSlot(bool stack, uint32_t slot) {
+ [[nodiscard]] bool addSlotsOrElementsSlot(bool stack, uint32_t slot) {
bool result = slotsOrElementsSlots_.append(SlotEntry(stack, slot));
if (result)
assertInvariants();
return result;
}
- MOZ_MUST_USE bool addSlotsOrElementsPointer(LAllocation alloc) {
+ [[nodiscard]] bool addSlotsOrElementsPointer(LAllocation alloc) {
if (alloc.isMemory())
return addSlotsOrElementsSlot(alloc.isStackSlot(), alloc.memorySlot());
MOZ_ASSERT(alloc.isRegister());
@@ -1525,7 +1525,7 @@ class LSafepoint : public TempObject
return false;
}
- MOZ_MUST_USE bool addGcPointer(LAllocation alloc) {
+ [[nodiscard]] bool addGcPointer(LAllocation alloc) {
if (alloc.isMemory())
return addGcSlot(alloc.isStackSlot(), alloc.memorySlot());
if (alloc.isRegister())
@@ -1545,7 +1545,7 @@ class LSafepoint : public TempObject
return false;
}
- MOZ_MUST_USE bool addValueSlot(bool stack, uint32_t slot) {
+ [[nodiscard]] bool addValueSlot(bool stack, uint32_t slot) {
bool result = valueSlots_.append(SlotEntry(stack, slot));
if (result)
assertInvariants();
@@ -1565,14 +1565,14 @@ class LSafepoint : public TempObject
#ifdef JS_NUNBOX32
- MOZ_MUST_USE bool addNunboxParts(uint32_t typeVreg, LAllocation type, LAllocation payload) {
+ [[nodiscard]] bool addNunboxParts(uint32_t typeVreg, LAllocation type, LAllocation payload) {
bool result = nunboxParts_.append(NunboxEntry(typeVreg, type, payload));
if (result)
assertInvariants();
return result;
}
- MOZ_MUST_USE bool addNunboxType(uint32_t typeVreg, LAllocation type) {
+ [[nodiscard]] bool addNunboxType(uint32_t typeVreg, LAllocation type) {
for (size_t i = 0; i < nunboxParts_.length(); i++) {
if (nunboxParts_[i].type == type)
return true;
@@ -1590,7 +1590,7 @@ class LSafepoint : public TempObject
return result;
}
- MOZ_MUST_USE bool addNunboxPayload(uint32_t payloadVreg, LAllocation payload) {
+ [[nodiscard]] bool addNunboxPayload(uint32_t payloadVreg, LAllocation payload) {
for (size_t i = 0; i < nunboxParts_.length(); i++) {
if (nunboxParts_[i].payload == payload)
return true;
@@ -1646,7 +1646,7 @@ class LSafepoint : public TempObject
return valueRegs_;
}
- MOZ_MUST_USE bool addBoxedValue(LAllocation alloc) {
+ [[nodiscard]] bool addBoxedValue(LAllocation alloc) {
if (alloc.isRegister()) {
Register reg = alloc.toRegister().gpr();
if (!valueRegs().has(reg))
@@ -1788,7 +1788,7 @@ class LIRGraph
public:
explicit LIRGraph(MIRGraph* mir);
- MOZ_MUST_USE bool init() {
+ [[nodiscard]] bool init() {
return constantPoolMap_.init() && blocks_.init(mir_.alloc(), mir_.numBlocks());
}
MIRGraph& mir() const {
@@ -1803,7 +1803,7 @@ class LIRGraph
uint32_t numBlockIds() const {
return mir_.numBlockIds();
}
- MOZ_MUST_USE bool initBlock(MBasicBlock* mir) {
+ [[nodiscard]] bool initBlock(MBasicBlock* mir) {
auto* block = &blocks_[mir->id()];
auto* lir = new (block) LBlock(mir);
return lir->init(mir_.alloc());
@@ -1855,7 +1855,7 @@ class LIRGraph
uint32_t totalSlotCount() const {
return paddedLocalSlotCount() + argumentsSize();
}
- MOZ_MUST_USE bool addConstantToPool(const Value& v, uint32_t* index);
+ [[nodiscard]] bool addConstantToPool(const Value& v, uint32_t* index);
size_t numConstants() const {
return constantPool_.length();
}
diff --git a/js/src/jit/LoopUnroller.h b/js/src/jit/LoopUnroller.h
index 096bdd2e42..4c1923c522 100644
--- a/js/src/jit/LoopUnroller.h
+++ b/js/src/jit/LoopUnroller.h
@@ -11,8 +11,7 @@
namespace js {
namespace jit {
-MOZ_MUST_USE bool
-UnrollLoops(MIRGraph& graph, const LoopIterationBoundVector& bounds);
+[[nodiscard]] bool UnrollLoops(MIRGraph& graph, const LoopIterationBoundVector& bounds);
} // namespace jit
} // namespace js
diff --git a/js/src/jit/Lowering.h b/js/src/jit/Lowering.h
index 8c380dcdef..e2b053643d 100644
--- a/js/src/jit/Lowering.h
+++ b/js/src/jit/Lowering.h
@@ -45,7 +45,7 @@ class LIRGenerator : public LIRGeneratorSpecific
maxargslots_(0)
{ }
- MOZ_MUST_USE bool generate();
+ [[nodiscard]] bool generate();
private:
LBoxAllocation useBoxFixedAtStart(MDefinition* mir, Register reg1, Register reg2) {
@@ -60,11 +60,11 @@ class LIRGenerator : public LIRGeneratorSpecific
void lowerBinaryV(JSOp op, MBinaryInstruction* ins);
void definePhis();
- MOZ_MUST_USE bool lowerCallArguments(MCall* call);
+ [[nodiscard]] bool lowerCallArguments(MCall* call);
public:
- MOZ_MUST_USE bool visitInstruction(MInstruction* ins);
- MOZ_MUST_USE bool visitBlock(MBasicBlock* block);
+ [[nodiscard]] bool visitInstruction(MInstruction* ins);
+ [[nodiscard]] bool visitBlock(MBasicBlock* block);
// Visitor hooks are explicit, to give CPU-specific versions a chance to
// intercept without a bunch of explicit gunk in the .cpp.
diff --git a/js/src/jit/MIR.h b/js/src/jit/MIR.h
index 62f49c8bad..f21454fd76 100644
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -292,7 +292,7 @@ class MNode : public TempObject
inline MDefinition* toDefinition();
inline MResumePoint* toResumePoint();
- virtual MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const;
+ [[nodiscard]] virtual bool writeRecoverData(CompactBufferWriter& writer) const;
virtual void dump(GenericPrinter& out) const = 0;
virtual void dump() const = 0;
@@ -393,7 +393,7 @@ class StoreDependency : public TempObject
: all_(alloc)
{ }
- MOZ_MUST_USE bool init(MDefinitionVector& all) {
+ [[nodiscard]] bool init(MDefinitionVector& all) {
if (!all_.appendAll(all))
return false;
return true;
@@ -800,7 +800,7 @@ class MDefinition : public MNode
// Replace the current instruction by an optimized-out constant in all uses
// of the current instruction. Note, that optimized-out constant should not
// be observed, and thus they should not flow in any computation.
- MOZ_MUST_USE bool optimizeOutAllUses(TempAllocator& alloc);
+ [[nodiscard]] bool optimizeOutAllUses(TempAllocator& alloc);
// Replace the current instruction by a dominating instruction |dom| in all
// instruction, but keep the current instruction for resume point and
@@ -810,7 +810,7 @@ class MDefinition : public MNode
// Mark this instruction as having replaced all uses of ins, as during GVN,
// returning false if the replacement should not be performed. For use when
// GVN eliminates instructions which are not equivalent to one another.
- virtual MOZ_MUST_USE bool updateForReplacement(MDefinition* ins) {
+ [[nodiscard]] virtual bool updateForReplacement(MDefinition* ins) {
return true;
}
@@ -1027,17 +1027,17 @@ class MRootList : public TempObject
void trace(JSTracer* trc);
template <typename T>
- MOZ_MUST_USE bool append(T ptr) {
+ [[nodiscard]] bool append(T ptr) {
if (ptr)
return roots_[JS::MapTypeToRootKind<T>::kind]->append(ptr);
return true;
}
template <typename T>
- MOZ_MUST_USE bool append(const CompilerGCPointer<T>& ptr) {
+ [[nodiscard]] bool append(const CompilerGCPointer<T>& ptr) {
return append(static_cast<T>(ptr));
}
- MOZ_MUST_USE bool append(const ReceiverGuard& guard) {
+ [[nodiscard]] bool append(const ReceiverGuard& guard) {
return append(guard.group) && append(guard.shape);
}
};
@@ -1362,7 +1362,7 @@ class MVariadicT : public T
FixedList<MUse> operands_;
protected:
- MOZ_MUST_USE bool init(TempAllocator& alloc, size_t length) {
+ [[nodiscard]] bool init(TempAllocator& alloc, size_t length) {
return operands_.init(alloc, length);
}
void initOperand(size_t index, MDefinition* operand) {
@@ -1533,7 +1533,7 @@ class MConstant : public MNullaryInstruction
// Try to convert this constant to boolean, similar to js::ToBoolean.
// Returns false if the type is MIRType::Magic*.
- bool MOZ_MUST_USE valueToBoolean(bool* res) const;
+ [[nodiscard]] bool valueToBoolean(bool* res) const;
// Like valueToBoolean, but returns the result directly instead of using
// an outparam. Should not be used if this constant might be a magic value.
@@ -1552,7 +1552,7 @@ class MConstant : public MNullaryInstruction
return AliasSet::None();
}
- MOZ_MUST_USE bool updateForReplacement(MDefinition* def) override {
+ [[nodiscard]] bool updateForReplacement(MDefinition* def) override {
MConstant* c = def->toConstant();
// During constant folding, we don't want to replace a float32
// value by a double value.
@@ -1803,7 +1803,7 @@ class MTableSwitch final
return successors_.length();
}
- MOZ_MUST_USE bool addSuccessor(MBasicBlock* successor, size_t* index) {
+ [[nodiscard]] bool addSuccessor(MBasicBlock* successor, size_t* index) {
MOZ_ASSERT(successors_.length() < (size_t)(high_ - low_ + 2));
MOZ_ASSERT(!successors_.empty());
*index = successors_.length();
@@ -1848,14 +1848,14 @@ class MTableSwitch final
return high() - low() + 1;
}
- MOZ_MUST_USE bool addDefault(MBasicBlock* block, size_t* index = nullptr) {
+ [[nodiscard]] bool addDefault(MBasicBlock* block, size_t* index = nullptr) {
MOZ_ASSERT(successors_.empty());
if (index)
*index = 0;
return successors_.append(block);
}
- MOZ_MUST_USE bool addCase(size_t successorIndex) {
+ [[nodiscard]] bool addCase(size_t successorIndex) {
return cases_.append(successorIndex);
}
@@ -1864,7 +1864,7 @@ class MTableSwitch final
return blocks_[i];
}
- MOZ_MUST_USE bool addBlock(MBasicBlock* block) {
+ [[nodiscard]] bool addBlock(MBasicBlock* block) {
return blocks_.append(block);
}
@@ -2116,7 +2116,7 @@ MakeSingletonTypeSet(CompilerConstraintList* constraints, JSObject* obj);
TemporaryTypeSet*
MakeSingletonTypeSet(CompilerConstraintList* constraints, ObjectGroup* obj);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
MergeTypes(TempAllocator& alloc, MIRType* ptype, TemporaryTypeSet** ptypeSet,
MIRType newType, TemporaryTypeSet* newTypeSet);
@@ -2197,7 +2197,7 @@ class MNewArray
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
// The template object can safely be used in the recover instruction
// because it can never be mutated by any other function execution.
@@ -2313,7 +2313,7 @@ class MNewTypedArray
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -2428,7 +2428,7 @@ class MNewObject
return vmCall_;
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
// The template object can safely be used in the recover instruction
// because it can never be mutated by any other function execution.
@@ -2542,7 +2542,7 @@ class MNewDerivedTypedObject
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -2557,7 +2557,7 @@ struct OperandIndexMap : public TempObject
// have any large number of properties.
FixedList<uint8_t> map;
- MOZ_MUST_USE bool init(TempAllocator& alloc, JSObject* templateObject);
+ [[nodiscard]] bool init(TempAllocator& alloc, JSObject* templateObject);
};
// Represent the content of all slots of an object. This instruction is not
@@ -2578,7 +2578,7 @@ class MObjectState
MObjectState(JSObject *templateObject, OperandIndexMap* operandIndex);
explicit MObjectState(MObjectState* state);
- MOZ_MUST_USE bool init(TempAllocator& alloc, MDefinition* obj);
+ [[nodiscard]] bool init(TempAllocator& alloc, MDefinition* obj);
void initSlot(uint32_t slot, MDefinition* def) {
initOperand(slot + 1, def);
@@ -2597,7 +2597,7 @@ class MObjectState
// As we might do read of uninitialized properties, we have to copy the
// initial values from the template object.
- MOZ_MUST_USE bool initFromTemplateObject(TempAllocator& alloc, MDefinition* undefinedVal);
+ [[nodiscard]] bool initFromTemplateObject(TempAllocator& alloc, MDefinition* undefinedVal);
size_t numFixedSlots() const {
return numFixedSlots_;
@@ -2647,7 +2647,7 @@ class MObjectState
replaceOperand(operandIndex_->map[offset], def);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -2664,7 +2664,7 @@ class MArrayState
explicit MArrayState(MDefinition* arr);
- MOZ_MUST_USE bool init(TempAllocator& alloc, MDefinition* obj, MDefinition* len);
+ [[nodiscard]] bool init(TempAllocator& alloc, MDefinition* obj, MDefinition* len);
void initElement(uint32_t index, MDefinition* def) {
initOperand(index + 2, def);
@@ -2694,7 +2694,7 @@ class MArrayState
replaceOperand(index + 2, def);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -3181,7 +3181,7 @@ class MAssertRecoveredOnBailout
// Needed to assert that float32 instructions are correctly recovered.
bool canConsumeFloat32(MUse* use) const override { return true; }
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -3381,8 +3381,8 @@ class MCompare
INSTRUCTION_HEADER(Compare)
TRIVIAL_NEW_WRAPPERS
- MOZ_MUST_USE bool tryFold(bool* result);
- MOZ_MUST_USE bool evaluateConstantOperands(TempAllocator& alloc, bool* result);
+ [[nodiscard]] bool tryFold(bool* result);
+ [[nodiscard]] bool evaluateConstantOperands(TempAllocator& alloc, bool* result);
MDefinition* foldsTo(TempAllocator& alloc) override;
void filtersUndefinedOrNull(bool trueBranch, MDefinition** subject, bool* filtersUndefined,
bool* filtersNull);
@@ -3458,8 +3458,8 @@ class MCompare
ALLOW_CLONE(MCompare)
protected:
- MOZ_MUST_USE bool tryFoldEqualOperands(bool* result);
- MOZ_MUST_USE bool tryFoldTypeOf(bool* result);
+ [[nodiscard]] bool tryFoldEqualOperands(bool* result);
+ [[nodiscard]] bool tryFoldTypeOf(bool* result);
bool congruentTo(const MDefinition* ins) const override {
if (!binaryCongruentTo(ins))
@@ -3769,7 +3769,7 @@ class MCreateThisWithTemplate
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override;
};
@@ -4036,7 +4036,7 @@ class MToDouble
implicitTruncate_ = Max(implicitTruncate_, kind);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
if (input()->type() == MIRType::Value) {
return false;
@@ -4103,7 +4103,7 @@ class MToFloat32
bool canConsumeFloat32(MUse* use) const override { return true; }
bool canProduceFloat32() const override { return true; }
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -4479,7 +4479,7 @@ class MTruncateToInt32
}
#endif
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return input()->type() < MIRType::Symbol;
}
@@ -4589,7 +4589,7 @@ class MBitNot
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ != MIRType::None;
}
@@ -4647,7 +4647,7 @@ class MTypeOf
return congruentIfOperandsEqual(ins);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -4784,7 +4784,7 @@ class MBitAnd : public MBinaryBitwiseInstruction
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ != MIRType::None;
}
@@ -4816,7 +4816,7 @@ class MBitOr : public MBinaryBitwiseInstruction
return this;
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ != MIRType::None;
}
@@ -4849,7 +4849,7 @@ class MBitXor : public MBinaryBitwiseInstruction
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -4896,7 +4896,7 @@ class MLsh : public MShiftInstruction
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ != MIRType::None;
}
@@ -4922,7 +4922,7 @@ class MRsh : public MShiftInstruction
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -4965,7 +4965,7 @@ class MUrsh : public MShiftInstruction
void computeRange(TempAllocator& alloc) override;
void collectRangeInfoPreTrunc() override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -5009,7 +5009,7 @@ class MSignExtendInt32
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -5175,7 +5175,7 @@ class MMinMax
}
MDefinition* foldsTo(TempAllocator& alloc) override;
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -5225,7 +5225,7 @@ class MAbs
bool isFloat32Commutative() const override { return true; }
void trySpecializeFloat32(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -5371,7 +5371,7 @@ class MSqrt
bool isFloat32Commutative() const override { return true; }
void trySpecializeFloat32(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -5433,7 +5433,7 @@ class MAtan2
return true;
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -5468,7 +5468,7 @@ class MHypot
return true;
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -5516,7 +5516,7 @@ class MPow
bool possiblyCalls() const override {
return true;
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
// Temporarily disable recovery to relieve fuzzer pressure. See bug 1188586.
return false;
@@ -5566,7 +5566,7 @@ class MPowHalf
return AliasSet::None();
}
void collectRangeInfoPreTrunc() override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -5596,7 +5596,7 @@ class MRandom : public MNullaryInstruction
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
#ifdef JS_MORE_DETERMINISTIC
@@ -5691,7 +5691,7 @@ class MMathFunction
}
void trySpecializeFloat32(TempAllocator& alloc) override;
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
if (input()->type() == MIRType::SinCosDouble)
return false;
@@ -5743,7 +5743,7 @@ class MAdd : public MBinaryArithInstruction
void truncate() override;
TruncateKind operandTruncateKind(size_t index) const override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -5785,7 +5785,7 @@ class MSub : public MBinaryArithInstruction
void truncate() override;
TruncateKind operandTruncateKind(size_t index) const override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -5880,7 +5880,7 @@ class MMul : public MBinaryArithInstruction
canBeNegativeZero_ = negativeZero;
}
- MOZ_MUST_USE bool updateForReplacement(MDefinition* ins) override;
+ [[nodiscard]] bool updateForReplacement(MDefinition* ins) override;
bool fallible() const {
return canBeNegativeZero_ || canOverflow();
@@ -5899,7 +5899,7 @@ class MMul : public MBinaryArithInstruction
Mode mode() const { return mode_; }
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -6033,7 +6033,7 @@ class MDiv : public MBinaryArithInstruction
void collectRangeInfoPreTrunc() override;
TruncateKind operandTruncateKind(size_t index) const override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -6129,7 +6129,7 @@ class MMod : public MBinaryArithInstruction
return trapOffset_;
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return specialization_ < MIRType::Object;
}
@@ -6176,7 +6176,7 @@ class MConcat
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -6210,7 +6210,7 @@ class MCharCodeAt
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -6240,7 +6240,7 @@ class MFromCharCode
return congruentIfOperandsEqual(ins);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -6340,7 +6340,7 @@ class MStringSplit
// it as store instruction, see also MNewArray.
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -6510,12 +6510,12 @@ class MPhi final
// Add types for this phi which speculate about new inputs that may come in
// via a loop backedge.
- MOZ_MUST_USE bool addBackedgeType(TempAllocator& alloc, MIRType type,
+ [[nodiscard]] bool addBackedgeType(TempAllocator& alloc, MIRType type,
TemporaryTypeSet* typeSet);
// Initializes the operands vector to the given capacity,
// permitting use of addInput() instead of addInputSlow().
- MOZ_MUST_USE bool reserveLength(size_t length) {
+ [[nodiscard]] bool reserveLength(size_t length) {
return inputs_.reserve(length);
}
@@ -6526,7 +6526,7 @@ class MPhi final
// Appends a new input to the input vector. May perform reallocation.
// Prefer reserveLength() and addInput() instead, where possible.
- MOZ_MUST_USE bool addInputSlow(MDefinition* ins) {
+ [[nodiscard]] bool addInputSlow(MDefinition* ins) {
return inputs_.emplaceBack(ins, this);
}
@@ -7064,7 +7064,7 @@ class MRegExpMatcher
TRIVIAL_NEW_WRAPPERS
NAMED_OPERANDS((0, regexp), (1, string), (2, lastIndex))
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
@@ -7099,7 +7099,7 @@ class MRegExpSearcher
TRIVIAL_NEW_WRAPPERS
NAMED_OPERANDS((0, regexp), (1, string), (2, lastIndex))
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
@@ -7138,7 +7138,7 @@ class MRegExpTester
return true;
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -7251,7 +7251,7 @@ class MStringReplace
return AliasSet::None();
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
if (isFlatReplacement_) {
MOZ_ASSERT(!pattern()->isRegExp());
@@ -7392,7 +7392,7 @@ class MLambda
const LambdaFunctionInfo& info() const {
return info_;
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -8112,7 +8112,7 @@ class MNot
bool congruentTo(const MDefinition* ins) const override {
return congruentIfOperandsEqual(ins);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -9582,7 +9582,7 @@ class InlinePropertyTable : public TempObject
return pc_;
}
- MOZ_MUST_USE bool addEntry(TempAllocator& alloc, ObjectGroup* group, JSFunction* func) {
+ [[nodiscard]] bool addEntry(TempAllocator& alloc, ObjectGroup* group, JSFunction* func) {
return entries_.append(new(alloc) Entry(group, func));
}
@@ -9703,7 +9703,7 @@ class MGetPropertyCache
}
void setBlock(MBasicBlock* block) override;
- MOZ_MUST_USE bool updateForReplacement(MDefinition* ins) override;
+ [[nodiscard]] bool updateForReplacement(MDefinition* ins) override;
bool allowDoubleResult() const;
@@ -9761,7 +9761,7 @@ class MGetPropertyPolymorphic
return congruentIfOperandsEqual(ins);
}
- MOZ_MUST_USE bool addReceiver(const ReceiverGuard& receiver, Shape* shape) {
+ [[nodiscard]] bool addReceiver(const ReceiverGuard& receiver, Shape* shape) {
PolymorphicEntry entry;
entry.receiver = receiver;
entry.shape = shape;
@@ -9826,7 +9826,7 @@ class MSetPropertyPolymorphic
return new(alloc) MSetPropertyPolymorphic(alloc, obj, value, name);
}
- MOZ_MUST_USE bool addReceiver(const ReceiverGuard& receiver, Shape* shape) {
+ [[nodiscard]] bool addReceiver(const ReceiverGuard& receiver, Shape* shape) {
PolymorphicEntry entry;
entry.receiver = receiver;
entry.shape = shape;
@@ -9952,7 +9952,7 @@ class MDispatchInstruction
}
public:
- MOZ_MUST_USE bool addCase(JSFunction* func, ObjectGroup* funcGroup, MBasicBlock* block) {
+ [[nodiscard]] bool addCase(JSFunction* func, ObjectGroup* funcGroup, MBasicBlock* block) {
return map_.append(Entry(func, funcGroup, block));
}
uint32_t numCases() const {
@@ -10162,7 +10162,7 @@ class MGuardReceiverPolymorphic
return new(alloc) MGuardReceiverPolymorphic(alloc, obj);
}
- MOZ_MUST_USE bool addReceiver(const ReceiverGuard& receiver) {
+ [[nodiscard]] bool addReceiver(const ReceiverGuard& receiver) {
return receivers_.append(receiver);
}
size_t numReceivers() const {
@@ -10896,7 +10896,7 @@ class MGetDOMProperty
return info_;
}
- MOZ_MUST_USE bool init(TempAllocator& alloc, MDefinition* obj, MDefinition* guard,
+ [[nodiscard]] bool init(TempAllocator& alloc, MDefinition* obj, MDefinition* guard,
MDefinition* globalGuard) {
MOZ_ASSERT(obj);
// guard can be null.
@@ -11049,7 +11049,7 @@ class MStringLength
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -11090,7 +11090,7 @@ class MFloor
return congruentIfOperandsEqual(ins);
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -11131,7 +11131,7 @@ class MCeil
return congruentIfOperandsEqual(ins);
}
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -11173,7 +11173,7 @@ class MRound
return congruentIfOperandsEqual(ins);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
@@ -11397,7 +11397,7 @@ class MArgumentsLength : public MNullaryInstruction
void computeRange(TempAllocator& alloc) override;
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
@@ -11910,7 +11910,7 @@ class MResumePoint final :
protected:
// Initializes operands_ to an empty array of a fixed length.
// The array may then be filled in by inherit().
- MOZ_MUST_USE bool init(TempAllocator& alloc);
+ [[nodiscard]] bool init(TempAllocator& alloc);
void clearOperand(size_t index) {
// FixedList doesn't initialize its elements, so do an unchecked init.
@@ -12000,7 +12000,7 @@ class MResumePoint final :
}
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
// Register a store instruction on the current resume point. This
// instruction would be recovered when we are bailing out. The |cache|
@@ -12292,7 +12292,7 @@ class MAtomicIsLockFree
return congruentIfOperandsEqual(ins);
}
- MOZ_MUST_USE bool writeRecoverData(CompactBufferWriter& writer) const override;
+ [[nodiscard]] bool writeRecoverData(CompactBufferWriter& writer) const override;
bool canRecoverOnBailout() const override {
return true;
}
diff --git a/js/src/jit/MIRGenerator.h b/js/src/jit/MIRGenerator.h
index 53e1155be9..3f1ee61f38 100644
--- a/js/src/jit/MIRGenerator.h
+++ b/js/src/jit/MIRGenerator.h
@@ -48,7 +48,7 @@ class MIRGenerator
MIRGraph& graph() {
return *graph_;
}
- MOZ_MUST_USE bool ensureBallast() {
+ [[nodiscard]] bool ensureBallast() {
return alloc().ensureBallast();
}
const JitRuntime* jitRuntime() const {
@@ -78,7 +78,7 @@ class MIRGenerator
return error_;
}
- MOZ_MUST_USE bool instrumentedProfiling() {
+ [[nodiscard]] bool instrumentedProfiling() {
if (!instrumentedProfilingIsCached_) {
instrumentedProfiling_ = GetJitContext()->runtime->spsProfiler().enabled();
instrumentedProfilingIsCached_ = true;
diff --git a/js/src/jit/MIRGraph.h b/js/src/jit/MIRGraph.h
index d68be8039c..a404adc3e9 100644
--- a/js/src/jit/MIRGraph.h
+++ b/js/src/jit/MIRGraph.h
@@ -46,11 +46,11 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
private:
MBasicBlock(MIRGraph& graph, const CompileInfo& info, BytecodeSite* site, Kind kind);
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
void copySlots(MBasicBlock* from);
- MOZ_MUST_USE bool inherit(TempAllocator& alloc, BytecodeAnalysis* analysis, MBasicBlock* pred,
+ [[nodiscard]] bool inherit(TempAllocator& alloc, BytecodeAnalysis* analysis, MBasicBlock* pred,
uint32_t popped, unsigned stackPhiCount = 0);
- MOZ_MUST_USE bool inheritResumePoint(MBasicBlock* pred);
+ [[nodiscard]] bool inheritResumePoint(MBasicBlock* pred);
void assertUsesAreNotWithin(MUseIterator use, MUseIterator end);
// This block cannot be reached by any means.
@@ -154,8 +154,8 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
MDefinition* argumentsObject();
// Increase the number of slots available
- MOZ_MUST_USE bool increaseSlots(size_t num);
- MOZ_MUST_USE bool ensureHasSlots(size_t num);
+ [[nodiscard]] bool increaseSlots(size_t num);
+ [[nodiscard]] bool ensureHasSlots(size_t num);
// Initializes a slot value; must not be called for normal stack
// operations, as it will not create new SSA names for copies.
@@ -166,7 +166,7 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
// In an OSR block, set all MOsrValues to use the MResumePoint attached to
// the MStart.
- MOZ_MUST_USE bool linkOsrValues(MStart* start);
+ [[nodiscard]] bool linkOsrValues(MStart* start);
// Sets the instruction associated with various slot types. The
// instruction must lie at the top of the stack.
@@ -220,17 +220,17 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
// Adds a predecessor. Every predecessor must have the same exit stack
// depth as the entry state to this block. Adding a predecessor
// automatically creates phi nodes and rewrites uses as needed.
- MOZ_MUST_USE bool addPredecessor(TempAllocator& alloc, MBasicBlock* pred);
- MOZ_MUST_USE bool addPredecessorPopN(TempAllocator& alloc, MBasicBlock* pred, uint32_t popped);
+ [[nodiscard]] bool addPredecessor(TempAllocator& alloc, MBasicBlock* pred);
+ [[nodiscard]] bool addPredecessorPopN(TempAllocator& alloc, MBasicBlock* pred, uint32_t popped);
// Add a predecessor which won't introduce any new phis to this block.
// This may be called after the contents of this block have been built.
void addPredecessorSameInputsAs(MBasicBlock* pred, MBasicBlock* existingPred);
// Stranger utilities used for inlining.
- MOZ_MUST_USE bool addPredecessorWithoutPhis(MBasicBlock* pred);
+ [[nodiscard]] bool addPredecessorWithoutPhis(MBasicBlock* pred);
void inheritSlots(MBasicBlock* parent);
- MOZ_MUST_USE bool initEntrySlots(TempAllocator& alloc);
+ [[nodiscard]] bool initEntrySlots(TempAllocator& alloc);
// Replaces an edge for a given block with a new block. This is
// used for critical edge splitting.
@@ -255,8 +255,8 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
// Sets a back edge. This places phi nodes and rewrites instructions within
// the current loop as necessary. If the backedge introduces new types for
// phis at the loop header, returns a disabling abort.
- MOZ_MUST_USE AbortReason setBackedge(TempAllocator& alloc, MBasicBlock* block);
- MOZ_MUST_USE bool setBackedgeWasm(MBasicBlock* block);
+ [[nodiscard]] AbortReason setBackedge(TempAllocator& alloc, MBasicBlock* block);
+ [[nodiscard]] bool setBackedgeWasm(MBasicBlock* block);
// Resets a LOOP_HEADER block to a NORMAL block. This is needed when
// optimizations remove the backedge.
@@ -271,11 +271,11 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
void inheritPhis(MBasicBlock* header);
// Propagates backedge slots into phis operands of the loop header.
- MOZ_MUST_USE bool inheritPhisFromBackedge(TempAllocator& alloc, MBasicBlock* backedge,
+ [[nodiscard]] bool inheritPhisFromBackedge(TempAllocator& alloc, MBasicBlock* backedge,
bool* hadTypeChange);
// Compute the types for phis in this block according to their inputs.
- MOZ_MUST_USE bool specializePhis(TempAllocator& alloc);
+ [[nodiscard]] bool specializePhis(TempAllocator& alloc);
void insertBefore(MInstruction* at, MInstruction* ins);
void insertAfter(MInstruction* at, MInstruction* ins);
@@ -683,7 +683,7 @@ class MBasicBlock : public TempObject, public InlineListNode<MBasicBlock>
#endif
public:
explicit BackupPoint(MBasicBlock* current);
- MOZ_MUST_USE bool init(TempAllocator& alloc);
+ [[nodiscard]] bool init(TempAllocator& alloc);
MBasicBlock* restore();
};
@@ -804,7 +804,7 @@ class MIRGraph
return returnAccumulator_;
}
- MOZ_MUST_USE bool addReturn(MBasicBlock* returnBlock) {
+ [[nodiscard]] bool addReturn(MBasicBlock* returnBlock) {
if (!returnAccumulator_)
return true;
diff --git a/js/src/jit/MacroAssembler.h b/js/src/jit/MacroAssembler.h
index f681456396..d9c0532c34 100644
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -1886,10 +1886,10 @@ class MacroAssembler : public MacroAssemblerSpecific
void convertValueToFloatingPoint(ValueOperand value, FloatRegister output, Label* fail,
MIRType outputType);
- MOZ_MUST_USE bool convertValueToFloatingPoint(JSContext* cx, const Value& v,
+ [[nodiscard]] bool convertValueToFloatingPoint(JSContext* cx, const Value& v,
FloatRegister output, Label* fail,
MIRType outputType);
- MOZ_MUST_USE bool convertConstantOrRegisterToFloatingPoint(JSContext* cx,
+ [[nodiscard]] bool convertConstantOrRegisterToFloatingPoint(JSContext* cx,
const ConstantOrRegister& src,
FloatRegister output, Label* fail,
MIRType outputType);
@@ -1903,11 +1903,11 @@ class MacroAssembler : public MacroAssemblerSpecific
void convertValueToDouble(ValueOperand value, FloatRegister output, Label* fail) {
convertValueToFloatingPoint(value, output, fail, MIRType::Double);
}
- MOZ_MUST_USE bool convertValueToDouble(JSContext* cx, const Value& v, FloatRegister output,
+ [[nodiscard]] bool convertValueToDouble(JSContext* cx, const Value& v, FloatRegister output,
Label* fail) {
return convertValueToFloatingPoint(cx, v, output, fail, MIRType::Double);
}
- MOZ_MUST_USE bool convertConstantOrRegisterToDouble(JSContext* cx,
+ [[nodiscard]] bool convertConstantOrRegisterToDouble(JSContext* cx,
const ConstantOrRegister& src,
FloatRegister output, Label* fail)
{
@@ -1920,11 +1920,11 @@ class MacroAssembler : public MacroAssemblerSpecific
void convertValueToFloat(ValueOperand value, FloatRegister output, Label* fail) {
convertValueToFloatingPoint(value, output, fail, MIRType::Float32);
}
- MOZ_MUST_USE bool convertValueToFloat(JSContext* cx, const Value& v, FloatRegister output,
+ [[nodiscard]] bool convertValueToFloat(JSContext* cx, const Value& v, FloatRegister output,
Label* fail) {
return convertValueToFloatingPoint(cx, v, output, fail, MIRType::Float32);
}
- MOZ_MUST_USE bool convertConstantOrRegisterToFloat(JSContext* cx,
+ [[nodiscard]] bool convertConstantOrRegisterToFloat(JSContext* cx,
const ConstantOrRegister& src,
FloatRegister output, Label* fail)
{
@@ -1969,9 +1969,9 @@ class MacroAssembler : public MacroAssemblerSpecific
convertValueToInt(value, nullptr, nullptr, nullptr, nullptr, InvalidReg, temp, output,
fail, behavior);
}
- MOZ_MUST_USE bool convertValueToInt(JSContext* cx, const Value& v, Register output, Label* fail,
+ [[nodiscard]] bool convertValueToInt(JSContext* cx, const Value& v, Register output, Label* fail,
IntConversionBehavior behavior);
- MOZ_MUST_USE bool convertConstantOrRegisterToInt(JSContext* cx,
+ [[nodiscard]] bool convertConstantOrRegisterToInt(JSContext* cx,
const ConstantOrRegister& src,
FloatRegister temp, Register output,
Label* fail, IntConversionBehavior behavior);
@@ -1998,14 +1998,14 @@ class MacroAssembler : public MacroAssemblerSpecific
: IntConversion_Normal,
conversion);
}
- MOZ_MUST_USE bool convertValueToInt32(JSContext* cx, const Value& v, Register output,
+ [[nodiscard]] bool convertValueToInt32(JSContext* cx, const Value& v, Register output,
Label* fail, bool negativeZeroCheck)
{
return convertValueToInt(cx, v, output, fail, negativeZeroCheck
? IntConversion_NegativeZeroCheck
: IntConversion_Normal);
}
- MOZ_MUST_USE bool convertConstantOrRegisterToInt32(JSContext* cx,
+ [[nodiscard]] bool convertConstantOrRegisterToInt32(JSContext* cx,
const ConstantOrRegister& src,
FloatRegister temp, Register output,
Label* fail, bool negativeZeroCheck)
@@ -2042,11 +2042,11 @@ class MacroAssembler : public MacroAssemblerSpecific
convertValueToInt(value, input, nullptr, nullptr, nullptr, InvalidReg, temp, output, fail,
IntConversion_Truncate);
}
- MOZ_MUST_USE bool truncateValueToInt32(JSContext* cx, const Value& v, Register output,
+ [[nodiscard]] bool truncateValueToInt32(JSContext* cx, const Value& v, Register output,
Label* fail) {
return convertValueToInt(cx, v, output, fail, IntConversion_Truncate);
}
- MOZ_MUST_USE bool truncateConstantOrRegisterToInt32(JSContext* cx,
+ [[nodiscard]] bool truncateConstantOrRegisterToInt32(JSContext* cx,
const ConstantOrRegister& src,
FloatRegister temp, Register output,
Label* fail)
@@ -2076,11 +2076,11 @@ class MacroAssembler : public MacroAssemblerSpecific
convertValueToInt(value, input, nullptr, nullptr, nullptr, InvalidReg, temp, output, fail,
IntConversion_ClampToUint8);
}
- MOZ_MUST_USE bool clampValueToUint8(JSContext* cx, const Value& v, Register output,
+ [[nodiscard]] bool clampValueToUint8(JSContext* cx, const Value& v, Register output,
Label* fail) {
return convertValueToInt(cx, v, output, fail, IntConversion_ClampToUint8);
}
- MOZ_MUST_USE bool clampConstantOrRegisterToUint8(JSContext* cx,
+ [[nodiscard]] bool clampConstantOrRegisterToUint8(JSContext* cx,
const ConstantOrRegister& src,
FloatRegister temp, Register output,
Label* fail)
@@ -2114,7 +2114,7 @@ class MacroAssembler : public MacroAssemblerSpecific
void restoreFrameAlignmentForICArguments(AfterICSaveLive& aic) PER_ARCH;
AfterICSaveLive icSaveLive(LiveRegisterSet& liveRegs);
- MOZ_MUST_USE bool icBuildOOLFakeExitFrame(void* fakeReturnAddr, AfterICSaveLive& aic);
+ [[nodiscard]] bool icBuildOOLFakeExitFrame(void* fakeReturnAddr, AfterICSaveLive& aic);
void icRestoreLive(LiveRegisterSet& liveRegs, AfterICSaveLive& aic);
// Align the stack pointer based on the number of arguments which are pushed
diff --git a/js/src/jit/MoveResolver.h b/js/src/jit/MoveResolver.h
index f52d6bc99a..40809b77c6 100644
--- a/js/src/jit/MoveResolver.h
+++ b/js/src/jit/MoveResolver.h
@@ -299,7 +299,7 @@ class MoveResolver
PendingMove* findBlockingMove(const PendingMove* last);
PendingMove* findCycledMove(PendingMoveIterator* stack, PendingMoveIterator end, const PendingMove* first);
- MOZ_MUST_USE bool addOrderedMove(const MoveOp& move);
+ [[nodiscard]] bool addOrderedMove(const MoveOp& move);
void reorderMove(size_t from, size_t to);
// Internal reset function. Does not clear lists.
@@ -319,8 +319,8 @@ class MoveResolver
//
// After calling addMove() for each parallel move, resolve() performs the
// cycle resolution algorithm. Calling addMove() again resets the resolver.
- MOZ_MUST_USE bool addMove(const MoveOperand& from, const MoveOperand& to, MoveOp::Type type);
- MOZ_MUST_USE bool resolve();
+ [[nodiscard]] bool addMove(const MoveOperand& from, const MoveOperand& to, MoveOp::Type type);
+ [[nodiscard]] bool resolve();
void sortMemoryToMemoryMoves();
size_t numMoves() const {
diff --git a/js/src/jit/OptimizationTracking.h b/js/src/jit/OptimizationTracking.h
index 1854fc1652..d2d6909369 100644
--- a/js/src/jit/OptimizationTracking.h
+++ b/js/src/jit/OptimizationTracking.h
@@ -74,8 +74,8 @@ class OptimizationTypeInfo
types_(alloc)
{ }
- MOZ_MUST_USE bool trackTypeSet(TemporaryTypeSet* typeSet);
- MOZ_MUST_USE bool trackType(TypeSet::Type type);
+ [[nodiscard]] bool trackTypeSet(TemporaryTypeSet* typeSet);
+ [[nodiscard]] bool trackType(TypeSet::Type type);
JS::TrackedTypeSite site() const { return site_; }
MIRType mirType() const { return mirType_; }
@@ -86,8 +86,8 @@ class OptimizationTypeInfo
HashNumber hash() const;
- MOZ_MUST_USE bool writeCompact(JSContext* cx, CompactBufferWriter& writer,
- UniqueTrackedTypes& uniqueTypes) const;
+ [[nodiscard]] bool writeCompact(JSContext* cx, CompactBufferWriter& writer,
+ UniqueTrackedTypes& uniqueTypes) const;
};
typedef Vector<OptimizationTypeInfo, 1, JitAllocPolicy> TempOptimizationTypeInfoVector;
@@ -113,9 +113,9 @@ class TrackedOptimizations : public TempObject
currentAttempt_ = UINT32_MAX;
}
- MOZ_MUST_USE bool trackTypeInfo(OptimizationTypeInfo&& ty);
+ [[nodiscard]] bool trackTypeInfo(OptimizationTypeInfo&& ty);
- MOZ_MUST_USE bool trackAttempt(JS::TrackedStrategy strategy);
+ [[nodiscard]] bool trackAttempt(JS::TrackedStrategy strategy);
void amendAttempt(uint32_t index);
void trackOutcome(JS::TrackedOutcome outcome);
void trackSuccess();
@@ -173,10 +173,10 @@ class UniqueTrackedOptimizations
sorted_(cx)
{ }
- MOZ_MUST_USE bool init() { return map_.init(); }
- MOZ_MUST_USE bool add(const TrackedOptimizations* optimizations);
+ [[nodiscard]] bool init() { return map_.init(); }
+ [[nodiscard]] bool add(const TrackedOptimizations* optimizations);
- MOZ_MUST_USE bool sortByFrequency(JSContext* cx);
+ [[nodiscard]] bool sortByFrequency(JSContext* cx);
bool sorted() const { return !sorted_.empty(); }
uint32_t count() const { MOZ_ASSERT(sorted()); return sorted_.length(); }
const SortedVector& sortedVector() const { MOZ_ASSERT(sorted()); return sorted_; }
@@ -406,10 +406,10 @@ class IonTrackedOptimizationsRegion
uint8_t* index);
static void WriteDelta(CompactBufferWriter& writer, uint32_t startDelta, uint32_t length,
uint8_t index);
- static MOZ_MUST_USE bool WriteRun(CompactBufferWriter& writer,
- const NativeToTrackedOptimizations* start,
- const NativeToTrackedOptimizations* end,
- const UniqueTrackedOptimizations& unique);
+ [[nodiscard]] static bool WriteRun(CompactBufferWriter& writer,
+ const NativeToTrackedOptimizations* start,
+ const NativeToTrackedOptimizations* end,
+ const UniqueTrackedOptimizations& unique);
};
class IonTrackedOptimizationsAttempts
@@ -559,7 +559,7 @@ typedef IonTrackedOptimizationsOffsetsTable<IonTrackedOptimizationsAttempts>
typedef IonTrackedOptimizationsOffsetsTable<IonTrackedOptimizationsTypeInfo>
IonTrackedOptimizationsTypesTable;
-MOZ_MUST_USE bool
+[[nodiscard]] bool
WriteIonTrackedOptimizationsTable(JSContext* cx, CompactBufferWriter& writer,
const NativeToTrackedOptimizations* start,
const NativeToTrackedOptimizations* end,
diff --git a/js/src/jit/PcScriptCache.h b/js/src/jit/PcScriptCache.h
index 03f8f311b4..c3060f3ea4 100644
--- a/js/src/jit/PcScriptCache.h
+++ b/js/src/jit/PcScriptCache.h
@@ -40,8 +40,8 @@ struct PcScriptCache
}
// Get a value from the cache. May perform lazy allocation.
- MOZ_MUST_USE bool get(JSRuntime* rt, uint32_t hash, uint8_t* addr,
- JSScript** scriptRes, jsbytecode** pcRes)
+ [[nodiscard]] bool get(JSRuntime* rt, uint32_t hash, uint8_t* addr,
+ JSScript** scriptRes, jsbytecode** pcRes)
{
// If a GC occurred, lazily clear the cache now.
if (gcNumber != rt->gc.gcNumber()) {
diff --git a/js/src/jit/PerfSpewer.h b/js/src/jit/PerfSpewer.h
index 465058574b..046e17838f 100644
--- a/js/src/jit/PerfSpewer.h
+++ b/js/src/jit/PerfSpewer.h
@@ -65,9 +65,9 @@ class PerfSpewer
BasicBlocksVector basicBlocks_;
public:
- virtual MOZ_MUST_USE bool startBasicBlock(MBasicBlock* blk, MacroAssembler& masm);
- virtual MOZ_MUST_USE bool endBasicBlock(MacroAssembler& masm);
- MOZ_MUST_USE bool noteEndInlineCode(MacroAssembler& masm);
+ [[nodiscard]] virtual bool startBasicBlock(MBasicBlock* blk, MacroAssembler& masm);
+ [[nodiscard]] virtual bool endBasicBlock(MacroAssembler& masm);
+ [[nodiscard]] bool noteEndInlineCode(MacroAssembler& masm);
void writeProfile(JSScript* script, JitCode* code, MacroAssembler& masm);
};
@@ -79,8 +79,8 @@ void writePerfSpewerJitCodeProfile(JitCode* code, const char* msg);
class WasmPerfSpewer : public PerfSpewer
{
public:
- MOZ_MUST_USE bool startBasicBlock(MBasicBlock* blk, MacroAssembler& masm) { return true; }
- MOZ_MUST_USE bool endBasicBlock(MacroAssembler& masm) { return true; }
+ [[nodiscard]] bool startBasicBlock(MBasicBlock* blk, MacroAssembler& masm) { return true; }
+ [[nodiscard]] bool endBasicBlock(MacroAssembler& masm) { return true; }
};
void writePerfSpewerWasmFunctionMap(uintptr_t base, uintptr_t size, const char* filename,
diff --git a/js/src/jit/ProcessExecutableMemory.cpp b/js/src/jit/ProcessExecutableMemory.cpp
index 7c40d93c71..a49ac22e77 100644
--- a/js/src/jit/ProcessExecutableMemory.cpp
+++ b/js/src/jit/ProcessExecutableMemory.cpp
@@ -441,7 +441,7 @@ class ProcessExecutableMemory
pages_()
{}
- MOZ_MUST_USE bool init() {
+ [[nodiscard]] bool init() {
pages_.init();
MOZ_RELEASE_ASSERT(!initialized());
diff --git a/js/src/jit/ProcessExecutableMemory.h b/js/src/jit/ProcessExecutableMemory.h
index 45c9c23b8c..efc47247fa 100644
--- a/js/src/jit/ProcessExecutableMemory.h
+++ b/js/src/jit/ProcessExecutableMemory.h
@@ -22,11 +22,11 @@ enum class ProtectionSetting {
Executable,
};
-extern MOZ_MUST_USE bool ReprotectRegion(void* start, size_t size, ProtectionSetting protection);
+[[nodiscard]] extern bool ReprotectRegion(void* start, size_t size, ProtectionSetting protection);
// Functions called at process start-up/shutdown to initialize/release the
// executable memory region.
-extern MOZ_MUST_USE bool InitProcessExecutableMemory();
+[[nodiscard]] extern bool InitProcessExecutableMemory();
extern void ReleaseProcessExecutableMemory();
// Allocate/deallocate executable pages.
diff --git a/js/src/jit/RangeAnalysis.h b/js/src/jit/RangeAnalysis.h
index 16fe93e000..879a20c940 100644
--- a/js/src/jit/RangeAnalysis.h
+++ b/js/src/jit/RangeAnalysis.h
@@ -103,24 +103,24 @@ class RangeAnalysis
public:
RangeAnalysis(MIRGenerator* mir, MIRGraph& graph) :
mir(mir), graph_(graph) {}
- MOZ_MUST_USE bool addBetaNodes();
- MOZ_MUST_USE bool analyze();
- MOZ_MUST_USE bool addRangeAssertions();
- MOZ_MUST_USE bool removeBetaNodes();
- MOZ_MUST_USE bool prepareForUCE(bool* shouldRemoveDeadCode);
- MOZ_MUST_USE bool tryRemovingGuards();
- MOZ_MUST_USE bool truncate();
- MOZ_MUST_USE bool removeUnnecessaryBitops();
+ [[nodiscard]] bool addBetaNodes();
+ [[nodiscard]] bool analyze();
+ [[nodiscard]] bool addRangeAssertions();
+ [[nodiscard]] bool removeBetaNodes();
+ [[nodiscard]] bool prepareForUCE(bool* shouldRemoveDeadCode);
+ [[nodiscard]] bool tryRemovingGuards();
+ [[nodiscard]] bool truncate();
+ [[nodiscard]] bool removeUnnecessaryBitops();
// Any iteration bounds discovered for loops in the graph.
LoopIterationBoundVector loopIterationBounds;
private:
- MOZ_MUST_USE bool analyzeLoop(MBasicBlock* header);
+ [[nodiscard]] bool analyzeLoop(MBasicBlock* header);
LoopIterationBound* analyzeLoopIterationCount(MBasicBlock* header,
MTest* test, BranchDirection direction);
void analyzeLoopPhi(MBasicBlock* header, LoopIterationBound* loopBound, MPhi* phi);
- MOZ_MUST_USE bool tryHoistBoundsCheck(MBasicBlock* header, MBoundsCheck* ins);
+ [[nodiscard]] bool tryHoistBoundsCheck(MBasicBlock* header, MBoundsCheck* ins);
};
class Range : public TempObject {
@@ -455,7 +455,7 @@ class Range : public TempObject {
void dump(GenericPrinter& out) const;
void dump() const;
- MOZ_MUST_USE bool update(const Range* other);
+ [[nodiscard]] bool update(const Range* other);
// Unlike the other operations, unionWith is an in-place
// modification. This is to avoid a bunch of useless extra
@@ -485,7 +485,7 @@ class Range : public TempObject {
static Range* sign(TempAllocator& alloc, const Range* op);
static Range* NaNToZero(TempAllocator& alloc, const Range* op);
- static MOZ_MUST_USE bool negativeZeroMul(const Range* lhs, const Range* rhs);
+ [[nodiscard]] static bool negativeZeroMul(const Range* lhs, const Range* rhs);
bool isUnknownInt32() const {
return isInt32() && lower() == INT32_MIN && upper() == INT32_MAX;
diff --git a/js/src/jit/Recover.h b/js/src/jit/Recover.h
index ee330d78e5..dc4e9bed50 100644
--- a/js/src/jit/Recover.h
+++ b/js/src/jit/Recover.h
@@ -143,7 +143,7 @@ class MOZ_NON_PARAM RInstruction
// Function used to recover the value computed by this instruction. This
// function reads its arguments from the allocations listed on the snapshot
// iterator and stores its returned value on the snapshot iterator too.
- virtual MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const = 0;
+ [[nodiscard]] virtual bool recover(JSContext* cx, SnapshotIterator& iter) const = 0;
// Decode an RInstruction on top of the reserved storage space, based on the
// tag written by the writeRecoverData function of the corresponding MIR
@@ -195,7 +195,7 @@ class RResumePoint final : public RInstruction
uint32_t numOperands() const override {
return numOperands_;
}
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RBitNot final : public RInstruction
@@ -203,7 +203,7 @@ class RBitNot final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(BitNot, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RBitAnd final : public RInstruction
@@ -211,7 +211,7 @@ class RBitAnd final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(BitAnd, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RBitOr final : public RInstruction
@@ -219,7 +219,7 @@ class RBitOr final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(BitOr, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RBitXor final : public RInstruction
@@ -227,7 +227,7 @@ class RBitXor final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(BitXor, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RLsh final : public RInstruction
@@ -235,7 +235,7 @@ class RLsh final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Lsh, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RRsh final : public RInstruction
@@ -243,7 +243,7 @@ class RRsh final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Rsh, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RUrsh final : public RInstruction
@@ -251,7 +251,7 @@ class RUrsh final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Ursh, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RSignExtendInt32 final : public RInstruction
@@ -262,7 +262,7 @@ class RSignExtendInt32 final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(SignExtendInt32, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RAdd final : public RInstruction
@@ -273,7 +273,7 @@ class RAdd final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Add, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RSub final : public RInstruction
@@ -284,7 +284,7 @@ class RSub final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Sub, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RMul final : public RInstruction
@@ -296,7 +296,7 @@ class RMul final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Mul, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RDiv final : public RInstruction
@@ -307,7 +307,7 @@ class RDiv final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Div, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RMod final : public RInstruction
@@ -315,7 +315,7 @@ class RMod final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Mod, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RNot final : public RInstruction
@@ -323,7 +323,7 @@ class RNot final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Not, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RConcat final : public RInstruction
@@ -331,7 +331,7 @@ class RConcat final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Concat, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RStringLength final : public RInstruction
@@ -339,7 +339,7 @@ class RStringLength final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(StringLength, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RArgumentsLength final : public RInstruction
@@ -347,7 +347,7 @@ class RArgumentsLength final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(ArgumentsLength, 0)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
@@ -356,7 +356,7 @@ class RFloor final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Floor, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RCeil final : public RInstruction
@@ -364,7 +364,7 @@ class RCeil final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Ceil, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RRound final : public RInstruction
@@ -372,7 +372,7 @@ class RRound final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Round, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RCharCodeAt final : public RInstruction
@@ -380,7 +380,7 @@ class RCharCodeAt final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(CharCodeAt, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RFromCharCode final : public RInstruction
@@ -388,7 +388,7 @@ class RFromCharCode final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(FromCharCode, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RPow final : public RInstruction
@@ -396,7 +396,7 @@ class RPow final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Pow, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RPowHalf final : public RInstruction
@@ -404,7 +404,7 @@ class RPowHalf final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(PowHalf, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RMinMax final : public RInstruction
@@ -415,7 +415,7 @@ class RMinMax final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(MinMax, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RAbs final : public RInstruction
@@ -423,7 +423,7 @@ class RAbs final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Abs, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RSqrt final : public RInstruction
@@ -434,7 +434,7 @@ class RSqrt final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Sqrt, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RAtan2 final : public RInstruction
@@ -442,7 +442,7 @@ class RAtan2 final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Atan2, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RHypot final : public RInstruction
@@ -457,7 +457,7 @@ class RHypot final : public RInstruction
return numOperands_;
}
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RMathFunction final : public RInstruction
@@ -468,14 +468,14 @@ class RMathFunction final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(MathFunction, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RRandom final : public RInstruction
{
RINSTRUCTION_HEADER_NUM_OP_(Random, 0)
public:
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RStringSplit final : public RInstruction
@@ -483,7 +483,7 @@ class RStringSplit final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(StringSplit, 3)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RNaNToZero final : public RInstruction
@@ -499,7 +499,7 @@ class RRegExpMatcher final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(RegExpMatcher, 3)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RRegExpSearcher final : public RInstruction
@@ -507,7 +507,7 @@ class RRegExpSearcher final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(RegExpSearcher, 3)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RRegExpTester final : public RInstruction
@@ -515,7 +515,7 @@ class RRegExpTester final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(RegExpTester, 3)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RStringReplace final : public RInstruction
@@ -526,7 +526,7 @@ class RStringReplace final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(StringReplace, 3)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RTypeOf final : public RInstruction
@@ -534,7 +534,7 @@ class RTypeOf final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(TypeOf, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RToDouble final : public RInstruction
@@ -542,7 +542,7 @@ class RToDouble final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(ToDouble, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RToFloat32 final : public RInstruction
@@ -550,7 +550,7 @@ class RToFloat32 final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(ToFloat32, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RTruncateToInt32 final : public RInstruction
@@ -558,7 +558,7 @@ class RTruncateToInt32 final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(TruncateToInt32, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RNewObject final : public RInstruction
@@ -569,7 +569,7 @@ class RNewObject final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(NewObject, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RNewTypedArray final : public RInstruction
@@ -577,7 +577,7 @@ class RNewTypedArray final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(NewTypedArray, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RNewArray final : public RInstruction
@@ -588,7 +588,7 @@ class RNewArray final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(NewArray, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RNewDerivedTypedObject final : public RInstruction
@@ -596,7 +596,7 @@ class RNewDerivedTypedObject final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(NewDerivedTypedObject, 3)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RCreateThisWithTemplate final : public RInstruction
@@ -604,7 +604,7 @@ class RCreateThisWithTemplate final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(CreateThisWithTemplate, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RLambda final : public RInstruction
@@ -612,7 +612,7 @@ class RLambda final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(Lambda, 2)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RObjectState final : public RInstruction
@@ -631,7 +631,7 @@ class RObjectState final : public RInstruction
return numSlots() + 1;
}
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RArrayState final : public RInstruction
@@ -651,7 +651,7 @@ class RArrayState final : public RInstruction
return numElements() + 2;
}
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RAtomicIsLockFree final : public RInstruction
@@ -659,7 +659,7 @@ class RAtomicIsLockFree final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(AtomicIsLockFree, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
class RAssertRecoveredOnBailout final : public RInstruction
@@ -667,7 +667,7 @@ class RAssertRecoveredOnBailout final : public RInstruction
public:
RINSTRUCTION_HEADER_NUM_OP_(AssertRecoveredOnBailout, 1)
- MOZ_MUST_USE bool recover(JSContext* cx, SnapshotIterator& iter) const override;
+ [[nodiscard]] bool recover(JSContext* cx, SnapshotIterator& iter) const override;
};
#undef RINSTRUCTION_HEADER_
diff --git a/js/src/jit/RegisterAllocator.h b/js/src/jit/RegisterAllocator.h
index 97333fbdca..39ead5df27 100644
--- a/js/src/jit/RegisterAllocator.h
+++ b/js/src/jit/RegisterAllocator.h
@@ -36,13 +36,13 @@ struct AllocationIntegrityState
// Record all virtual registers in the graph. This must be called before
// register allocation, to pick up the original LUses.
- MOZ_MUST_USE bool record();
+ [[nodiscard]] bool record();
// Perform the liveness analysis on the graph, and assert on an invalid
// allocation. This must be called after register allocation, to pick up
// all assigned physical values. If populateSafepoints is specified,
// safepoints will be filled in with liveness information.
- MOZ_MUST_USE bool check(bool populateSafepoints);
+ [[nodiscard]] bool check(bool populateSafepoints);
private:
@@ -121,11 +121,11 @@ struct AllocationIntegrityState
typedef HashSet<IntegrityItem, IntegrityItem, SystemAllocPolicy> IntegrityItemSet;
IntegrityItemSet seen;
- MOZ_MUST_USE bool checkIntegrity(LBlock* block, LInstruction* ins, uint32_t vreg,
+ [[nodiscard]] bool checkIntegrity(LBlock* block, LInstruction* ins, uint32_t vreg,
LAllocation alloc, bool populateSafepoints);
- MOZ_MUST_USE bool checkSafepointAllocation(LInstruction* ins, uint32_t vreg, LAllocation alloc,
+ [[nodiscard]] bool checkSafepointAllocation(LInstruction* ins, uint32_t vreg, LAllocation alloc,
bool populateSafepoints);
- MOZ_MUST_USE bool addPredecessor(LBlock* block, uint32_t vreg, LAllocation alloc);
+ [[nodiscard]] bool addPredecessor(LBlock* block, uint32_t vreg, LAllocation alloc);
void dump();
};
@@ -232,7 +232,7 @@ class InstructionDataMap
: insData_()
{ }
- MOZ_MUST_USE bool init(MIRGenerator* gen, uint32_t numInstructions) {
+ [[nodiscard]] bool init(MIRGenerator* gen, uint32_t numInstructions) {
if (!insData_.init(gen->alloc(), numInstructions))
return false;
memset(&insData_[0], 0, sizeof(LNode*) * numInstructions);
@@ -296,7 +296,7 @@ class RegisterAllocator
}
}
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
TempAllocator& alloc() const {
return mir->alloc();
diff --git a/js/src/jit/RematerializedFrame.h b/js/src/jit/RematerializedFrame.h
index fa3a9ef49f..694b3d02cd 100644
--- a/js/src/jit/RematerializedFrame.h
+++ b/js/src/jit/RematerializedFrame.h
@@ -72,10 +72,10 @@ class RematerializedFrame
// Rematerialize all remaining frames pointed to by |iter| into |frames|
// in older-to-younger order, e.g., frames[0] is the oldest frame.
- static MOZ_MUST_USE bool RematerializeInlineFrames(JSContext* cx, uint8_t* top,
- InlineFrameIterator& iter,
- MaybeReadFallback& fallback,
- GCVector<RematerializedFrame*>& frames);
+ [[nodiscard]] static bool RematerializeInlineFrames(JSContext* cx, uint8_t* top,
+ InlineFrameIterator& iter,
+ MaybeReadFallback& fallback,
+ GCVector<RematerializedFrame*>& frames);
// Free a vector of RematerializedFrames; takes care to call the
// destructor. Also clears the vector.
@@ -137,8 +137,8 @@ class RematerializedFrame
envChain_ = &envChain_->as<SpecificEnvironment>().enclosingEnvironment();
}
- MOZ_MUST_USE bool initFunctionEnvironmentObjects(JSContext* cx);
- MOZ_MUST_USE bool pushVarEnvironment(JSContext* cx, HandleScope scope);
+ [[nodiscard]] bool initFunctionEnvironmentObjects(JSContext* cx);
+ [[nodiscard]] bool pushVarEnvironment(JSContext* cx, HandleScope scope);
bool hasInitialEnvironment() const {
return hasInitialEnv_;
diff --git a/js/src/jit/Safepoints.h b/js/src/jit/Safepoints.h
index 1626d924c8..4c5858851c 100644
--- a/js/src/jit/Safepoints.h
+++ b/js/src/jit/Safepoints.h
@@ -28,7 +28,7 @@ class SafepointWriter
public:
explicit SafepointWriter(uint32_t slotCount, uint32_t argumentCount);
- MOZ_MUST_USE bool init(TempAllocator& alloc);
+ [[nodiscard]] bool init(TempAllocator& alloc);
private:
// A safepoint entry is written in the order these functions appear.
@@ -83,7 +83,7 @@ class SafepointReader
void advanceFromGcSlots();
void advanceFromValueSlots();
void advanceFromNunboxSlots();
- MOZ_MUST_USE bool getSlotFromBitmap(SafepointSlotEntry* entry);
+ [[nodiscard]] bool getSlotFromBitmap(SafepointSlotEntry* entry);
public:
SafepointReader(IonScript* script, const SafepointIndex* si);
@@ -111,17 +111,17 @@ class SafepointReader
uint32_t osiReturnPointOffset() const;
// Returns true if a slot was read, false if there are no more slots.
- MOZ_MUST_USE bool getGcSlot(SafepointSlotEntry* entry);
+ [[nodiscard]] bool getGcSlot(SafepointSlotEntry* entry);
// Returns true if a slot was read, false if there are no more value slots.
- MOZ_MUST_USE bool getValueSlot(SafepointSlotEntry* entry);
+ [[nodiscard]] bool getValueSlot(SafepointSlotEntry* entry);
// Returns true if a nunbox slot was read, false if there are no more
// nunbox slots.
- MOZ_MUST_USE bool getNunboxSlot(LAllocation* type, LAllocation* payload);
+ [[nodiscard]] bool getNunboxSlot(LAllocation* type, LAllocation* payload);
// Returns true if a slot was read, false if there are no more slots.
- MOZ_MUST_USE bool getSlotsOrElementsSlot(SafepointSlotEntry* entry);
+ [[nodiscard]] bool getSlotsOrElementsSlot(SafepointSlotEntry* entry);
};
} // namespace jit
diff --git a/js/src/jit/ScalarReplacement.h b/js/src/jit/ScalarReplacement.h
index 18e0f02624..cc885642eb 100644
--- a/js/src/jit/ScalarReplacement.h
+++ b/js/src/jit/ScalarReplacement.h
@@ -15,8 +15,7 @@ namespace jit {
class MIRGenerator;
class MIRGraph;
-MOZ_MUST_USE bool
-ScalarReplacement(MIRGenerator* mir, MIRGraph& graph);
+[[nodiscard]] bool ScalarReplacement(MIRGenerator* mir, MIRGraph& graph);
} // namespace jit
} // namespace js
diff --git a/js/src/jit/SharedIC.h b/js/src/jit/SharedIC.h
index d259ebf0bc..dcc615a608 100644
--- a/js/src/jit/SharedIC.h
+++ b/js/src/jit/SharedIC.h
@@ -939,10 +939,10 @@ class ICUpdatedStub : public ICStub
{}
public:
- MOZ_MUST_USE bool initUpdatingChain(JSContext* cx, ICStubSpace* space);
+ [[nodiscard]] bool initUpdatingChain(JSContext* cx, ICStubSpace* space);
- MOZ_MUST_USE bool addUpdateStubForValue(JSContext* cx, HandleScript script, HandleObject obj,
- HandleId id, HandleValue val);
+ [[nodiscard]] bool addUpdateStubForValue(JSContext* cx, HandleScript script, HandleObject obj,
+ HandleId id, HandleValue val);
void addOptimizedUpdateStub(ICStub* stub) {
if (firstUpdateStub_->isTypeUpdate_Fallback()) {
@@ -1015,7 +1015,7 @@ class ICStubCompiler
(static_cast<int32_t>(kind) << 1);
}
- virtual MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm) = 0;
+ [[nodiscard]] virtual bool generateStubCode(MacroAssembler& masm) = 0;
virtual void postGenerateStubCode(MacroAssembler& masm, Handle<JitCode*> genCode) {}
JitCode* getStubCode();
@@ -1032,14 +1032,14 @@ class ICStubCompiler
void pushStubPayload(MacroAssembler& masm, Register scratch);
// Emits a tail call to a VMFunction wrapper.
- MOZ_MUST_USE bool tailCallVM(const VMFunction& fun, MacroAssembler& masm);
+ [[nodiscard]] bool tailCallVM(const VMFunction& fun, MacroAssembler& masm);
// Emits a normal (non-tail) call to a VMFunction wrapper.
- MOZ_MUST_USE bool callVM(const VMFunction& fun, MacroAssembler& masm);
+ [[nodiscard]] bool callVM(const VMFunction& fun, MacroAssembler& masm);
// Emits a call to a type-update IC, assuming that the value to be
// checked is already in R0.
- MOZ_MUST_USE bool callTypeUpdateIC(MacroAssembler& masm, uint32_t objectOffset);
+ [[nodiscard]] bool callTypeUpdateIC(MacroAssembler& masm, uint32_t objectOffset);
// A stub frame is used when a stub wants to call into the VM without
// performing a tail call. This is required for the return address
@@ -1180,9 +1180,9 @@ class ICMonitoredFallbackStub : public ICFallbackStub
fallbackMonitorStub_(nullptr) {}
public:
- MOZ_MUST_USE bool initMonitoringChain(JSContext* cx, ICStubSpace* space,
+ [[nodiscard]] bool initMonitoringChain(JSContext* cx, ICStubSpace* space,
ICStubCompiler::Engine engine);
- MOZ_MUST_USE bool addMonitorStubForValue(JSContext* cx, SharedStubInfo* info, HandleValue val);
+ [[nodiscard]] bool addMonitorStubForValue(JSContext* cx, SharedStubInfo* info, HandleValue val);
inline ICTypeMonitor_Fallback* fallbackMonitorStub() const {
return fallbackMonitorStub_;
@@ -1442,7 +1442,7 @@ class ICTypeMonitor_Fallback : public ICStub
// Create a new monitor stub for the type of the given value, and
// add it to this chain.
- MOZ_MUST_USE bool addMonitorStubForValue(JSContext* cx, SharedStubInfo* info, HandleValue val);
+ [[nodiscard]] bool addMonitorStubForValue(JSContext* cx, SharedStubInfo* info, HandleValue val);
void resetMonitorStubChain(Zone* zone);
@@ -1452,7 +1452,7 @@ class ICTypeMonitor_Fallback : public ICStub
uint32_t argumentIndex_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, Engine engine, ICMonitoredFallbackStub* mainFallbackStub)
@@ -1485,7 +1485,7 @@ class ICTypeMonitor_PrimitiveSet : public TypeCheckPrimitiveSetStub
public:
class Compiler : public TypeCheckPrimitiveSetStub::Compiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, Engine engine, ICTypeMonitor_PrimitiveSet* existingStub,
@@ -1529,7 +1529,7 @@ class ICTypeMonitor_SingleObject : public ICStub
class Compiler : public ICStubCompiler {
protected:
HandleObject obj_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, HandleObject obj)
@@ -1563,7 +1563,7 @@ class ICTypeMonitor_ObjectGroup : public ICStub
class Compiler : public ICStubCompiler {
protected:
HandleObjectGroup group_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, HandleObjectGroup group)
@@ -1615,7 +1615,7 @@ class ICBinaryArith_Fallback : public ICFallbackStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx, Engine engine)
@@ -1648,7 +1648,7 @@ class ICBinaryArith_Int32 : public ICStub
JSOp op_;
bool allowDouble_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
// Stub keys shift-stubs need to encode the kind, the JSOp and if we allow doubles.
virtual int32_t getKey() const {
@@ -1680,7 +1680,7 @@ class ICBinaryArith_StringConcat : public ICStub
public:
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx, Engine engine)
@@ -1711,7 +1711,7 @@ class ICBinaryArith_StringObjectConcat : public ICStub
class Compiler : public ICStubCompiler {
protected:
bool lhsIsString_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -1743,7 +1743,7 @@ class ICBinaryArith_Double : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -1785,7 +1785,7 @@ class ICBinaryArith_BooleanWithInt32 : public ICStub
JSOp op_;
bool lhsIsBool_;
bool rhsIsBool_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -1830,7 +1830,7 @@ class ICBinaryArith_DoubleWithInt32 : public ICStub
class Compiler : public ICMultiStubCompiler {
protected:
bool lhsIsDouble_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -1881,7 +1881,7 @@ class ICUnaryArith_Fallback : public ICFallbackStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx, Engine engine)
@@ -1905,7 +1905,7 @@ class ICUnaryArith_Int32 : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -1929,7 +1929,7 @@ class ICUnaryArith_Double : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -1973,7 +1973,7 @@ class ICCompare_Fallback : public ICFallbackStub
// Compiler for this stub kind.
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx, Engine engine)
@@ -1996,7 +1996,7 @@ class ICCompare_Int32 : public ICStub
// Compiler for this stub kind.
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -2019,7 +2019,7 @@ class ICCompare_Double : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -2049,7 +2049,7 @@ class ICCompare_NumberWithUndefined : public ICStub
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
bool lhsIsUndefined;
@@ -2084,7 +2084,7 @@ class ICCompare_String : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -2108,7 +2108,7 @@ class ICCompare_Boolean : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -2132,7 +2132,7 @@ class ICCompare_Object : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, JSOp op, Engine engine)
@@ -2156,7 +2156,7 @@ class ICCompare_ObjectWithUndefined : public ICStub
public:
class Compiler : public ICMultiStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
bool lhsIsUndefined;
bool compareWithNull;
@@ -2202,7 +2202,7 @@ class ICCompare_Int32WithBoolean : public ICStub
protected:
JSOp op_;
bool lhsIsInt32_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -2249,7 +2249,7 @@ IsPreliminaryObject(JSObject* obj);
void
StripPreliminaryObjectStubs(JSContext* cx, ICFallbackStub* stub);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EffectlesslyLookupProperty(JSContext* cx, HandleObject obj, HandleId name,
MutableHandleObject holder, MutableHandle<PropertyResult> prop,
bool* checkDOMProxy=nullptr,
@@ -2268,17 +2268,17 @@ IsCacheableGetPropReadSlot(JSObject* obj, JSObject* holder, Shape* shape, bool i
void
GetFixedOrDynamicSlotOffset(Shape* shape, bool* isFixed, uint32_t* offset);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
IsCacheableGetPropCall(JSContext* cx, JSObject* obj, JSObject* holder, Shape* shape,
bool* isScripted, bool* isTemporarilyUnoptimizable, bool isDOMProxy=false);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
UpdateExistingGetPropCallStubs(ICFallbackStub* fallbackStub,
ICStub::Kind kind,
HandleNativeObject holder,
HandleObject receiver,
HandleFunction getter);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CheckHasNoSuchProperty(JSContext* cx, JSObject* obj, PropertyName* name,
JSObject** lastProto = nullptr, size_t* protoChainDepthOut = nullptr);
@@ -2287,7 +2287,7 @@ GuardReceiverObject(MacroAssembler& masm, ReceiverGuard guard,
Register object, Register scratch,
size_t receiverGuardOffset, Label* failure);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
GetProtoShapes(JSObject* obj, size_t protoChainDepth, MutableHandle<ShapeVector> shapes);
void
@@ -2302,7 +2302,7 @@ CheckDOMProxyExpandoDoesNotShadow(JSContext* cx, MacroAssembler& masm, Register
void
CheckForTypedObjectWithDetachedStorage(JSContext* cx, MacroAssembler& masm, Label* failure);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DoCallNativeGetter(JSContext* cx, HandleFunction callee, HandleObject obj,
MutableHandleValue result);
@@ -2344,7 +2344,7 @@ class ICGetProp_Fallback : public ICMonitoredFallbackStub
protected:
uint32_t returnOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
void postGenerateStubCode(MacroAssembler& masm, Handle<JitCode*> code);
public:
@@ -2376,7 +2376,7 @@ class ICGetProp_Generic : public ICMonitoredStub
class Compiler : public ICStubCompiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
ICStub* firstMonitorStub_;
public:
explicit Compiler(JSContext* cx, Engine engine, ICStub* firstMonitorStub)
@@ -2401,7 +2401,7 @@ class ICGetProp_StringLength : public ICStub
public:
class Compiler : public ICStubCompiler {
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx, Engine engine)
@@ -2515,7 +2515,7 @@ class ICGetPropNativeCompiler : public ICStubCompiler
uint32_t offset_;
bool inputDefinitelyObject_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
protected:
virtual int32_t getKey() const {
@@ -2695,7 +2695,7 @@ class ICGetProp_CallScripted : public ICGetPropCallGetter
class Compiler : public ICGetPropCallGetter::Compiler {
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, ICStub* firstMonitorStub, HandleObject obj,
@@ -2770,7 +2770,7 @@ class ICGetPropCallNativeCompiler : public ICGetPropCallGetter::Compiler
{
bool inputDefinitelyObject_;
protected:
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
int32_t baseKey = ICGetPropCallGetter::Compiler::getKey();
@@ -2883,9 +2883,9 @@ class ICGetPropCallDOMProxyNativeCompiler : public ICStubCompiler {
RootedFunction getter_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm, Address* internalStructAddr,
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm, Address* internalStructAddr,
Address* generationAddr);
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
ICGetPropCallDOMProxyNativeCompiler(JSContext* cx, ICStub::Kind kind,
@@ -2941,7 +2941,7 @@ class ICGetProp_DOMProxyShadowed : public ICMonitoredStub
RootedPropertyName name_;
uint32_t pcOffset_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, Engine engine, ICStub* firstMonitorStub, Handle<ProxyObject*> proxy,
@@ -2973,7 +2973,7 @@ class ICGetProp_ArgumentsLength : public ICStub
protected:
Which which_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
virtual int32_t getKey() const {
return static_cast<int32_t>(engine_) |
@@ -3004,7 +3004,7 @@ class ICGetProp_ArgumentsCallee : public ICMonitoredStub
class Compiler : public ICStubCompiler {
protected:
ICStub* firstMonitorStub_;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, Engine engine, ICStub* firstMonitorStub)
@@ -3039,7 +3039,7 @@ class ICNewArray_Fallback : public ICFallbackStub
public:
class Compiler : public ICStubCompiler {
RootedObjectGroup templateGroup;
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
Compiler(JSContext* cx, ObjectGroup* templateGroup, Engine engine)
@@ -3085,7 +3085,7 @@ class ICNewObject_Fallback : public ICFallbackStub
public:
class Compiler : public ICStubCompiler {
- MOZ_MUST_USE bool generateStubCode(MacroAssembler& masm);
+ [[nodiscard]] bool generateStubCode(MacroAssembler& masm);
public:
explicit Compiler(JSContext* cx, Engine engine)
diff --git a/js/src/jit/Sink.h b/js/src/jit/Sink.h
index 154300f43c..d2a9e8c646 100644
--- a/js/src/jit/Sink.h
+++ b/js/src/jit/Sink.h
@@ -15,8 +15,7 @@ namespace jit {
class MIRGenerator;
class MIRGraph;
-MOZ_MUST_USE bool
-Sink(MIRGenerator* mir, MIRGraph& graph);
+[[nodiscard]] bool Sink(MIRGenerator* mir, MIRGraph& graph);
} // namespace jit
} // namespace js
diff --git a/js/src/jit/Snapshots.h b/js/src/jit/Snapshots.h
index d9a4962946..290dbd68cd 100644
--- a/js/src/jit/Snapshots.h
+++ b/js/src/jit/Snapshots.h
@@ -384,14 +384,14 @@ class SnapshotWriter
SnapshotOffset lastStart_;
public:
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
SnapshotOffset startSnapshot(RecoverOffset recoverOffset, BailoutKind kind);
#ifdef TRACK_SNAPSHOTS
void trackSnapshot(uint32_t pcOpcode, uint32_t mirOpcode, uint32_t mirId,
uint32_t lirOpcode, uint32_t lirId);
#endif
- MOZ_MUST_USE bool add(const RValueAllocation& slot);
+ [[nodiscard]] bool add(const RValueAllocation& slot);
uint32_t allocWritten() const {
return allocWritten_;
diff --git a/js/src/jit/StupidAllocator.h b/js/src/jit/StupidAllocator.h
index aae2cb96bd..96c17e03f3 100644
--- a/js/src/jit/StupidAllocator.h
+++ b/js/src/jit/StupidAllocator.h
@@ -56,10 +56,10 @@ class StupidAllocator : public RegisterAllocator
{
}
- MOZ_MUST_USE bool go();
+ [[nodiscard]] bool go();
private:
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
void syncForBlockEnd(LBlock* block, LInstruction* ins);
void allocateForInstruction(LInstruction* ins);
diff --git a/js/src/jit/TypePolicy.h b/js/src/jit/TypePolicy.h
index 0b9d2b37ef..8ab241ab00 100644
--- a/js/src/jit/TypePolicy.h
+++ b/js/src/jit/TypePolicy.h
@@ -29,7 +29,7 @@ class TypePolicy
// * If untyped, optionally ask the input to try and specialize its value.
// * Replace the operand with a conversion instruction.
// * Insert an unconditional deoptimization (no conversion possible).
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) = 0;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) = 0;
};
struct TypeSpecializationData
@@ -79,8 +79,8 @@ class BoxInputsPolicy final : public TypePolicy
{
public:
SPECIALIZATION_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -89,28 +89,28 @@ class ArithPolicy final : public TypePolicy
{
public:
SPECIALIZATION_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
class AllDoublePolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] bool adjustInputs(TempAllocator& alloc, MInstruction* def);
};
class BitwisePolicy final : public TypePolicy
{
public:
SPECIALIZATION_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
class ComparePolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
// Policy for MTest instructions.
@@ -118,21 +118,21 @@ class TestPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
class TypeBarrierPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
class CallPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
// Policy for MPow. First operand Double; second Double or Int32.
@@ -140,7 +140,7 @@ class PowPolicy final : public TypePolicy
{
public:
SPECIALIZATION_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
// Expect a string for operand Op. If the input is a Value, it is unboxed.
@@ -149,8 +149,8 @@ class StringPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -161,8 +161,8 @@ class ConvertToStringPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -173,8 +173,8 @@ class BooleanPolicy final : private TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -185,8 +185,8 @@ class IntPolicy final : private TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -197,8 +197,8 @@ class ConvertToInt32Policy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -209,8 +209,8 @@ class TruncateToInt32Policy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -221,8 +221,8 @@ class DoublePolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -233,8 +233,8 @@ class Float32Policy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -246,7 +246,7 @@ class FloatingPointPolicy final : public TypePolicy
{
public:
SPECIALIZATION_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
template <unsigned Op>
@@ -254,8 +254,8 @@ class NoFloatPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -267,7 +267,7 @@ class NoFloatPolicyAfter final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
// Box objects or strings as an input to a ToDouble instruction.
@@ -275,8 +275,8 @@ class ToDoublePolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -286,8 +286,8 @@ class ToInt32Policy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -297,8 +297,8 @@ class ToStringPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* def);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override {
return staticAdjustInputs(alloc, def);
}
};
@@ -308,8 +308,8 @@ class ObjectPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
return staticAdjustInputs(alloc, ins);
}
};
@@ -323,8 +323,8 @@ class BoxPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
return staticAdjustInputs(alloc, ins);
}
};
@@ -335,8 +335,8 @@ class BoxExceptPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
- MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
+ [[nodiscard]] bool adjustInputs(TempAllocator& alloc, MInstruction* ins) {
return staticAdjustInputs(alloc, ins);
}
};
@@ -347,8 +347,8 @@ class CacheIdPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
- MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins);
+ [[nodiscard]] bool adjustInputs(TempAllocator& alloc, MInstruction* ins) {
return staticAdjustInputs(alloc, ins);
}
};
@@ -359,10 +359,10 @@ class MixPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins) {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins) {
return Lhs::staticAdjustInputs(alloc, ins) && Rhs::staticAdjustInputs(alloc, ins);
}
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
return staticAdjustInputs(alloc, ins);
}
};
@@ -373,12 +373,12 @@ class Mix3Policy final : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins) {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins) {
return Policy1::staticAdjustInputs(alloc, ins) &&
Policy2::staticAdjustInputs(alloc, ins) &&
Policy3::staticAdjustInputs(alloc, ins);
}
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
return staticAdjustInputs(alloc, ins);
}
};
@@ -389,13 +389,13 @@ class Mix4Policy : public TypePolicy
{
public:
EMPTY_DATA_;
- static MOZ_MUST_USE bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins) {
+ [[nodiscard]] static bool staticAdjustInputs(TempAllocator& alloc, MInstruction* ins) {
return Policy1::staticAdjustInputs(alloc, ins) &&
Policy2::staticAdjustInputs(alloc, ins) &&
Policy3::staticAdjustInputs(alloc, ins) &&
Policy4::staticAdjustInputs(alloc, ins);
}
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override {
return staticAdjustInputs(alloc, ins);
}
};
@@ -404,7 +404,7 @@ class CallSetElementPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
// First operand will be boxed to a Value (except for an object)
@@ -413,7 +413,7 @@ class InstanceOfPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
class StoreTypedArrayHolePolicy;
@@ -422,37 +422,37 @@ class StoreTypedArrayElementStaticPolicy;
class StoreUnboxedScalarPolicy : public TypePolicy
{
private:
- static MOZ_MUST_USE bool adjustValueInput(TempAllocator& alloc, MInstruction* ins,
- Scalar::Type arrayType, MDefinition* value,
- int valueOperand);
+ [[nodiscard]] static bool adjustValueInput(TempAllocator& alloc, MInstruction* ins,
+ Scalar::Type arrayType, MDefinition* value,
+ int valueOperand);
friend class StoreTypedArrayHolePolicy;
friend class StoreTypedArrayElementStaticPolicy;
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
class StoreTypedArrayHolePolicy final : public StoreUnboxedScalarPolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
class StoreTypedArrayElementStaticPolicy final : public StoreUnboxedScalarPolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
class StoreUnboxedObjectOrNullPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* def) override;
};
// Accepts integers and doubles. Everything else is boxed.
@@ -460,14 +460,14 @@ class ClampPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
class FilterTypeSetPolicy final : public TypePolicy
{
public:
EMPTY_DATA_;
- virtual MOZ_MUST_USE bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
+ [[nodiscard]] virtual bool adjustInputs(TempAllocator& alloc, MInstruction* ins) override;
};
#undef SPECIALIZATION_DATA_
diff --git a/js/src/jit/VMFunctions.h b/js/src/jit/VMFunctions.h
index b134c5df05..8a2e9b92d2 100644
--- a/js/src/jit/VMFunctions.h
+++ b/js/src/jit/VMFunctions.h
@@ -582,10 +582,10 @@ class AutoDetectInvalidation
}
};
-MOZ_MUST_USE bool
+[[nodiscard]] bool
InvokeFunction(JSContext* cx, HandleObject obj0, bool constructing, bool ignoresReturnValue,
uint32_t argc, Value* argv, MutableHandleValue rval);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
InvokeFunctionShuffleNewTarget(JSContext* cx, HandleObject obj, uint32_t numActualArgs,
uint32_t numFormalArgs, Value* argv, MutableHandleValue rval);
@@ -594,15 +594,15 @@ bool CheckOverRecursedWithExtra(JSContext* cx, BaselineFrame* frame,
uint32_t extra, uint32_t earlyCheck);
JSObject* BindVar(JSContext* cx, HandleObject scopeChain);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DefVar(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DefLexical(JSContext* cx, HandlePropertyName dn, unsigned attrs, HandleObject scopeChain);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DefGlobalLexical(JSContext* cx, HandlePropertyName dn, unsigned attrs);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
MutatePrototype(JSContext* cx, HandlePlainObject obj, HandleValue value);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
InitProp(JSContext* cx, HandleObject obj, HandlePropertyName name, HandleValue value,
jsbytecode* pc);
@@ -620,21 +620,21 @@ bool GreaterThanOrEqual(JSContext* cx, MutableHandleValue lhs, MutableHandleValu
template<bool Equal>
bool StringsEqual(JSContext* cx, HandleString left, HandleString right, bool* res);
-MOZ_MUST_USE bool ArrayPopDense(JSContext* cx, HandleObject obj, MutableHandleValue rval);
-MOZ_MUST_USE bool ArrayPushDense(JSContext* cx, HandleObject obj, HandleValue v, uint32_t* length);
-MOZ_MUST_USE bool ArrayShiftDense(JSContext* cx, HandleObject obj, MutableHandleValue rval);
+[[nodiscard]] bool ArrayPopDense(JSContext* cx, HandleObject obj, MutableHandleValue rval);
+[[nodiscard]] bool ArrayPushDense(JSContext* cx, HandleObject obj, HandleValue v, uint32_t* length);
+[[nodiscard]] bool ArrayShiftDense(JSContext* cx, HandleObject obj, MutableHandleValue rval);
JSString* ArrayJoin(JSContext* cx, HandleObject array, HandleString sep);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CharCodeAt(JSContext* cx, HandleString str, int32_t index, uint32_t* code);
JSFlatString* StringFromCharCode(JSContext* cx, int32_t code);
JSString* StringFromCodePoint(JSContext* cx, int32_t codePoint);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
SetProperty(JSContext* cx, HandleObject obj, HandlePropertyName name, HandleValue value,
bool strict, jsbytecode* pc);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
InterruptCheck(JSContext* cx);
void* MallocWrapper(JSRuntime* rt, size_t nbytes);
@@ -645,10 +645,10 @@ JSObject* NewStringObject(JSContext* cx, HandleString str);
bool OperatorIn(JSContext* cx, HandleValue key, HandleObject obj, bool* out);
bool OperatorInI(JSContext* cx, uint32_t index, HandleObject obj, bool* out);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
GetIntrinsicValue(JSContext* cx, HandlePropertyName name, MutableHandleValue rval);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CreateThis(JSContext* cx, HandleObject callee, HandleObject newTarget, MutableHandleValue rval);
void GetDynamicName(JSContext* cx, JSObject* scopeChain, JSString* str, Value* vp);
@@ -659,92 +659,92 @@ void PostGlobalWriteBarrier(JSRuntime* rt, JSObject* obj);
uint32_t GetIndexFromString(JSString* str);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugPrologue(JSContext* cx, BaselineFrame* frame, jsbytecode* pc, bool* mustReturn);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugEpilogue(JSContext* cx, BaselineFrame* frame, jsbytecode* pc, bool ok);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugEpilogueOnBaselineReturn(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
void FrameIsDebuggeeCheck(BaselineFrame* frame);
JSObject* CreateGenerator(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
NormalSuspend(JSContext* cx, HandleObject obj, BaselineFrame* frame, jsbytecode* pc,
uint32_t stackDepth);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
FinalSuspend(JSContext* cx, HandleObject obj, BaselineFrame* frame, jsbytecode* pc);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
InterpretResume(JSContext* cx, HandleObject obj, HandleValue val, HandlePropertyName kind,
MutableHandleValue rval);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugAfterYield(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
GeneratorThrowOrClose(JSContext* cx, BaselineFrame* frame, Handle<GeneratorObject*> genObj,
HandleValue arg, uint32_t resumeKind);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
GlobalNameConflictsCheckFromIon(JSContext* cx, HandleScript script);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CheckGlobalOrEvalDeclarationConflicts(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
InitFunctionEnvironmentObjects(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
NewArgumentsObject(JSContext* cx, BaselineFrame* frame, MutableHandleValue res);
JSObject* InitRestParameter(JSContext* cx, uint32_t length, Value* rest, HandleObject templateObj,
HandleObject res);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
HandleDebugTrap(JSContext* cx, BaselineFrame* frame, uint8_t* retAddr, bool* mustReturn);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
OnDebuggerStatement(JSContext* cx, BaselineFrame* frame, jsbytecode* pc, bool* mustReturn);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
GlobalHasLiveOnDebuggerStatement(JSContext* cx);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EnterWith(JSContext* cx, BaselineFrame* frame, HandleValue val, Handle<WithScope*> templ);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
LeaveWith(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
PushLexicalEnv(JSContext* cx, BaselineFrame* frame, Handle<LexicalScope*> scope);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
PopLexicalEnv(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugLeaveThenPopLexicalEnv(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
FreshenLexicalEnv(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugLeaveThenFreshenLexicalEnv(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RecreateLexicalEnv(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugLeaveThenRecreateLexicalEnv(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DebugLeaveLexicalEnv(JSContext* cx, BaselineFrame* frame, jsbytecode* pc);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
PushVarEnv(JSContext* cx, BaselineFrame* frame, HandleScope scope);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
PopVarEnv(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
InitBaselineFrameForOsr(BaselineFrame* frame, InterpreterFrame* interpFrame,
uint32_t numStackValues);
JSObject* CreateDerivedTypedObj(JSContext* cx, HandleObject descr,
HandleObject owner, int32_t offset);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
Recompile(JSContext* cx);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ForcedRecompile(JSContext* cx);
JSString* StringReplace(JSContext* cx, HandleString string, HandleString pattern,
HandleString repl);
-MOZ_MUST_USE bool SetDenseOrUnboxedArrayElement(JSContext* cx, HandleObject obj, int32_t index,
+[[nodiscard]] bool SetDenseOrUnboxedArrayElement(JSContext* cx, HandleObject obj, int32_t index,
HandleValue value, bool strict);
void AssertValidObjectPtr(JSContext* cx, JSObject* obj);
@@ -782,25 +782,25 @@ IonMarkFunction(MIRType type)
bool ObjectIsCallable(JSObject* obj);
bool ObjectIsConstructor(JSObject* obj);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ThrowRuntimeLexicalError(JSContext* cx, unsigned errorNumber);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ThrowReadOnlyError(JSContext* cx, int32_t index);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BaselineThrowUninitializedThis(JSContext* cx, BaselineFrame* frame);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ThrowBadDerivedReturn(JSContext* cx, HandleValue v);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ThrowObjectCoercible(JSContext* cx, HandleValue v);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BaselineGetFunctionThis(JSContext* cx, BaselineFrame* frame, MutableHandleValue res);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CheckIsCallable(JSContext* cx, HandleValue v, CheckIsCallableKind kind);
extern const VMFunction ToNumberInfo;
diff --git a/js/src/jit/ValueNumbering.h b/js/src/jit/ValueNumbering.h
index df3540fa4b..dd2cb733c8 100644
--- a/js/src/jit/ValueNumbering.h
+++ b/js/src/jit/ValueNumbering.h
@@ -40,14 +40,14 @@ class ValueNumberer
public:
explicit VisibleValues(TempAllocator& alloc);
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
typedef ValueSet::Ptr Ptr;
typedef ValueSet::AddPtr AddPtr;
Ptr findLeader(const MDefinition* def) const;
AddPtr findLeaderForAdd(MDefinition* def);
- MOZ_MUST_USE bool add(AddPtr p, MDefinition* def);
+ [[nodiscard]] bool add(AddPtr p, MDefinition* def);
void overwrite(AddPtr p, MDefinition* def);
void forget(const MDefinition* def);
void clear();
@@ -77,37 +77,37 @@ class ValueNumberer
SetUseRemoved
};
- MOZ_MUST_USE bool handleUseReleased(MDefinition* def, UseRemovedOption useRemovedOption);
- MOZ_MUST_USE bool discardDefsRecursively(MDefinition* def);
- MOZ_MUST_USE bool releaseResumePointOperands(MResumePoint* resume);
- MOZ_MUST_USE bool releaseAndRemovePhiOperands(MPhi* phi);
- MOZ_MUST_USE bool releaseOperands(MDefinition* def);
- MOZ_MUST_USE bool discardDef(MDefinition* def);
- MOZ_MUST_USE bool processDeadDefs();
+ [[nodiscard]] bool handleUseReleased(MDefinition* def, UseRemovedOption useRemovedOption);
+ [[nodiscard]] bool discardDefsRecursively(MDefinition* def);
+ [[nodiscard]] bool releaseResumePointOperands(MResumePoint* resume);
+ [[nodiscard]] bool releaseAndRemovePhiOperands(MPhi* phi);
+ [[nodiscard]] bool releaseOperands(MDefinition* def);
+ [[nodiscard]] bool discardDef(MDefinition* def);
+ [[nodiscard]] bool processDeadDefs();
- MOZ_MUST_USE bool fixupOSROnlyLoop(MBasicBlock* block, MBasicBlock* backedge);
- MOZ_MUST_USE bool removePredecessorAndDoDCE(MBasicBlock* block, MBasicBlock* pred,
+ [[nodiscard]] bool fixupOSROnlyLoop(MBasicBlock* block, MBasicBlock* backedge);
+ [[nodiscard]] bool removePredecessorAndDoDCE(MBasicBlock* block, MBasicBlock* pred,
size_t predIndex);
- MOZ_MUST_USE bool removePredecessorAndCleanUp(MBasicBlock* block, MBasicBlock* pred);
+ [[nodiscard]] bool removePredecessorAndCleanUp(MBasicBlock* block, MBasicBlock* pred);
MDefinition* simplified(MDefinition* def) const;
MDefinition* leader(MDefinition* def);
bool hasLeader(const MPhi* phi, const MBasicBlock* phiBlock) const;
bool loopHasOptimizablePhi(MBasicBlock* header) const;
- MOZ_MUST_USE bool visitDefinition(MDefinition* def);
- MOZ_MUST_USE bool visitControlInstruction(MBasicBlock* block, const MBasicBlock* root);
- MOZ_MUST_USE bool visitUnreachableBlock(MBasicBlock* block);
- MOZ_MUST_USE bool visitBlock(MBasicBlock* block, const MBasicBlock* root);
- MOZ_MUST_USE bool visitDominatorTree(MBasicBlock* root);
- MOZ_MUST_USE bool visitGraph();
+ [[nodiscard]] bool visitDefinition(MDefinition* def);
+ [[nodiscard]] bool visitControlInstruction(MBasicBlock* block, const MBasicBlock* root);
+ [[nodiscard]] bool visitUnreachableBlock(MBasicBlock* block);
+ [[nodiscard]] bool visitBlock(MBasicBlock* block, const MBasicBlock* root);
+ [[nodiscard]] bool visitDominatorTree(MBasicBlock* root);
+ [[nodiscard]] bool visitGraph();
- MOZ_MUST_USE bool insertOSRFixups();
- MOZ_MUST_USE bool cleanupOSRFixups();
+ [[nodiscard]] bool insertOSRFixups();
+ [[nodiscard]] bool cleanupOSRFixups();
public:
ValueNumberer(MIRGenerator* mir, MIRGraph& graph);
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
enum UpdateAliasAnalysisFlag {
DontUpdateAliasAnalysis,
@@ -117,7 +117,7 @@ class ValueNumberer
// Optimize the graph, performing expression simplification and
// canonicalization, eliminating statically fully-redundant expressions,
// deleting dead instructions, and removing unreachable blocks.
- MOZ_MUST_USE bool run(UpdateAliasAnalysisFlag updateAliasAnalysis);
+ [[nodiscard]] bool run(UpdateAliasAnalysisFlag updateAliasAnalysis);
};
} // namespace jit
diff --git a/js/src/jit/shared/CodeGenerator-shared.cpp b/js/src/jit/shared/CodeGenerator-shared.cpp
index cdacf9ead5..ccda378a3a 100644
--- a/js/src/jit/shared/CodeGenerator-shared.cpp
+++ b/js/src/jit/shared/CodeGenerator-shared.cpp
@@ -1640,7 +1640,7 @@ CodeGeneratorShared::jumpToBlock(MBasicBlock* mir, Assembler::Condition cond)
}
#endif
-MOZ_MUST_USE bool
+[[nodiscard]] bool
CodeGeneratorShared::addCacheLocations(const CacheLocationList& locs, size_t* numLocs,
size_t* curIndex)
{
diff --git a/js/src/jit/shared/CodeGenerator-shared.h b/js/src/jit/shared/CodeGenerator-shared.h
index 0cc10b567d..7f14e8cd58 100644
--- a/js/src/jit/shared/CodeGenerator-shared.h
+++ b/js/src/jit/shared/CodeGenerator-shared.h
@@ -270,8 +270,7 @@ class CodeGeneratorShared : public LElementVisitor
};
protected:
- MOZ_MUST_USE
- bool allocateData(size_t size, size_t* offset) {
+ [[nodiscard]] bool allocateData(size_t size, size_t* offset) {
MOZ_ASSERT(size % sizeof(void*) == 0);
*offset = runtimeData_.length();
masm.propagateOOM(runtimeData_.appendN(0, size));
diff --git a/js/src/jit/x64/BaseAssembler-x64.h b/js/src/jit/x64/BaseAssembler-x64.h
index f66cecf35d..2b42bc12d2 100644
--- a/js/src/jit/x64/BaseAssembler-x64.h
+++ b/js/src/jit/x64/BaseAssembler-x64.h
@@ -700,7 +700,7 @@ class BaseAssemblerX64 : public BaseAssembler
m_formatter.oneByteOp64(OP_MOVSXD_GvEv, offset, base, index, scale, dst);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
movl_ripr(RegisterID dst)
{
m_formatter.oneByteRipOp(OP_MOV_GvEv, 0, (RegisterID)dst);
@@ -709,7 +709,7 @@ class BaseAssemblerX64 : public BaseAssembler
return label;
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
movl_rrip(RegisterID src)
{
m_formatter.oneByteRipOp(OP_MOV_EvGv, 0, (RegisterID)src);
@@ -718,7 +718,7 @@ class BaseAssemblerX64 : public BaseAssembler
return label;
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
movq_ripr(RegisterID dst)
{
m_formatter.oneByteRipOp64(OP_MOV_GvEv, 0, dst);
@@ -727,7 +727,7 @@ class BaseAssemblerX64 : public BaseAssembler
return label;
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
movq_rrip(RegisterID src)
{
m_formatter.oneByteRipOp64(OP_MOV_EvGv, 0, (RegisterID)src);
@@ -742,7 +742,7 @@ class BaseAssemblerX64 : public BaseAssembler
m_formatter.oneByteOp64(OP_LEA, offset, base, dst);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
leaq_rip(RegisterID dst)
{
m_formatter.oneByteRipOp64(OP_LEA, 0, dst);
@@ -806,44 +806,44 @@ class BaseAssemblerX64 : public BaseAssembler
twoByteOpInt64Simd("vmovq", VEX_PD, OP2_MOVD_VdEd, src, invalid_xmm, dst);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovsd_ripr(XMMRegisterID dst)
{
return twoByteRipOpSimd("vmovsd", VEX_SD, OP2_MOVSD_VsdWsd, invalid_xmm, dst);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovss_ripr(XMMRegisterID dst)
{
return twoByteRipOpSimd("vmovss", VEX_SS, OP2_MOVSD_VsdWsd, invalid_xmm, dst);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovsd_rrip(XMMRegisterID src)
{
return twoByteRipOpSimd("vmovsd", VEX_SD, OP2_MOVSD_WsdVsd, invalid_xmm, src);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovss_rrip(XMMRegisterID src)
{
return twoByteRipOpSimd("vmovss", VEX_SS, OP2_MOVSD_WsdVsd, invalid_xmm, src);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovdqa_rrip(XMMRegisterID src)
{
return twoByteRipOpSimd("vmovdqa", VEX_PD, OP2_MOVDQ_WdqVdq, invalid_xmm, src);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovaps_rrip(XMMRegisterID src)
{
return twoByteRipOpSimd("vmovdqa", VEX_PS, OP2_MOVAPS_WsdVsd, invalid_xmm, src);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovaps_ripr(XMMRegisterID dst)
{
return twoByteRipOpSimd("vmovaps", VEX_PS, OP2_MOVAPS_VsdWsd, invalid_xmm, dst);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
vmovdqa_ripr(XMMRegisterID dst)
{
return twoByteRipOpSimd("vmovdqa", VEX_PD, OP2_MOVDQ_VdqWdq, invalid_xmm, dst);
@@ -851,7 +851,7 @@ class BaseAssemblerX64 : public BaseAssembler
private:
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
twoByteRipOpSimd(const char* name, VexOperandType ty, TwoByteOpcodeID opcode,
XMMRegisterID src0, XMMRegisterID dst)
{
diff --git a/js/src/jit/x86-shared/AssemblerBuffer-x86-shared.h b/js/src/jit/x86-shared/AssemblerBuffer-x86-shared.h
index 8a5caa58dd..66815c2131 100644
--- a/js/src/jit/x86-shared/AssemblerBuffer-x86-shared.h
+++ b/js/src/jit/x86-shared/AssemblerBuffer-x86-shared.h
@@ -2,6 +2,7 @@
*
* ***** BEGIN LICENSE BLOCK *****
* Copyright (C) 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2023 Moonchild Productions.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -112,7 +113,7 @@ namespace jit {
MOZ_ALWAYS_INLINE void putInt(int value) { sizedAppend<4>(value); }
MOZ_ALWAYS_INLINE void putInt64(int64_t value) { sizedAppend<8>(value); }
- MOZ_MUST_USE bool append(const unsigned char* values, size_t size)
+ [[nodiscard]] bool append(const unsigned char* values, size_t size)
{
if (MOZ_UNLIKELY(!m_buffer.append(values, size))) {
oomDetected();
diff --git a/js/src/jit/x86-shared/BaseAssembler-x86-shared.h b/js/src/jit/x86-shared/BaseAssembler-x86-shared.h
index 31a8d1f65c..ad479cd4e0 100644
--- a/js/src/jit/x86-shared/BaseAssembler-x86-shared.h
+++ b/js/src/jit/x86-shared/BaseAssembler-x86-shared.h
@@ -80,7 +80,7 @@ public:
spew("; %s", msg);
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
twoByteNop()
{
spew("nop (2 byte)");
@@ -1782,7 +1782,7 @@ public:
}
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
cmpl_im_disp32(int32_t rhs, int32_t offset, RegisterID base)
{
spew("cmpl $0x%x, " MEM_o32b, rhs, ADDR_o32b(offset, base));
@@ -1799,7 +1799,7 @@ public:
return r;
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
cmpl_im_disp32(int32_t rhs, const void* addr)
{
spew("cmpl $0x%x, %p", rhs, addr);
@@ -2514,7 +2514,7 @@ public:
// Flow control:
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
call()
{
m_formatter.oneByteOp(OP_CALL_rel32);
@@ -2538,7 +2538,7 @@ public:
// Comparison of EAX against a 32-bit immediate. The immediate is patched
// in as if it were a jump target. The intention is to toggle the first
// byte of the instruction between a CMP and a JMP to produce a pseudo-NOP.
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
cmp_eax()
{
m_formatter.oneByteOp(OP_CMP_EAXIv);
@@ -2563,7 +2563,7 @@ public:
m_formatter.immediate32(diff - 5);
}
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
jmp()
{
m_formatter.oneByteOp(OP_JMP_rel32);
@@ -2606,7 +2606,7 @@ public:
}
}
- MOZ_MUST_USE JmpSrc
+ [[nodiscard]] JmpSrc
jCC(Condition cond)
{
m_formatter.twoByteOp(jccRel32(cond));
@@ -3829,7 +3829,7 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_3A, imm, off
{
memcpy(buffer, m_formatter.buffer(), size());
}
- MOZ_MUST_USE bool appendBuffer(const BaseAssembler& other)
+ [[nodiscard]] bool appendBuffer(const BaseAssembler& other)
{
return m_formatter.append(other.m_formatter.buffer(), other.size());
}
@@ -5048,7 +5048,7 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_3A, imm, off
m_buffer.putInt64Unchecked(imm);
}
- MOZ_ALWAYS_INLINE MOZ_MUST_USE JmpSrc
+ [[nodiscard]] MOZ_ALWAYS_INLINE JmpSrc
immediateRel32()
{
m_buffer.putIntUnchecked(0);
@@ -5107,7 +5107,7 @@ threeByteOpImmSimd("vblendps", VEX_PD, OP3_BLENDPS_VpsWpsIb, ESCAPE_3A, imm, off
bool isAligned(int alignment) const { return m_buffer.isAligned(alignment); }
unsigned char* data() { return m_buffer.data(); }
- MOZ_MUST_USE bool append(const unsigned char* values, size_t size)
+ [[nodiscard]] bool append(const unsigned char* values, size_t size)
{
return m_buffer.append(values, size);
}
diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp
index 9067ca3d3d..fd815d8927 100644
--- a/js/src/jsapi.cpp
+++ b/js/src/jsapi.cpp
@@ -4320,7 +4320,7 @@ CompileFunction(JSContext* cx, const ReadOnlyCompileOptions& optionsArg,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
BuildFunctionString(const char* name, size_t nameLen,
unsigned nargs, const char* const* argnames,
const SourceBufferHolder& srcBuf, StringBuffer* out,
diff --git a/js/src/jsapi.h b/js/src/jsapi.h
index 19a0b805d2..df9294b418 100644
--- a/js/src/jsapi.h
+++ b/js/src/jsapi.h
@@ -129,14 +129,14 @@ class MOZ_RAII AutoVectorRooterBase : protected AutoGCRooter
size_t length() const { return vector.length(); }
bool empty() const { return vector.empty(); }
- MOZ_MUST_USE bool append(const T& v) { return vector.append(v); }
- MOZ_MUST_USE bool appendN(const T& v, size_t len) { return vector.appendN(v, len); }
- MOZ_MUST_USE bool append(const T* ptr, size_t len) { return vector.append(ptr, len); }
- MOZ_MUST_USE bool appendAll(const AutoVectorRooterBase<T>& other) {
+ [[nodiscard]] bool append(const T& v) { return vector.append(v); }
+ [[nodiscard]] bool appendN(const T& v, size_t len) { return vector.appendN(v, len); }
+ [[nodiscard]] bool append(const T* ptr, size_t len) { return vector.append(ptr, len); }
+ [[nodiscard]] bool appendAll(const AutoVectorRooterBase<T>& other) {
return vector.appendAll(other.vector);
}
- MOZ_MUST_USE bool insert(T* p, const T& val) { return vector.insert(p, val); }
+ [[nodiscard]] bool insert(T* p, const T& val) { return vector.insert(p, val); }
/* For use when space has already been reserved. */
void infallibleAppend(const T& v) { vector.infallibleAppend(v); }
@@ -144,7 +144,7 @@ class MOZ_RAII AutoVectorRooterBase : protected AutoGCRooter
void popBack() { vector.popBack(); }
T popCopy() { return vector.popCopy(); }
- MOZ_MUST_USE bool growBy(size_t inc) {
+ [[nodiscard]] bool growBy(size_t inc) {
size_t oldLength = vector.length();
if (!vector.growByUninitialized(inc))
return false;
@@ -152,7 +152,7 @@ class MOZ_RAII AutoVectorRooterBase : protected AutoGCRooter
return true;
}
- MOZ_MUST_USE bool resize(size_t newLength) {
+ [[nodiscard]] bool resize(size_t newLength) {
size_t oldLength = vector.length();
if (newLength <= oldLength) {
vector.shrinkBy(oldLength - newLength);
@@ -166,7 +166,7 @@ class MOZ_RAII AutoVectorRooterBase : protected AutoGCRooter
void clear() { vector.clear(); }
- MOZ_MUST_USE bool reserve(size_t newLength) {
+ [[nodiscard]] bool reserve(size_t newLength) {
return vector.reserve(newLength);
}
@@ -5950,7 +5950,7 @@ class JS_PUBLIC_API(AutoSaveExceptionState)
* This is not the same stack as `e.stack` when `e` is an `Error` object. (That
* would be JS::ExceptionStackOrNull).
*/
-MOZ_MUST_USE JS_PUBLIC_API(JSObject*)
+[[nodiscard]] JS_PUBLIC_API(JSObject*)
GetPendingExceptionStack(JSContext* cx);
} /* namespace JS */
diff --git a/js/src/jscntxt.h b/js/src/jscntxt.h
index c4ef783d3a..654374a524 100644
--- a/js/src/jscntxt.h
+++ b/js/src/jscntxt.h
@@ -520,7 +520,7 @@ struct JSContext : public js::ExclusiveContext,
return throwing;
}
- MOZ_MUST_USE
+ [[nodiscard]]
bool getPendingException(JS::MutableHandleValue rval);
js::SavedFrame* getPendingExceptionStack();
diff --git a/js/src/jscompartment.h b/js/src/jscompartment.h
index a02b39301d..7815d840e3 100644
--- a/js/src/jscompartment.h
+++ b/js/src/jscompartment.h
@@ -578,18 +578,18 @@ struct JSCompartment
JSCompartment(JS::Zone* zone, const JS::CompartmentOptions& options);
~JSCompartment();
- MOZ_MUST_USE bool init(JSContext* maybecx);
+ [[nodiscard]] bool init(JSContext* maybecx);
- MOZ_MUST_USE inline bool wrap(JSContext* cx, JS::MutableHandleValue vp);
+ [[nodiscard]] inline bool wrap(JSContext* cx, JS::MutableHandleValue vp);
- MOZ_MUST_USE bool wrap(JSContext* cx, js::MutableHandleString strp);
- MOZ_MUST_USE bool wrap(JSContext* cx, js::MutableHandle<JS::BigInt*> bi);
- MOZ_MUST_USE bool wrap(JSContext* cx, JS::MutableHandleObject obj);
- MOZ_MUST_USE bool wrap(JSContext* cx, JS::MutableHandle<js::PropertyDescriptor> desc);
- MOZ_MUST_USE bool wrap(JSContext* cx, JS::MutableHandle<JS::GCVector<JS::Value>> vec);
- MOZ_MUST_USE bool rewrap(JSContext* cx, JS::MutableHandleObject obj, JS::HandleObject existing);
+ [[nodiscard]] bool wrap(JSContext* cx, js::MutableHandleString strp);
+ [[nodiscard]] bool wrap(JSContext* cx, js::MutableHandle<JS::BigInt*> bi);
+ [[nodiscard]] bool wrap(JSContext* cx, JS::MutableHandleObject obj);
+ [[nodiscard]] bool wrap(JSContext* cx, JS::MutableHandle<js::PropertyDescriptor> desc);
+ [[nodiscard]] bool wrap(JSContext* cx, JS::MutableHandle<JS::GCVector<JS::Value>> vec);
+ [[nodiscard]] bool rewrap(JSContext* cx, JS::MutableHandleObject obj, JS::HandleObject existing);
- MOZ_MUST_USE bool putWrapper(JSContext* cx, const js::CrossCompartmentKey& wrapped,
+ [[nodiscard]] bool putWrapper(JSContext* cx, const js::CrossCompartmentKey& wrapped,
const js::Value& wrapper);
js::WrapperMap::Ptr lookupWrapper(const js::Value& wrapped) const {
@@ -672,7 +672,7 @@ struct JSCompartment
js::SavedStacks& savedStacks() { return savedStacks_; }
// Add a name to [[VarNames]]. Reports OOM on failure.
- MOZ_MUST_USE bool addToVarNames(JSContext* cx, JS::Handle<JSAtom*> name);
+ [[nodiscard]] bool addToVarNames(JSContext* cx, JS::Handle<JSAtom*> name);
void removeFromVarNames(JS::Handle<JSAtom*> name) {
varNames_.remove(name);
diff --git a/js/src/jsfriendapi.h b/js/src/jsfriendapi.h
index c463019dac..508ddc4419 100644
--- a/js/src/jsfriendapi.h
+++ b/js/src/jsfriendapi.h
@@ -1326,11 +1326,11 @@ class MOZ_STACK_CLASS JS_FRIEND_API(AutoStableStringChars)
: s_(cx), state_(Uninitialized)
{}
- MOZ_MUST_USE
+ [[nodiscard]]
bool init(JSContext* cx, JSString* s);
/* Like init(), but Latin1 chars are inflated to TwoByte. */
- MOZ_MUST_USE
+ [[nodiscard]]
bool initTwoByte(JSContext* cx, JSString* s);
bool isLatin1() const { return state_ == Latin1; }
diff --git a/js/src/jsnum.h b/js/src/jsnum.h
index 7c96bfb652..d6c3bf30ab 100644
--- a/js/src/jsnum.h
+++ b/js/src/jsnum.h
@@ -80,7 +80,7 @@ IsInteger(const Value& val);
* Convert an integer or double (contained in the given value) to a string and
* append to the given buffer.
*/
-extern MOZ_MUST_USE bool JS_FASTCALL
+[[nodiscard]] extern bool JS_FASTCALL
NumberValueToStringBuffer(JSContext* cx, const Value& v, StringBuffer& sb);
/* Same as js_NumberToString, different signature. */
@@ -159,7 +159,7 @@ enum class PrefixIntegerSeparatorHandling : bool {
* then upon return *dp == 0 and *endp == start.
*/
template <typename CharT>
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
GetPrefixInteger(ExclusiveContext* cx, const CharT* start, const CharT* end, int base,
PrefixIntegerSeparatorHandling separatorHandling, const CharT** endp,
double* dp);
@@ -169,7 +169,7 @@ GetPrefixInteger(ExclusiveContext* cx, const CharT* start, const CharT* end, int
* '_', and doesn't have an |endp| outparam. It should only be used when the
* characters are known to only contain digits and '_'.
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
GetDecimalInteger(ExclusiveContext* cx, const char16_t* start, const char16_t* end, double* dp);
/*
@@ -177,14 +177,14 @@ GetDecimalInteger(ExclusiveContext* cx, const char16_t* start, const char16_t* e
* should only be used when the characters are known to only contain digits,
* '.', 'e' or 'E', '+' or '-', and '_'.
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
GetDecimalNonInteger(ExclusiveContext* cx, const char16_t* start, const char16_t* end, double* dp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
StringToNumber(ExclusiveContext* cx, JSString* str, double* result);
/* ES5 9.3 ToNumber, overwriting *vp with the appropriate number value. */
-MOZ_ALWAYS_INLINE MOZ_MUST_USE bool
+[[nodiscard]] MOZ_ALWAYS_INLINE bool
ToNumber(JSContext* cx, JS::MutableHandleValue vp)
{
if (vp.isNumber())
@@ -198,7 +198,7 @@ ToNumber(JSContext* cx, JS::MutableHandleValue vp)
return true;
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
num_parseInt(JSContext* cx, unsigned argc, Value* vp);
} /* namespace js */
@@ -216,16 +216,16 @@ num_parseInt(JSContext* cx, unsigned argc, Value* vp);
* Return false if out of memory.
*/
template <typename CharT>
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
js_strtod(js::ExclusiveContext* cx, const CharT* begin, const CharT* end,
const CharT** dEnd, double* d);
namespace js {
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
num_toString(JSContext* cx, unsigned argc, Value* vp);
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
num_valueOf(JSContext* cx, unsigned argc, Value* vp);
static MOZ_ALWAYS_INLINE bool
@@ -265,7 +265,7 @@ IsDefinitelyIndex(const Value& v, uint32_t* indexp)
}
/* ES5 9.4 ToInteger. */
-static MOZ_MUST_USE inline bool
+[[nodiscard]] static inline bool
ToInteger(JSContext* cx, HandleValue v, double* dp)
{
if (v.isInt32()) {
@@ -290,7 +290,7 @@ ToInteger(JSContext* cx, HandleValue v, double* dp)
* For JSContext and ExclusiveContext.
*/
template<typename T>
-MOZ_MUST_USE bool ToLengthClamped(T* cx, HandleValue v, uint32_t* out, bool* overflow);
+[[nodiscard]] bool ToLengthClamped(T* cx, HandleValue v, uint32_t* out, bool* overflow);
/* Convert and range check an index value as for DataView, SIMD, and Atomics
* operations, eg ES7 24.2.1.1, DataView's GetViewValue():
@@ -310,7 +310,7 @@ MOZ_MUST_USE bool ToLengthClamped(T* cx, HandleValue v, uint32_t* out, bool* ove
*
* The returned index will always be in the range 0 <= *index <= 2^53.
*/
-MOZ_MUST_USE bool ToIntegerIndex(JSContext* cx, JS::HandleValue v, uint64_t* index);
+[[nodiscard]] bool ToIntegerIndex(JSContext* cx, JS::HandleValue v, uint64_t* index);
/* ES2017 draft 7.1.17 ToIndex
*
@@ -319,9 +319,9 @@ MOZ_MUST_USE bool ToIntegerIndex(JSContext* cx, JS::HandleValue v, uint64_t* ind
*
* The returned index will always be in the range 0 <= *index <= 2^53-1.
*/
-MOZ_MUST_USE bool ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index);
+[[nodiscard]] bool ToIndex(JSContext* cx, JS::HandleValue v, uint64_t* index);
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
SafeAdd(int32_t one, int32_t two, int32_t* res)
{
#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_sadd_overflow)
@@ -336,7 +336,7 @@ SafeAdd(int32_t one, int32_t two, int32_t* res)
#endif
}
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
SafeSub(int32_t one, int32_t two, int32_t* res)
{
#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_ssub_overflow)
@@ -348,7 +348,7 @@ SafeSub(int32_t one, int32_t two, int32_t* res)
#endif
}
-MOZ_MUST_USE inline bool
+[[nodiscard]] inline bool
SafeMul(int32_t one, int32_t two, int32_t* res)
{
#if BUILTIN_CHECKED_ARITHMETIC_SUPPORTED(__builtin_smul_overflow)
@@ -360,12 +360,12 @@ SafeMul(int32_t one, int32_t two, int32_t* res)
#endif
}
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
ToNumberSlow(ExclusiveContext* cx, HandleValue v, double* dp);
// Variant of ToNumber which takes an ExclusiveContext instead of a JSContext.
// ToNumber is part of the API and can't use ExclusiveContext directly.
-MOZ_ALWAYS_INLINE MOZ_MUST_USE bool
+[[nodiscard]] MOZ_ALWAYS_INLINE bool
ToNumber(ExclusiveContext* cx, HandleValue v, double* out)
{
if (v.isNumber()) {
@@ -379,7 +379,7 @@ bool
ToNumericSlow(ExclusiveContext* cx, JS::MutableHandleValue vp);
// BigInt proposal section 3.1.6
-MOZ_ALWAYS_INLINE MOZ_MUST_USE bool
+[[nodiscard]] MOZ_ALWAYS_INLINE bool
ToNumeric(ExclusiveContext* cx, JS::MutableHandleValue vp)
{
if (vp.isNumeric()) {
@@ -391,7 +391,7 @@ ToNumeric(ExclusiveContext* cx, JS::MutableHandleValue vp)
bool
ToInt32OrBigIntSlow(JSContext* cx, JS::MutableHandleValue vp);
-MOZ_ALWAYS_INLINE MOZ_MUST_USE bool
+[[nodiscard]] MOZ_ALWAYS_INLINE bool
ToInt32OrBigInt(JSContext* cx, JS::MutableHandleValue vp)
{
if (vp.isInt32()) {
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index 46f89e547e..3809df8ea8 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -3854,7 +3854,7 @@ JSObject::maybeConstructorDisplayAtom() const
}
// ES 2016 7.3.20.
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
js::SpeciesConstructor(JSContext* cx, HandleObject obj, HandleObject defaultCtor,
bool (*isDefaultSpecies)(JSContext*, JSFunction*))
{
@@ -3916,7 +3916,7 @@ js::SpeciesConstructor(JSContext* cx, HandleObject obj, HandleObject defaultCtor
return nullptr;
}
-MOZ_MUST_USE JSObject*
+[[nodiscard]] JSObject*
js::SpeciesConstructor(JSContext* cx, HandleObject obj, JSProtoKey ctorKey,
bool (*isDefaultSpecies)(JSContext*, JSFunction*))
{
diff --git a/js/src/jsobj.h b/js/src/jsobj.h
index a53667d251..1948eb036d 100644
--- a/js/src/jsobj.h
+++ b/js/src/jsobj.h
@@ -1345,11 +1345,11 @@ FreezeObject(JSContext* cx, HandleObject obj)
extern bool
TestIntegrityLevel(JSContext* cx, HandleObject obj, IntegrityLevel level, bool* resultp);
-extern MOZ_MUST_USE JSObject*
+[[nodiscard]] extern JSObject*
SpeciesConstructor(JSContext* cx, HandleObject obj, HandleObject defaultCtor,
bool (*isDefaultSpecies)(JSContext*, JSFunction*));
-extern MOZ_MUST_USE JSObject*
+[[nodiscard]] extern JSObject*
SpeciesConstructor(JSContext* cx, HandleObject obj, JSProtoKey ctorKey,
bool (*isDefaultSpecies)(JSContext*, JSFunction*));
diff --git a/js/src/jsobjinlines.h b/js/src/jsobjinlines.h
index a27a13fd6c..979838ea9b 100644
--- a/js/src/jsobjinlines.h
+++ b/js/src/jsobjinlines.h
@@ -294,7 +294,7 @@ ClassCanHaveFixedData(const Class* clasp)
// returned in place of the pointer passed. If a GC occurs, the returned pointer
// may be the passed pointer, relocated by GC. If no GC could occur, it's just
// passed through. We root nothing unless necessary.
-static MOZ_ALWAYS_INLINE MOZ_MUST_USE JSObject*
+[[nodiscard]] static MOZ_ALWAYS_INLINE JSObject*
SetNewObjectMetadata(ExclusiveContext* cxArg, JSObject* obj)
{
MOZ_ASSERT(!cxArg->compartment()->hasObjectPendingMetadata());
diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp
index c9ec240e7f..b82715fb6e 100644
--- a/js/src/jsopcode.cpp
+++ b/js/src/jsopcode.cpp
@@ -149,7 +149,7 @@ js::StackDefs(JSScript* script, jsbytecode* pc)
const char * PCCounts::numExecName = "interp";
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
DumpIonScriptCounts(Sprinter* sp, HandleScript script, jit::IonScriptCounts* ionCounts)
{
if (!sp->jsprintf("IonScript [%" PRIuSIZE " blocks]:\n", ionCounts->numBlocks()))
@@ -181,7 +181,7 @@ DumpIonScriptCounts(Sprinter* sp, HandleScript script, jit::IonScriptCounts* ion
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
DumpPCCounts(JSContext* cx, HandleScript script, Sprinter* sp)
{
MOZ_ASSERT(script->hasScriptCounts());
@@ -696,7 +696,7 @@ js::ReconstructStackDepth(JSContext* cx, JSScript* script, jsbytecode* pc, uint3
* current line. If showAll is true, include the source note type and the
* entry stack depth.
*/
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
DisassembleAtPC(JSContext* cx, JSScript* scriptArg, bool lines,
jsbytecode* pc, bool showAll, Sprinter* sp)
{
@@ -1861,7 +1861,7 @@ js::GetPCCountScriptCount(JSContext* cx)
enum MaybeComma {NO_COMMA, COMMA};
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
AppendJSONProperty(StringBuffer& buf, const char* name, MaybeComma comma = COMMA)
{
if (comma && !buf.append(','))
diff --git a/js/src/jsopcode.h b/js/src/jsopcode.h
index 70ae964b23..ce0658a7b3 100644
--- a/js/src/jsopcode.h
+++ b/js/src/jsopcode.h
@@ -875,7 +875,7 @@ GetNextPc(jsbytecode* pc)
/*
* Disassemblers, for debugging only.
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
Disassemble(JSContext* cx, JS::Handle<JSScript*> script, bool lines, Sprinter* sp);
unsigned
@@ -884,7 +884,7 @@ Disassemble1(JSContext* cx, JS::Handle<JSScript*> script, jsbytecode* pc, unsign
#endif
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
DumpCompartmentPCCounts(JSContext* cx);
} // namespace js
diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp
index 5cf0d19195..bb59f5fba5 100644
--- a/js/src/jsscript.cpp
+++ b/js/src/jsscript.cpp
@@ -1840,7 +1840,7 @@ ScriptSource::functionBodyString(JSContext* cx)
return substring(cx, start, stop);
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ScriptSource::setSource(ExclusiveContext* cx,
mozilla::UniquePtr<char16_t[], JS::FreePolicy>&& source,
size_t length)
@@ -1862,7 +1862,7 @@ ScriptSource::setSource(SharedImmutableTwoByteString&& string)
data = SourceType(Uncompressed(mozilla::Move(string)));
}
-MOZ_MUST_USE bool
+[[nodiscard]] bool
ScriptSource::setCompressedSource(ExclusiveContext* cx,
mozilla::UniquePtr<char[], JS::FreePolicy>&& raw,
size_t rawLength,
@@ -1939,7 +1939,7 @@ ScriptSource::setSourceCopy(ExclusiveContext* cx, SourceBufferHolder& srcBuf,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
reallocUniquePtr(UniquePtr<char[], JS::FreePolicy>& unique, size_t size)
{
auto newPtr = static_cast<char*>(js_realloc(unique.get(), size));
diff --git a/js/src/jsscript.h b/js/src/jsscript.h
index 78afa2eec2..1b29aaf0d1 100644
--- a/js/src/jsscript.h
+++ b/js/src/jsscript.h
@@ -520,12 +520,12 @@ class ScriptSource
void addSizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf,
JS::ScriptSourceInfo* info) const;
- MOZ_MUST_USE bool setSource(ExclusiveContext* cx,
+ [[nodiscard]] bool setSource(ExclusiveContext* cx,
mozilla::UniquePtr<char16_t[], JS::FreePolicy>&& source,
size_t length);
void setSource(SharedImmutableTwoByteString&& string);
- MOZ_MUST_USE bool setCompressedSource(
+ [[nodiscard]] bool setCompressedSource(
ExclusiveContext* cx,
mozilla::UniquePtr<char[], JS::FreePolicy>&& raw,
size_t rawLength,
diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp
index 593cf4d708..c539141130 100644
--- a/js/src/jsstr.cpp
+++ b/js/src/jsstr.cpp
@@ -1852,7 +1852,7 @@ class StringSegmentRange
: stack(cx, StringVector(cx)), cur(cx)
{}
- MOZ_MUST_USE bool init(JSString* str) {
+ [[nodiscard]] bool init(JSString* str) {
MOZ_ASSERT(stack.empty());
return settle(str);
}
@@ -1866,7 +1866,7 @@ class StringSegmentRange
return cur;
}
- MOZ_MUST_USE bool popFront() {
+ [[nodiscard]] bool popFront() {
MOZ_ASSERT(!empty());
if (stack.empty()) {
cur = nullptr;
diff --git a/js/src/jsstr.h b/js/src/jsstr.h
index cd2be4e59b..8ee7259cc2 100644
--- a/js/src/jsstr.h
+++ b/js/src/jsstr.h
@@ -377,7 +377,7 @@ str_trimEnd(JSContext* cx, unsigned argc, Value* vp);
*
* Usage: lowerCase = intl_toLocaleLowerCase(string, locale)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_toLocaleLowerCase(JSContext* cx, unsigned argc, Value* vp);
/**
@@ -386,7 +386,7 @@ intl_toLocaleLowerCase(JSContext* cx, unsigned argc, Value* vp);
*
* Usage: upperCase = intl_toLocaleUpperCase(string, locale)
*/
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
intl_toLocaleUpperCase(JSContext* cx, unsigned argc, Value* vp);
diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp
index 1f89e38482..b83fa6a3d5 100644
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -631,7 +631,7 @@ RegisterScriptPathWithModuleLoader(JSContext* cx, HandleScript script, const cha
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RunFile(JSContext* cx, const char* filename, FILE* file, bool compileOnly)
{
SkipUTF8BOM(file);
@@ -744,7 +744,7 @@ GetImportMethod(JSContext* cx, HandleObject loader, MutableHandleFunction result
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
RunModule(JSContext* cx, const char* filename, FILE* file, bool compileOnly)
{
// Execute a module by calling |Reflect.Loader.import(filename)|.
@@ -970,7 +970,7 @@ EvalAndPrint(JSContext* cx, const char* bytes, size_t length,
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ReadEvalPrintLoop(JSContext* cx, FILE* in, bool compileOnly)
{
ShellContext* sc = GetShellContext(cx);
@@ -1071,7 +1071,7 @@ ReportCantOpenErrorUnknownEncoding(JSContext* cx, const char* filename)
filename, strerror(errno));
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
Process(JSContext* cx, const char* filename, bool forceTTY, FileKind kind = FileScript)
{
FILE* file;
@@ -2488,7 +2488,7 @@ UpdateSwitchTableBounds(JSContext* cx, HandleScript script, unsigned offset,
*end = *start + (unsigned)(n * jmplen);
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
SrcNotes(JSContext* cx, HandleScript script, Sprinter* sp)
{
if (sp->put("\nSource notes:\n") < 0 ||
@@ -2664,7 +2664,7 @@ TryNoteName(JSTryNoteKind kind)
MOZ_CRASH("Bad JSTryNoteKind");
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
TryNotes(JSContext* cx, HandleScript script, Sprinter* sp)
{
if (!script->hasTrynotes())
@@ -2687,7 +2687,7 @@ TryNotes(JSContext* cx, HandleScript script, Sprinter* sp)
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ScopeNotes(JSContext* cx, HandleScript script, Sprinter* sp)
{
if (!script->hasScopeNotes())
@@ -2719,7 +2719,7 @@ ScopeNotes(JSContext* cx, HandleScript script, Sprinter* sp)
return true;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
DisassembleScript(JSContext* cx, HandleScript script, HandleFunction fun,
bool lines, bool recursive, bool sourceNotes, Sprinter* sp)
{
@@ -7477,7 +7477,7 @@ OptionFailure(const char* option, const char* str)
return false;
}
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
ProcessArgs(JSContext* cx, OptionParser* op)
{
ShellContext* sc = GetShellContext(cx);
diff --git a/js/src/threading/Thread.h b/js/src/threading/Thread.h
index c48f4af80f..7d9f560407 100644
--- a/js/src/threading/Thread.h
+++ b/js/src/threading/Thread.h
@@ -105,7 +105,7 @@ public:
// result in the value being copied, which may not be the intended behavior.
// See the comment below on ThreadTrampoline::args for an explanation.
template <typename F, typename... Args>
- MOZ_MUST_USE bool init(F&& f, Args&&... args) {
+ [[nodiscard]] bool init(F&& f, Args&&... args) {
MOZ_RELEASE_ASSERT(!joinable());
using Trampoline = detail::ThreadTrampoline<F, Args...>;
AutoEnterOOMUnsafeRegion oom;
@@ -163,7 +163,7 @@ private:
Options options_;
// Dispatch to per-platform implementation of thread creation.
- MOZ_MUST_USE bool create(THREAD_RETURN_TYPE (THREAD_CALL_API *aMain)(void*), void* aArg);
+ [[nodiscard]] bool create(THREAD_RETURN_TYPE (THREAD_CALL_API *aMain)(void*), void* aArg);
};
namespace ThisThread {
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 */
diff --git a/js/src/wasm/AsmJS.cpp b/js/src/wasm/AsmJS.cpp
index 9bb3f08e79..1c42ceca59 100644
--- a/js/src/wasm/AsmJS.cpp
+++ b/js/src/wasm/AsmJS.cpp
@@ -1595,7 +1595,7 @@ class MOZ_STACK_CLASS ModuleValidator
MOZ_ASSERT(!moduleFunctionName_);
moduleFunctionName_ = name;
}
- MOZ_MUST_USE bool initGlobalArgumentName(PropertyName* n) {
+ [[nodiscard]] bool initGlobalArgumentName(PropertyName* n) {
MOZ_ASSERT(n->isTenured());
globalArgumentName_ = n;
if (n) {
@@ -1605,7 +1605,7 @@ class MOZ_STACK_CLASS ModuleValidator
}
return true;
}
- MOZ_MUST_USE bool initImportArgumentName(PropertyName* n) {
+ [[nodiscard]] bool initImportArgumentName(PropertyName* n) {
MOZ_ASSERT(n->isTenured());
importArgumentName_ = n;
if (n) {
@@ -1615,7 +1615,7 @@ class MOZ_STACK_CLASS ModuleValidator
}
return true;
}
- MOZ_MUST_USE bool initBufferArgumentName(PropertyName* n) {
+ [[nodiscard]] bool initBufferArgumentName(PropertyName* n) {
MOZ_ASSERT(n->isTenured());
bufferArgumentName_ = n;
if (n) {
@@ -2500,11 +2500,11 @@ class MOZ_STACK_CLASS FunctionValidator
Encoder& encoder() { return *encoder_; }
- MOZ_MUST_USE bool writeInt32Lit(int32_t i32) {
+ [[nodiscard]] bool writeInt32Lit(int32_t i32) {
return encoder().writeOp(Op::I32Const) &&
encoder().writeVarS32(i32);
}
- MOZ_MUST_USE bool writeConstExpr(const NumLit& lit) {
+ [[nodiscard]] bool writeConstExpr(const NumLit& lit) {
switch (lit.which()) {
case NumLit::Fixnum:
case NumLit::NegativeInt:
@@ -2521,11 +2521,11 @@ class MOZ_STACK_CLASS FunctionValidator
}
MOZ_CRASH("unexpected literal type");
}
- MOZ_MUST_USE bool writeCall(ParseNode* pn, Op op) {
+ [[nodiscard]] bool writeCall(ParseNode* pn, Op op) {
return encoder().writeOp(op) &&
fg_.addCallSiteLineNum(m().tokenStream().srcCoords.lineNum(pn->pn_pos.begin));
}
- MOZ_MUST_USE bool prepareCall(ParseNode* pn) {
+ [[nodiscard]] bool prepareCall(ParseNode* pn) {
return fg_.addCallSiteLineNum(m().tokenStream().srcCoords.lineNum(pn->pn_pos.begin));
}
};
diff --git a/js/src/wasm/AsmJS.h b/js/src/wasm/AsmJS.h
index 2bad4b3e4e..abdbf5111d 100644
--- a/js/src/wasm/AsmJS.h
+++ b/js/src/wasm/AsmJS.h
@@ -39,7 +39,7 @@ typedef frontend::Parser<frontend::FullParseHandler> AsmJSParser;
// indeterminate amount and the entire function should be reparsed from the
// beginning.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
CompileAsmJS(ExclusiveContext* cx, AsmJSParser& parser, frontend::ParseNode* stmtList,
bool* validated);
diff --git a/js/src/wasm/WasmBaselineCompile.cpp b/js/src/wasm/WasmBaselineCompile.cpp
index 152d15cf24..38d8d5b99b 100644
--- a/js/src/wasm/WasmBaselineCompile.cpp
+++ b/js/src/wasm/WasmBaselineCompile.cpp
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -583,11 +584,11 @@ class BaseCompiler
const ValTypeVector& locals,
FuncCompileResults& compileResults);
- MOZ_MUST_USE bool init();
+ [[nodiscard]] bool init();
void finish();
- MOZ_MUST_USE bool emitFunction();
+ [[nodiscard]] bool emitFunction();
// Used by some of the ScratchRegister implementations.
operator MacroAssembler&() const { return masm; }
@@ -607,14 +608,14 @@ class BaseCompiler
//
// Out of line code management.
- MOZ_MUST_USE OutOfLineCode* addOutOfLineCode(OutOfLineCode* ool) {
+ [[nodiscard]] OutOfLineCode* addOutOfLineCode(OutOfLineCode* ool) {
if (!ool || !outOfLine_.append(ool))
return nullptr;
ool->setFramePushed(masm.framePushed());
return ool;
}
- MOZ_MUST_USE bool generateOutOfLineCode() {
+ [[nodiscard]] bool generateOutOfLineCode() {
for (uint32_t i = 0; i < outOfLine_.length(); i++) {
OutOfLineCode* ool = outOfLine_[i];
ool->bind(masm);
@@ -1010,7 +1011,7 @@ class BaseCompiler
freeFPU(r.reg);
}
- MOZ_MUST_USE RegI32 needI32() {
+ [[nodiscard]] RegI32 needI32() {
if (!hasGPR())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegI32(allocGPR());
@@ -1030,7 +1031,7 @@ class BaseCompiler
needI32(r1);
}
- MOZ_MUST_USE RegI64 needI64() {
+ [[nodiscard]] RegI64 needI64() {
if (!hasInt64())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegI64(allocInt64());
@@ -1047,7 +1048,7 @@ class BaseCompiler
needI64(r1);
}
- MOZ_MUST_USE RegF32 needF32() {
+ [[nodiscard]] RegF32 needF32() {
if (!hasFPU<MIRType::Float32>())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegF32(allocFPU<MIRType::Float32>());
@@ -1059,7 +1060,7 @@ class BaseCompiler
allocFPU(specific.reg);
}
- MOZ_MUST_USE RegF64 needF64() {
+ [[nodiscard]] RegF64 needF64() {
if (!hasFPU<MIRType::Double>())
sync(); // TODO / OPTIMIZE: improve this (Bug 1316802)
return RegF64(allocFPU<MIRType::Double>());
@@ -1491,7 +1492,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegI32 popI32() {
+ [[nodiscard]] RegI32 popI32() {
Stk& v = stk_.back();
RegI32 r;
if (v.kind() == Stk::RegisterI32)
@@ -1545,7 +1546,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegI64 popI64() {
+ [[nodiscard]] RegI64 popI64() {
Stk& v = stk_.back();
RegI64 r;
if (v.kind() == Stk::RegisterI64)
@@ -1599,7 +1600,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegF64 popF64() {
+ [[nodiscard]] RegF64 popF64() {
Stk& v = stk_.back();
RegF64 r;
if (v.kind() == Stk::RegisterF64)
@@ -1648,7 +1649,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE RegF32 popF32() {
+ [[nodiscard]] RegF32 popF32() {
Stk& v = stk_.back();
RegF32 r;
if (v.kind() == Stk::RegisterF32)
@@ -1673,7 +1674,7 @@ class BaseCompiler
return specific;
}
- MOZ_MUST_USE bool popConstI32(int32_t& c) {
+ [[nodiscard]] bool popConstI32(int32_t& c) {
Stk& v = stk_.back();
if (v.kind() != Stk::ConstI32)
return false;
@@ -1701,7 +1702,7 @@ class BaseCompiler
// popping of the stack we can just use the JoinReg as it will
// become available in that process.
- MOZ_MUST_USE AnyReg popJoinReg() {
+ [[nodiscard]] AnyReg popJoinReg() {
switch (stk_.back().kind()) {
case Stk::RegisterI32:
case Stk::ConstI32:
@@ -1731,7 +1732,7 @@ class BaseCompiler
}
}
- MOZ_MUST_USE AnyReg allocJoinReg(ExprType type) {
+ [[nodiscard]] AnyReg allocJoinReg(ExprType type) {
switch (type) {
case ExprType::I32:
allocGPR(joinRegI32.reg);
@@ -1926,7 +1927,7 @@ class BaseCompiler
Vector<Control, 8, SystemAllocPolicy> ctl_;
- MOZ_MUST_USE bool pushControl(UniquePooledLabel* label, UniquePooledLabel* otherLabel = nullptr)
+ [[nodiscard]] bool pushControl(UniquePooledLabel* label, UniquePooledLabel* otherLabel = nullptr)
{
uint32_t framePushed = masm.framePushed();
uint32_t stackSize = stk_.length();
@@ -1956,7 +1957,7 @@ class BaseCompiler
return ctl_[ctl_.length() - 1 - relativeDepth];
}
- MOZ_MUST_USE PooledLabel* newLabel() {
+ [[nodiscard]] PooledLabel* newLabel() {
// TODO / INVESTIGATE (Bug 1316819): allocate() is fallible, but we can
// probably rely on an infallible allocator here. That would simplify
// code later.
@@ -2825,7 +2826,7 @@ class BaseCompiler
}
};
- MOZ_MUST_USE bool truncateF32ToI32(RegF32 src, RegI32 dest, bool isUnsigned) {
+ [[nodiscard]] bool truncateF32ToI32(RegF32 src, RegI32 dest, bool isUnsigned) {
TrapOffset off = trapOffset();
OutOfLineCode* ool;
if (isCompilingAsmJS()) {
@@ -2853,7 +2854,7 @@ class BaseCompiler
return true;
}
- MOZ_MUST_USE bool truncateF64ToI32(RegF64 src, RegI32 dest, bool isUnsigned) {
+ [[nodiscard]] bool truncateF64ToI32(RegF64 src, RegI32 dest, bool isUnsigned) {
TrapOffset off = trapOffset();
OutOfLineCode* ool;
if (isCompilingAsmJS()) {
@@ -2923,7 +2924,7 @@ class BaseCompiler
};
#ifndef FLOAT_TO_I64_CALLOUT
- MOZ_MUST_USE bool truncateF32ToI64(RegF32 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
+ [[nodiscard]] bool truncateF32ToI64(RegF32 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
# if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86)
OutOfLineCode* ool =
addOutOfLineCode(new (alloc_) OutOfLineTruncateCheckF32OrF64ToI64(AnyReg(src),
@@ -2943,7 +2944,7 @@ class BaseCompiler
return true;
}
- MOZ_MUST_USE bool truncateF64ToI64(RegF64 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
+ [[nodiscard]] bool truncateF64ToI64(RegF64 src, RegI64 dest, bool isUnsigned, RegF64 temp) {
# if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86)
OutOfLineCode* ool =
addOutOfLineCode(new (alloc_) OutOfLineTruncateCheckF32OrF64ToI64(AnyReg(src),
@@ -3231,7 +3232,7 @@ class BaseCompiler
}
// This is the temp register passed as the last argument to load()
- MOZ_MUST_USE size_t loadStoreTemps(MemoryAccessDesc& access) {
+ [[nodiscard]] size_t loadStoreTemps(MemoryAccessDesc& access) {
#if defined(JS_CODEGEN_ARM)
if (IsUnaligned(access)) {
switch (access.type()) {
@@ -3251,7 +3252,7 @@ class BaseCompiler
// ptr and dest may be the same iff dest is I32.
// This may destroy ptr even if ptr and dest are not the same.
- MOZ_MUST_USE bool load(MemoryAccessDesc& access, RegI32 ptr, AnyReg dest, RegI32 tmp1,
+ [[nodiscard]] bool load(MemoryAccessDesc& access, RegI32 ptr, AnyReg dest, RegI32 tmp1,
RegI32 tmp2)
{
checkOffset(&access, ptr);
@@ -3337,7 +3338,7 @@ class BaseCompiler
// ptr and src must not be the same register.
// This may destroy ptr.
- MOZ_MUST_USE bool store(MemoryAccessDesc access, RegI32 ptr, AnyReg src, RegI32 tmp1,
+ [[nodiscard]] bool store(MemoryAccessDesc access, RegI32 ptr, AnyReg src, RegI32 tmp1,
RegI32 tmp2)
{
checkOffset(&access, ptr);
@@ -3613,38 +3614,38 @@ class BaseCompiler
//////////////////////////////////////////////////////////////////////
- MOZ_MUST_USE bool emitBody();
- MOZ_MUST_USE bool emitBlock();
- MOZ_MUST_USE bool emitLoop();
- MOZ_MUST_USE bool emitIf();
- MOZ_MUST_USE bool emitElse();
- MOZ_MUST_USE bool emitEnd();
- MOZ_MUST_USE bool emitBr();
- MOZ_MUST_USE bool emitBrIf();
- MOZ_MUST_USE bool emitBrTable();
- MOZ_MUST_USE bool emitDrop();
- MOZ_MUST_USE bool emitReturn();
- MOZ_MUST_USE bool emitCallArgs(const ValTypeVector& args, FunctionCall& baselineCall);
- MOZ_MUST_USE bool emitCall();
- MOZ_MUST_USE bool emitCallIndirect(bool oldStyle);
- MOZ_MUST_USE bool emitCommonMathCall(uint32_t lineOrBytecode, SymbolicAddress callee,
+ [[nodiscard]] bool emitBody();
+ [[nodiscard]] bool emitBlock();
+ [[nodiscard]] bool emitLoop();
+ [[nodiscard]] bool emitIf();
+ [[nodiscard]] bool emitElse();
+ [[nodiscard]] bool emitEnd();
+ [[nodiscard]] bool emitBr();
+ [[nodiscard]] bool emitBrIf();
+ [[nodiscard]] bool emitBrTable();
+ [[nodiscard]] bool emitDrop();
+ [[nodiscard]] bool emitReturn();
+ [[nodiscard]] bool emitCallArgs(const ValTypeVector& args, FunctionCall& baselineCall);
+ [[nodiscard]] bool emitCall();
+ [[nodiscard]] bool emitCallIndirect(bool oldStyle);
+ [[nodiscard]] bool emitCommonMathCall(uint32_t lineOrBytecode, SymbolicAddress callee,
ValTypeVector& signature, ExprType retType);
- MOZ_MUST_USE bool emitUnaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
- MOZ_MUST_USE bool emitBinaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
+ [[nodiscard]] bool emitUnaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
+ [[nodiscard]] bool emitBinaryMathBuiltinCall(SymbolicAddress callee, ValType operandType);
#ifdef INT_DIV_I64_CALLOUT
- MOZ_MUST_USE bool emitDivOrModI64BuiltinCall(SymbolicAddress callee, ValType operandType);
+ [[nodiscard]] bool emitDivOrModI64BuiltinCall(SymbolicAddress callee, ValType operandType);
#endif
- MOZ_MUST_USE bool emitGetLocal();
- MOZ_MUST_USE bool emitSetLocal();
- MOZ_MUST_USE bool emitTeeLocal();
- MOZ_MUST_USE bool emitGetGlobal();
- MOZ_MUST_USE bool emitSetGlobal();
- MOZ_MUST_USE bool emitTeeGlobal();
- MOZ_MUST_USE bool emitLoad(ValType type, Scalar::Type viewType);
- MOZ_MUST_USE bool emitStore(ValType resultType, Scalar::Type viewType);
- MOZ_MUST_USE bool emitTeeStore(ValType resultType, Scalar::Type viewType);
- MOZ_MUST_USE bool emitTeeStoreWithCoercion(ValType resultType, Scalar::Type viewType);
- MOZ_MUST_USE bool emitSelect();
+ [[nodiscard]] bool emitGetLocal();
+ [[nodiscard]] bool emitSetLocal();
+ [[nodiscard]] bool emitTeeLocal();
+ [[nodiscard]] bool emitGetGlobal();
+ [[nodiscard]] bool emitSetGlobal();
+ [[nodiscard]] bool emitTeeGlobal();
+ [[nodiscard]] bool emitLoad(ValType type, Scalar::Type viewType);
+ [[nodiscard]] bool emitStore(ValType resultType, Scalar::Type viewType);
+ [[nodiscard]] bool emitTeeStore(ValType resultType, Scalar::Type viewType);
+ [[nodiscard]] bool emitTeeStoreWithCoercion(ValType resultType, Scalar::Type viewType);
+ [[nodiscard]] bool emitSelect();
void endBlock(ExprType type, bool isFunctionBody);
void endLoop(ExprType type);
@@ -3725,14 +3726,14 @@ class BaseCompiler
void emitNegateF64();
void emitSqrtF32();
void emitSqrtF64();
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF32ToI32();
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF64ToI32();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF32ToI32();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF64ToI32();
#ifdef FLOAT_TO_I64_CALLOUT
- MOZ_MUST_USE bool emitConvertFloatingToInt64Callout(SymbolicAddress callee, ValType operandType,
+ [[nodiscard]] bool emitConvertFloatingToInt64Callout(SymbolicAddress callee, ValType operandType,
ValType resultType);
#else
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF32ToI64();
- template<bool isUnsigned> MOZ_MUST_USE bool emitTruncateF64ToI64();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF32ToI64();
+ template<bool isUnsigned> [[nodiscard]] bool emitTruncateF64ToI64();
#endif
void emitWrapI64ToI32();
void emitExtendI32_8();
@@ -3751,7 +3752,7 @@ class BaseCompiler
void emitConvertI32ToF64();
void emitConvertU32ToF64();
#ifdef I64_TO_FLOAT_CALLOUT
- MOZ_MUST_USE bool emitConvertInt64ToFloatingCallout(SymbolicAddress callee, ValType operandType,
+ [[nodiscard]] bool emitConvertInt64ToFloatingCallout(SymbolicAddress callee, ValType operandType,
ValType resultType);
#else
void emitConvertI64ToF32();
@@ -3761,8 +3762,8 @@ class BaseCompiler
#endif
void emitReinterpretI32AsF32();
void emitReinterpretI64AsF64();
- MOZ_MUST_USE bool emitGrowMemory();
- MOZ_MUST_USE bool emitCurrentMemory();
+ [[nodiscard]] bool emitGrowMemory();
+ [[nodiscard]] bool emitCurrentMemory();
};
void
diff --git a/js/src/wasm/WasmBinaryFormat.h b/js/src/wasm/WasmBinaryFormat.h
index 0279597cb8..d7fda3aa8a 100644
--- a/js/src/wasm/WasmBinaryFormat.h
+++ b/js/src/wasm/WasmBinaryFormat.h
@@ -33,12 +33,12 @@ class Encoder
Bytes& bytes_;
template <class T>
- MOZ_MUST_USE bool write(const T& v) {
+ [[nodiscard]] bool write(const T& v) {
return bytes_.append(reinterpret_cast<const uint8_t*>(&v), sizeof(T));
}
template <typename UInt>
- MOZ_MUST_USE bool writeVarU(UInt i) {
+ [[nodiscard]] bool writeVarU(UInt i) {
do {
uint8_t byte = i & 0x7f;
i >>= 7;
@@ -51,7 +51,7 @@ class Encoder
}
template <typename SInt>
- MOZ_MUST_USE bool writeVarS(SInt i) {
+ [[nodiscard]] bool writeVarS(SInt i) {
bool done;
do {
uint8_t byte = i & 0x7f;
@@ -111,48 +111,48 @@ class Encoder
// Fixed-size encoding operations simply copy the literal bytes (without
// attempting to align).
- MOZ_MUST_USE bool writeFixedU7(uint8_t i) {
+ [[nodiscard]] bool writeFixedU7(uint8_t i) {
MOZ_ASSERT(i <= uint8_t(INT8_MAX));
return writeFixedU8(i);
}
- MOZ_MUST_USE bool writeFixedU8(uint8_t i) {
+ [[nodiscard]] bool writeFixedU8(uint8_t i) {
return write<uint8_t>(i);
}
- MOZ_MUST_USE bool writeFixedU32(uint32_t i) {
+ [[nodiscard]] bool writeFixedU32(uint32_t i) {
return write<uint32_t>(i);
}
- MOZ_MUST_USE bool writeFixedF32(RawF32 f) {
+ [[nodiscard]] bool writeFixedF32(RawF32 f) {
return write<uint32_t>(f.bits());
}
- MOZ_MUST_USE bool writeFixedF64(RawF64 d) {
+ [[nodiscard]] bool writeFixedF64(RawF64 d) {
return write<uint64_t>(d.bits());
}
// Variable-length encodings that all use LEB128.
- MOZ_MUST_USE bool writeVarU32(uint32_t i) {
+ [[nodiscard]] bool writeVarU32(uint32_t i) {
return writeVarU<uint32_t>(i);
}
- MOZ_MUST_USE bool writeVarS32(int32_t i) {
+ [[nodiscard]] bool writeVarS32(int32_t i) {
return writeVarS<int32_t>(i);
}
- MOZ_MUST_USE bool writeVarU64(uint64_t i) {
+ [[nodiscard]] bool writeVarU64(uint64_t i) {
return writeVarU<uint64_t>(i);
}
- MOZ_MUST_USE bool writeVarS64(int64_t i) {
+ [[nodiscard]] bool writeVarS64(int64_t i) {
return writeVarS<int64_t>(i);
}
- MOZ_MUST_USE bool writeValType(ValType type) {
+ [[nodiscard]] bool writeValType(ValType type) {
static_assert(size_t(TypeCode::Limit) <= UINT8_MAX, "fits");
MOZ_ASSERT(size_t(type) < size_t(TypeCode::Limit));
return writeFixedU8(uint8_t(type));
}
- MOZ_MUST_USE bool writeBlockType(ExprType type) {
+ [[nodiscard]] bool writeBlockType(ExprType type) {
static_assert(size_t(TypeCode::Limit) <= UINT8_MAX, "fits");
MOZ_ASSERT(size_t(type) < size_t(TypeCode::Limit));
return writeFixedU8(uint8_t(type));
}
- MOZ_MUST_USE bool writeOp(Op op) {
+ [[nodiscard]] bool writeOp(Op op) {
static_assert(size_t(Op::Limit) <= 2 * UINT8_MAX, "fits");
MOZ_ASSERT(size_t(op) < size_t(Op::Limit));
if (size_t(op) < UINT8_MAX)
@@ -163,7 +163,7 @@ class Encoder
// Fixed-length encodings that allow back-patching.
- MOZ_MUST_USE bool writePatchableFixedU7(size_t* offset) {
+ [[nodiscard]] bool writePatchableFixedU7(size_t* offset) {
*offset = bytes_.length();
return writeFixedU8(UINT8_MAX);
}
@@ -173,7 +173,7 @@ class Encoder
// Variable-length encodings that allow back-patching.
- MOZ_MUST_USE bool writePatchableVarU32(size_t* offset) {
+ [[nodiscard]] bool writePatchableVarU32(size_t* offset) {
*offset = bytes_.length();
return writeVarU32(UINT32_MAX);
}
@@ -184,7 +184,7 @@ class Encoder
// Byte ranges start with an LEB128 length followed by an arbitrary sequence
// of bytes. When used for strings, bytes are to be interpreted as utf8.
- MOZ_MUST_USE bool writeBytes(const void* bytes, uint32_t numBytes) {
+ [[nodiscard]] bool writeBytes(const void* bytes, uint32_t numBytes) {
return writeVarU32(numBytes) &&
bytes_.append(reinterpret_cast<const uint8_t*>(bytes), numBytes);
}
@@ -195,7 +195,7 @@ class Encoder
// end while the size's varU32 must be stored at the beginning. Immediately
// after the section length is the string id of the section.
- MOZ_MUST_USE bool startSection(SectionId id, size_t* offset) {
+ [[nodiscard]] bool startSection(SectionId id, size_t* offset) {
MOZ_ASSERT(id != SectionId::UserDefined); // not supported yet
return writeVarU32(uint32_t(id)) &&
@@ -218,7 +218,7 @@ class Decoder
UniqueChars* error_;
template <class T>
- MOZ_MUST_USE bool read(T* out) {
+ [[nodiscard]] bool read(T* out) {
if (bytesRemain() < sizeof(T))
return false;
memcpy((void*)out, cur_, sizeof(T));
@@ -243,7 +243,7 @@ class Decoder
}
template <typename UInt>
- MOZ_MUST_USE bool readVarU(UInt* out) {
+ [[nodiscard]] bool readVarU(UInt* out) {
const unsigned numBits = sizeof(UInt) * CHAR_BIT;
const unsigned remainderBits = numBits % 7;
const unsigned numBitsInSevens = numBits - remainderBits;
@@ -267,7 +267,7 @@ class Decoder
}
template <typename SInt>
- MOZ_MUST_USE bool readVarS(SInt* out) {
+ [[nodiscard]] bool readVarS(SInt* out) {
const unsigned numBits = sizeof(SInt) * CHAR_BIT;
const unsigned remainderBits = numBits % 7;
const unsigned numBitsInSevens = numBits - remainderBits;
@@ -344,20 +344,20 @@ class Decoder
// Fixed-size encoding operations simply copy the literal bytes (without
// attempting to align).
- MOZ_MUST_USE bool readFixedU8(uint8_t* i) {
+ [[nodiscard]] bool readFixedU8(uint8_t* i) {
return read<uint8_t>(i);
}
- MOZ_MUST_USE bool readFixedU32(uint32_t* u) {
+ [[nodiscard]] bool readFixedU32(uint32_t* u) {
return read<uint32_t>(u);
}
- MOZ_MUST_USE bool readFixedF32(RawF32* f) {
+ [[nodiscard]] bool readFixedF32(RawF32* f) {
uint32_t u;
if (!read<uint32_t>(&u))
return false;
*f = RawF32::fromBits(u);
return true;
}
- MOZ_MUST_USE bool readFixedF64(RawF64* d) {
+ [[nodiscard]] bool readFixedF64(RawF64* d) {
uint64_t u;
if (!read<uint64_t>(&u))
return false;
@@ -367,27 +367,27 @@ class Decoder
// Variable-length encodings that all use LEB128.
- MOZ_MUST_USE bool readVarU32(uint32_t* out) {
+ [[nodiscard]] bool readVarU32(uint32_t* out) {
return readVarU<uint32_t>(out);
}
- MOZ_MUST_USE bool readVarS32(int32_t* out) {
+ [[nodiscard]] bool readVarS32(int32_t* out) {
return readVarS<int32_t>(out);
}
- MOZ_MUST_USE bool readVarU64(uint64_t* out) {
+ [[nodiscard]] bool readVarU64(uint64_t* out) {
return readVarU<uint64_t>(out);
}
- MOZ_MUST_USE bool readVarS64(int64_t* out) {
+ [[nodiscard]] bool readVarS64(int64_t* out) {
return readVarS<int64_t>(out);
}
- MOZ_MUST_USE bool readValType(uint8_t* type) {
+ [[nodiscard]] bool readValType(uint8_t* type) {
static_assert(uint8_t(TypeCode::Limit) <= UINT8_MAX, "fits");
return readFixedU8(type);
}
- MOZ_MUST_USE bool readBlockType(uint8_t* type) {
+ [[nodiscard]] bool readBlockType(uint8_t* type) {
static_assert(size_t(TypeCode::Limit) <= UINT8_MAX, "fits");
return readFixedU8(type);
}
- MOZ_MUST_USE bool readOp(uint16_t* op) {
+ [[nodiscard]] bool readOp(uint16_t* op) {
static_assert(size_t(Op::Limit) <= 2 * UINT8_MAX, "fits");
uint8_t u8;
if (!readFixedU8(&u8))
@@ -404,7 +404,7 @@ class Decoder
// See writeBytes comment.
- MOZ_MUST_USE bool readBytes(uint32_t numBytes, const uint8_t** bytes = nullptr) {
+ [[nodiscard]] bool readBytes(uint32_t numBytes, const uint8_t** bytes = nullptr) {
if (bytes)
*bytes = cur_;
if (bytesRemain() < numBytes)
@@ -417,7 +417,7 @@ class Decoder
static const uint32_t NotStarted = UINT32_MAX;
- MOZ_MUST_USE bool startSection(SectionId id,
+ [[nodiscard]] bool startSection(SectionId id,
uint32_t* startOffset,
uint32_t* size,
const char* sectionName)
@@ -451,7 +451,7 @@ class Decoder
fail:
return fail("failed to start %s section", sectionName);
}
- MOZ_MUST_USE bool finishSection(uint32_t startOffset, uint32_t size,
+ [[nodiscard]] bool finishSection(uint32_t startOffset, uint32_t size,
const char* sectionName)
{
if (size != (cur_ - beg_) - startOffset)
@@ -462,7 +462,7 @@ class Decoder
// "User sections" do not cause validation errors unless the error is in
// the user-defined section header itself.
- MOZ_MUST_USE bool startUserDefinedSection(const char* expectedId,
+ [[nodiscard]] bool startUserDefinedSection(const char* expectedId,
size_t expectedIdSize,
uint32_t* sectionStart,
uint32_t* sectionSize)
@@ -492,7 +492,7 @@ class Decoder
return fail("failed to start user-defined section");
}
template <size_t IdSizeWith0>
- MOZ_MUST_USE bool startUserDefinedSection(const char (&id)[IdSizeWith0],
+ [[nodiscard]] bool startUserDefinedSection(const char (&id)[IdSizeWith0],
uint32_t* sectionStart,
uint32_t* sectionSize)
{
@@ -506,7 +506,7 @@ class Decoder
MOZ_ASSERT(cur_ <= end_);
clearError();
}
- MOZ_MUST_USE bool skipUserDefinedSection() {
+ [[nodiscard]] bool skipUserDefinedSection() {
uint32_t sectionStart, sectionSize;
if (!startUserDefinedSection(nullptr, 0, &sectionStart, &sectionSize))
return false;
@@ -587,56 +587,56 @@ class Decoder
UniqueChars
DecodeName(Decoder& d);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeTableLimits(Decoder& d, TableDescVector* tables);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
GlobalIsJSCompatible(Decoder& d, ValType type, bool isMutable);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EncodeLocalEntries(Encoder& d, const ValTypeVector& locals);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeLocalEntries(Decoder& d, ModuleKind kind, ValTypeVector* locals);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeGlobalType(Decoder& d, ValType* type, bool* isMutable);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeInitializerExpression(Decoder& d, const GlobalDescVector& globals, ValType expected,
InitExpr* init);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeLimits(Decoder& d, Limits* limits);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeMemoryLimits(Decoder& d, bool hasMemory, Limits* memory);
// Section macros.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodePreamble(Decoder& d);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeTypeSection(Decoder& d, SigWithIdVector* sigs);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeImportSection(Decoder& d, const SigWithIdVector& sigs, Uint32Vector* funcSigIndices,
GlobalDescVector* globals, TableDescVector* tables, Maybe<Limits>* memory,
ImportVector* imports);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeFunctionSection(Decoder& d, const SigWithIdVector& sigs, size_t numImportedFunc,
Uint32Vector* funcSigIndexes);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeUnknownSections(Decoder& d);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeDataSection(Decoder& d, bool usesMemory, uint32_t minMemoryByteLength,
const GlobalDescVector& globals, DataSegmentVector* segments);
-MOZ_MUST_USE bool
+[[nodiscard]] bool
DecodeMemorySection(Decoder& d, bool hasMemory, Limits* memory, bool* present);
} // namespace wasm
diff --git a/js/src/wasm/WasmBinaryIterator.h b/js/src/wasm/WasmBinaryIterator.h
index ccad80f9dd..c5473ef42f 100644
--- a/js/src/wasm/WasmBinaryIterator.h
+++ b/js/src/wasm/WasmBinaryIterator.h
@@ -260,56 +260,56 @@ class MOZ_STACK_CLASS OpIter : private Policy
DebugOnly<Op> op_;
size_t offsetOfExpr_;
- MOZ_MUST_USE bool readFixedU8(uint8_t* out) {
+ [[nodiscard]] bool readFixedU8(uint8_t* out) {
if (Validate)
return d_.readFixedU8(out);
*out = d_.uncheckedReadFixedU8();
return true;
}
- MOZ_MUST_USE bool readFixedU32(uint32_t* out) {
+ [[nodiscard]] bool readFixedU32(uint32_t* out) {
if (Validate)
return d_.readFixedU32(out);
*out = d_.uncheckedReadFixedU32();
return true;
}
- MOZ_MUST_USE bool readVarS32(int32_t* out) {
+ [[nodiscard]] bool readVarS32(int32_t* out) {
if (Validate)
return d_.readVarS32(out);
*out = d_.uncheckedReadVarS32();
return true;
}
- MOZ_MUST_USE bool readVarU32(uint32_t* out) {
+ [[nodiscard]] bool readVarU32(uint32_t* out) {
if (Validate)
return d_.readVarU32(out);
*out = d_.uncheckedReadVarU32();
return true;
}
- MOZ_MUST_USE bool readVarS64(int64_t* out) {
+ [[nodiscard]] bool readVarS64(int64_t* out) {
if (Validate)
return d_.readVarS64(out);
*out = d_.uncheckedReadVarS64();
return true;
}
- MOZ_MUST_USE bool readVarU64(uint64_t* out) {
+ [[nodiscard]] bool readVarU64(uint64_t* out) {
if (Validate)
return d_.readVarU64(out);
*out = d_.uncheckedReadVarU64();
return true;
}
- MOZ_MUST_USE bool readFixedF32(RawF32* out) {
+ [[nodiscard]] bool readFixedF32(RawF32* out) {
if (Validate)
return d_.readFixedF32(out);
*out = d_.uncheckedReadFixedF32();
return true;
}
- MOZ_MUST_USE bool readFixedF64(RawF64* out) {
+ [[nodiscard]] bool readFixedF64(RawF64* out) {
if (Validate)
return d_.readFixedF64(out);
*out = d_.uncheckedReadFixedF64();
return true;
}
- MOZ_MUST_USE bool readAtomicViewType(Scalar::Type* viewType) {
+ [[nodiscard]] bool readAtomicViewType(Scalar::Type* viewType) {
uint8_t x;
if (!readFixedU8(&x))
return fail("unable to read atomic view");
@@ -319,7 +319,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
return true;
}
- MOZ_MUST_USE bool readAtomicBinOpOp(jit::AtomicOp* op) {
+ [[nodiscard]] bool readAtomicBinOpOp(jit::AtomicOp* op) {
uint8_t x;
if (!readFixedU8(&x))
return fail("unable to read atomic opcode");
@@ -339,23 +339,23 @@ class MOZ_STACK_CLASS OpIter : private Policy
return true;
}
- MOZ_MUST_USE bool readLinearMemoryAddress(uint32_t byteSize, LinearMemoryAddress<Value>* addr);
- MOZ_MUST_USE bool readBlockType(ExprType* expr);
+ [[nodiscard]] bool readLinearMemoryAddress(uint32_t byteSize, LinearMemoryAddress<Value>* addr);
+ [[nodiscard]] bool readBlockType(ExprType* expr);
- MOZ_MUST_USE bool typeMismatch(ExprType actual, ExprType expected) MOZ_COLD;
- MOZ_MUST_USE bool checkType(ValType actual, ValType expected);
- MOZ_MUST_USE bool checkType(ExprType actual, ExprType expected);
+ [[nodiscard]] bool typeMismatch(ExprType actual, ExprType expected) MOZ_COLD;
+ [[nodiscard]] bool checkType(ValType actual, ValType expected);
+ [[nodiscard]] bool checkType(ExprType actual, ExprType expected);
- MOZ_MUST_USE bool pushControl(LabelKind kind, ExprType type, bool reachable);
- MOZ_MUST_USE bool mergeControl(LabelKind* kind, ExprType* type, Value* value);
- MOZ_MUST_USE bool popControl(LabelKind* kind, ExprType* type, Value* value);
+ [[nodiscard]] bool pushControl(LabelKind kind, ExprType type, bool reachable);
+ [[nodiscard]] bool mergeControl(LabelKind* kind, ExprType* type, Value* value);
+ [[nodiscard]] bool popControl(LabelKind* kind, ExprType* type, Value* value);
- MOZ_MUST_USE bool push(ValType t) {
+ [[nodiscard]] bool push(ValType t) {
if (MOZ_UNLIKELY(!reachable_))
return true;
return valueStack_.emplaceBack(t);
}
- MOZ_MUST_USE bool push(TypeAndValue<Value> tv) {
+ [[nodiscard]] bool push(TypeAndValue<Value> tv) {
if (MOZ_UNLIKELY(!reachable_))
return true;
return valueStack_.append(tv);
@@ -372,7 +372,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Test whether reading the top of the value stack is currently valid.
- MOZ_MUST_USE bool checkTop() {
+ [[nodiscard]] bool checkTop() {
MOZ_ASSERT(reachable_);
if (Validate && valueStack_.length() <= controlStack_.back().valueStackStart()) {
if (valueStack_.empty())
@@ -383,7 +383,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Pop the top of the value stack.
- MOZ_MUST_USE bool pop(TypeAndValue<Value>* tv) {
+ [[nodiscard]] bool pop(TypeAndValue<Value>* tv) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -393,7 +393,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Pop the top of the value stack and check that it has the given type.
- MOZ_MUST_USE bool popWithType(ValType expectedType, Value* value) {
+ [[nodiscard]] bool popWithType(ValType expectedType, Value* value) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -407,7 +407,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Pop the top of the value stack and discard the result.
- MOZ_MUST_USE bool pop() {
+ [[nodiscard]] bool pop() {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -417,7 +417,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Read the top of the value stack (without popping it).
- MOZ_MUST_USE bool top(TypeAndValue<Value>* tv) {
+ [[nodiscard]] bool top(TypeAndValue<Value>* tv) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -428,7 +428,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
// Read the top of the value stack (without popping it) and check that it
// has the given type.
- MOZ_MUST_USE bool topWithType(ValType expectedType, Value* value) {
+ [[nodiscard]] bool topWithType(ValType expectedType, Value* value) {
if (MOZ_UNLIKELY(!reachable_))
return true;
if (!checkTop())
@@ -442,7 +442,7 @@ class MOZ_STACK_CLASS OpIter : private Policy
}
// Read the value stack entry at depth |index|.
- MOZ_MUST_USE bool peek(uint32_t index, TypeAndValue<Value>* tv) {
+ [[nodiscard]] bool peek(uint32_t index, TypeAndValue<Value>* tv) {
MOZ_ASSERT(reachable_);
if (Validate && valueStack_.length() - controlStack_.back().valueStackStart() < index)
return fail("peeking at value from outside block");
@@ -484,13 +484,13 @@ class MOZ_STACK_CLASS OpIter : private Policy
bool done() const { return d_.done(); }
// Report a general failure.
- MOZ_MUST_USE bool fail(const char* msg) MOZ_COLD;
+ [[nodiscard]] bool fail(const char* msg) MOZ_COLD;
// Report an unimplemented feature.
- MOZ_MUST_USE bool notYetImplemented(const char* what) MOZ_COLD;
+ [[nodiscard]] bool notYetImplemented(const char* what) MOZ_COLD;
// Report an unrecognized opcode.
- MOZ_MUST_USE bool unrecognizedOpcode(uint32_t expr) MOZ_COLD;
+ [[nodiscard]] bool unrecognizedOpcode(uint32_t expr) MOZ_COLD;
// Test whether the iterator is currently in "reachable" code.
bool inReachableCode() const { return reachable_; }
@@ -498,70 +498,70 @@ class MOZ_STACK_CLASS OpIter : private Policy
// ------------------------------------------------------------------------
// Decoding and validation interface.
- MOZ_MUST_USE bool readOp(uint16_t* op);
- MOZ_MUST_USE bool readFunctionStart(ExprType ret);
- MOZ_MUST_USE bool readFunctionEnd();
- MOZ_MUST_USE bool readReturn(Value* value);
- MOZ_MUST_USE bool readBlock();
- MOZ_MUST_USE bool readLoop();
- MOZ_MUST_USE bool readIf(Value* condition);
- MOZ_MUST_USE bool readElse(ExprType* thenType, Value* thenValue);
- MOZ_MUST_USE bool readEnd(LabelKind* kind, ExprType* type, Value* value);
- MOZ_MUST_USE bool readBr(uint32_t* relativeDepth, ExprType* type, Value* value);
- MOZ_MUST_USE bool readBrIf(uint32_t* relativeDepth, ExprType* type,
+ [[nodiscard]] bool readOp(uint16_t* op);
+ [[nodiscard]] bool readFunctionStart(ExprType ret);
+ [[nodiscard]] bool readFunctionEnd();
+ [[nodiscard]] bool readReturn(Value* value);
+ [[nodiscard]] bool readBlock();
+ [[nodiscard]] bool readLoop();
+ [[nodiscard]] bool readIf(Value* condition);
+ [[nodiscard]] bool readElse(ExprType* thenType, Value* thenValue);
+ [[nodiscard]] bool readEnd(LabelKind* kind, ExprType* type, Value* value);
+ [[nodiscard]] bool readBr(uint32_t* relativeDepth, ExprType* type, Value* value);
+ [[nodiscard]] bool readBrIf(uint32_t* relativeDepth, ExprType* type,
Value* value, Value* condition);
- MOZ_MUST_USE bool readBrTable(uint32_t* tableLength, ExprType* type,
+ [[nodiscard]] bool readBrTable(uint32_t* tableLength, ExprType* type,
Value* value, Value* index);
- MOZ_MUST_USE bool readBrTableEntry(ExprType* type, Value* value, uint32_t* depth);
- MOZ_MUST_USE bool readBrTableDefault(ExprType* type, Value* value, uint32_t* depth);
- MOZ_MUST_USE bool readUnreachable();
- MOZ_MUST_USE bool readDrop();
- MOZ_MUST_USE bool readUnary(ValType operandType, Value* input);
- MOZ_MUST_USE bool readConversion(ValType operandType, ValType resultType, Value* input);
- MOZ_MUST_USE bool readBinary(ValType operandType, Value* lhs, Value* rhs);
- MOZ_MUST_USE bool readComparison(ValType operandType, Value* lhs, Value* rhs);
- MOZ_MUST_USE bool readLoad(ValType resultType, uint32_t byteSize,
+ [[nodiscard]] bool readBrTableEntry(ExprType* type, Value* value, uint32_t* depth);
+ [[nodiscard]] bool readBrTableDefault(ExprType* type, Value* value, uint32_t* depth);
+ [[nodiscard]] bool readUnreachable();
+ [[nodiscard]] bool readDrop();
+ [[nodiscard]] bool readUnary(ValType operandType, Value* input);
+ [[nodiscard]] bool readConversion(ValType operandType, ValType resultType, Value* input);
+ [[nodiscard]] bool readBinary(ValType operandType, Value* lhs, Value* rhs);
+ [[nodiscard]] bool readComparison(ValType operandType, Value* lhs, Value* rhs);
+ [[nodiscard]] bool readLoad(ValType resultType, uint32_t byteSize,
LinearMemoryAddress<Value>* addr);
- MOZ_MUST_USE bool readStore(ValType resultType, uint32_t byteSize,
+ [[nodiscard]] bool readStore(ValType resultType, uint32_t byteSize,
LinearMemoryAddress<Value>* addr, Value* value);
- MOZ_MUST_USE bool readTeeStore(ValType resultType, uint32_t byteSize,
+ [[nodiscard]] bool readTeeStore(ValType resultType, uint32_t byteSize,
LinearMemoryAddress<Value>* addr, Value* value);
- MOZ_MUST_USE bool readNop();
- MOZ_MUST_USE bool readCurrentMemory();
- MOZ_MUST_USE bool readGrowMemory(Value* input);
- MOZ_MUST_USE bool readSelect(ValType* type,
+ [[nodiscard]] bool readNop();
+ [[nodiscard]] bool readCurrentMemory();
+ [[nodiscard]] bool readGrowMemory(Value* input);
+ [[nodiscard]] bool readSelect(ValType* type,
Value* trueValue, Value* falseValue, Value* condition);
- MOZ_MUST_USE bool readGetLocal(const ValTypeVector& locals, uint32_t* id);
- MOZ_MUST_USE bool readSetLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readTeeLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readGetGlobal(const GlobalDescVector& globals, uint32_t* id);
- MOZ_MUST_USE bool readSetGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readTeeGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
- MOZ_MUST_USE bool readI32Const(int32_t* i32);
- MOZ_MUST_USE bool readI64Const(int64_t* i64);
- MOZ_MUST_USE bool readF32Const(RawF32* f32);
- MOZ_MUST_USE bool readF64Const(RawF64* f64);
- MOZ_MUST_USE bool readCall(uint32_t* calleeIndex);
- MOZ_MUST_USE bool readCallIndirect(uint32_t* sigIndex, Value* callee);
- MOZ_MUST_USE bool readOldCallIndirect(uint32_t* sigIndex);
- MOZ_MUST_USE bool readCallArg(ValType type, uint32_t numArgs, uint32_t argIndex, Value* arg);
- MOZ_MUST_USE bool readCallArgsEnd(uint32_t numArgs);
- MOZ_MUST_USE bool readOldCallIndirectCallee(Value* callee);
- MOZ_MUST_USE bool readCallReturn(ExprType ret);
- MOZ_MUST_USE bool readAtomicLoad(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readGetLocal(const ValTypeVector& locals, uint32_t* id);
+ [[nodiscard]] bool readSetLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readTeeLocal(const ValTypeVector& locals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readGetGlobal(const GlobalDescVector& globals, uint32_t* id);
+ [[nodiscard]] bool readSetGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readTeeGlobal(const GlobalDescVector& globals, uint32_t* id, Value* value);
+ [[nodiscard]] bool readI32Const(int32_t* i32);
+ [[nodiscard]] bool readI64Const(int64_t* i64);
+ [[nodiscard]] bool readF32Const(RawF32* f32);
+ [[nodiscard]] bool readF64Const(RawF64* f64);
+ [[nodiscard]] bool readCall(uint32_t* calleeIndex);
+ [[nodiscard]] bool readCallIndirect(uint32_t* sigIndex, Value* callee);
+ [[nodiscard]] bool readOldCallIndirect(uint32_t* sigIndex);
+ [[nodiscard]] bool readCallArg(ValType type, uint32_t numArgs, uint32_t argIndex, Value* arg);
+ [[nodiscard]] bool readCallArgsEnd(uint32_t numArgs);
+ [[nodiscard]] bool readOldCallIndirectCallee(Value* callee);
+ [[nodiscard]] bool readCallReturn(ExprType ret);
+ [[nodiscard]] bool readAtomicLoad(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType);
- MOZ_MUST_USE bool readAtomicStore(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicStore(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
Value* value);
- MOZ_MUST_USE bool readAtomicBinOp(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicBinOp(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
jit::AtomicOp* op,
Value* value);
- MOZ_MUST_USE bool readAtomicCompareExchange(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicCompareExchange(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
Value* oldValue,
Value* newValue);
- MOZ_MUST_USE bool readAtomicExchange(LinearMemoryAddress<Value>* addr,
+ [[nodiscard]] bool readAtomicExchange(LinearMemoryAddress<Value>* addr,
Scalar::Type* viewType,
Value* newValue);
diff --git a/js/src/wasm/WasmBinaryToAST.cpp b/js/src/wasm/WasmBinaryToAST.cpp
index 8d6db7b357..80bec9df46 100644
--- a/js/src/wasm/WasmBinaryToAST.cpp
+++ b/js/src/wasm/WasmBinaryToAST.cpp
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -150,7 +151,7 @@ class AstDecodeContext
void popBack() { return exprs().popBack(); }
AstDecodeStackItem popCopy() { return exprs().popCopy(); }
AstDecodeStackItem& top() { return exprs().back(); }
- MOZ_MUST_USE bool push(AstDecodeStackItem item) { return exprs().append(item); }
+ [[nodiscard]] bool push(AstDecodeStackItem item) { return exprs().append(item); }
bool needFirst() {
for (size_t i = depths().back(); i < exprs().length(); ++i) {
diff --git a/js/src/wasm/WasmBinaryToExperimentalText.h b/js/src/wasm/WasmBinaryToExperimentalText.h
index 6c77c583cb..a93a05eda0 100644
--- a/js/src/wasm/WasmBinaryToExperimentalText.h
+++ b/js/src/wasm/WasmBinaryToExperimentalText.h
@@ -46,7 +46,7 @@ struct ExperimentalTextFormatting
// Translate the given binary representation of a wasm module into the module's textual
// representation.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BinaryToExperimentalText(JSContext* cx, const uint8_t* bytes, size_t length, StringBuffer& buffer,
const ExperimentalTextFormatting& formatting = ExperimentalTextFormatting(),
GeneratedSourceMap* sourceMap = nullptr);
diff --git a/js/src/wasm/WasmBinaryToText.h b/js/src/wasm/WasmBinaryToText.h
index 1674bdcd48..e2c4e530c3 100644
--- a/js/src/wasm/WasmBinaryToText.h
+++ b/js/src/wasm/WasmBinaryToText.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +34,7 @@ namespace wasm {
// Translate the given binary representation of a wasm module into the module's textual
// representation.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
BinaryToText(JSContext* cx, const uint8_t* bytes, size_t length, StringBuffer& buffer,
GeneratedSourceMap* sourceMap = nullptr);
diff --git a/js/src/wasm/WasmCode.h b/js/src/wasm/WasmCode.h
index c6f1ace02e..1254fd9d7c 100644
--- a/js/src/wasm/WasmCode.h
+++ b/js/src/wasm/WasmCode.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -530,7 +531,7 @@ class Code
// asynchronously walk the stack. Otherwise, the ProfilingFrameIterator will
// skip any activations of this code.
- MOZ_MUST_USE bool ensureProfilingState(JSContext* cx, bool enabled);
+ [[nodiscard]] bool ensureProfilingState(JSContext* cx, bool enabled);
bool profilingEnabled() const { return profilingEnabled_; }
const char* profilingLabel(uint32_t funcIndex) const { return funcLabels_[funcIndex].get(); }
diff --git a/js/src/wasm/WasmGenerator.h b/js/src/wasm/WasmGenerator.h
index 85b23664a2..377898d6c7 100644
--- a/js/src/wasm/WasmGenerator.h
+++ b/js/src/wasm/WasmGenerator.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -116,22 +117,22 @@ class MOZ_STACK_CLASS ModuleGenerator
bool funcIsCompiled(uint32_t funcIndex) const;
const CodeRange& funcCodeRange(uint32_t funcIndex) const;
- MOZ_MUST_USE bool patchCallSites(TrapExitOffsetArray* maybeTrapExits = nullptr);
- MOZ_MUST_USE bool patchFarJumps(const TrapExitOffsetArray& trapExits);
- MOZ_MUST_USE bool finishTask(IonCompileTask* task);
- MOZ_MUST_USE bool finishOutstandingTask();
- MOZ_MUST_USE bool finishFuncExports();
- MOZ_MUST_USE bool finishCodegen();
- MOZ_MUST_USE bool finishLinkData(Bytes& code);
- MOZ_MUST_USE bool addFuncImport(const Sig& sig, uint32_t globalDataOffset);
- MOZ_MUST_USE bool allocateGlobalBytes(uint32_t bytes, uint32_t align, uint32_t* globalDataOff);
- MOZ_MUST_USE bool allocateGlobal(GlobalDesc* global);
+ [[nodiscard]] bool patchCallSites(TrapExitOffsetArray* maybeTrapExits = nullptr);
+ [[nodiscard]] bool patchFarJumps(const TrapExitOffsetArray& trapExits);
+ [[nodiscard]] bool finishTask(IonCompileTask* task);
+ [[nodiscard]] bool finishOutstandingTask();
+ [[nodiscard]] bool finishFuncExports();
+ [[nodiscard]] bool finishCodegen();
+ [[nodiscard]] bool finishLinkData(Bytes& code);
+ [[nodiscard]] bool addFuncImport(const Sig& sig, uint32_t globalDataOffset);
+ [[nodiscard]] bool allocateGlobalBytes(uint32_t bytes, uint32_t align, uint32_t* globalDataOff);
+ [[nodiscard]] bool allocateGlobal(GlobalDesc* global);
public:
explicit ModuleGenerator(ImportVector&& imports);
~ModuleGenerator();
- MOZ_MUST_USE bool init(UniqueModuleGeneratorData shared, const CompileArgs& args,
+ [[nodiscard]] bool init(UniqueModuleGeneratorData shared, const CompileArgs& args,
Metadata* maybeAsmJSMetadata = nullptr);
bool isAsmJS() const { return metadata_->kind == ModuleKind::AsmJS; }
@@ -159,23 +160,23 @@ class MOZ_STACK_CLASS ModuleGenerator
uint32_t numFuncs() const;
// Exports:
- MOZ_MUST_USE bool addFuncExport(UniqueChars fieldName, uint32_t funcIndex);
- MOZ_MUST_USE bool addTableExport(UniqueChars fieldName);
- MOZ_MUST_USE bool addMemoryExport(UniqueChars fieldName);
- MOZ_MUST_USE bool addGlobalExport(UniqueChars fieldName, uint32_t globalIndex);
+ [[nodiscard]] bool addFuncExport(UniqueChars fieldName, uint32_t funcIndex);
+ [[nodiscard]] bool addTableExport(UniqueChars fieldName);
+ [[nodiscard]] bool addMemoryExport(UniqueChars fieldName);
+ [[nodiscard]] bool addGlobalExport(UniqueChars fieldName, uint32_t globalIndex);
// Function definitions:
- MOZ_MUST_USE bool startFuncDefs();
- MOZ_MUST_USE bool startFuncDef(uint32_t lineOrBytecode, FunctionGenerator* fg);
- MOZ_MUST_USE bool finishFuncDef(uint32_t funcIndex, FunctionGenerator* fg);
- MOZ_MUST_USE bool finishFuncDefs();
+ [[nodiscard]] bool startFuncDefs();
+ [[nodiscard]] bool startFuncDef(uint32_t lineOrBytecode, FunctionGenerator* fg);
+ [[nodiscard]] bool finishFuncDef(uint32_t funcIndex, FunctionGenerator* fg);
+ [[nodiscard]] bool finishFuncDefs();
// Start function:
bool setStartFunction(uint32_t funcIndex);
// Segments:
void setDataSegments(DataSegmentVector&& segments);
- MOZ_MUST_USE bool addElemSegment(InitExpr offset, Uint32Vector&& elemFuncIndices);
+ [[nodiscard]] bool addElemSegment(InitExpr offset, Uint32Vector&& elemFuncIndices);
// Function names:
void setFuncNames(NameInBytecodeVector&& funcNames);
@@ -183,12 +184,12 @@ class MOZ_STACK_CLASS ModuleGenerator
// asm.js lazy initialization:
void initSig(uint32_t sigIndex, Sig&& sig);
void initFuncSig(uint32_t funcIndex, uint32_t sigIndex);
- MOZ_MUST_USE bool initImport(uint32_t funcIndex, uint32_t sigIndex);
- MOZ_MUST_USE bool initSigTableLength(uint32_t sigIndex, uint32_t length);
- MOZ_MUST_USE bool initSigTableElems(uint32_t sigIndex, Uint32Vector&& elemFuncIndices);
+ [[nodiscard]] bool initImport(uint32_t funcIndex, uint32_t sigIndex);
+ [[nodiscard]] bool initSigTableLength(uint32_t sigIndex, uint32_t length);
+ [[nodiscard]] bool initSigTableElems(uint32_t sigIndex, Uint32Vector&& elemFuncIndices);
void initMemoryUsage(MemoryUsage memoryUsage);
void bumpMinMemoryLength(uint32_t newMinMemoryLength);
- MOZ_MUST_USE bool addGlobal(ValType type, bool isConst, uint32_t* index);
+ [[nodiscard]] bool addGlobal(ValType type, bool isConst, uint32_t* index);
// Finish compilation, provided the list of imports and source bytecode.
// Both these Vectors may be empty (viz., b/c asm.js does different things
@@ -240,7 +241,7 @@ class MOZ_STACK_CLASS FunctionGenerator
Bytes& bytes() {
return bytes_;
}
- MOZ_MUST_USE bool addCallSiteLineNum(uint32_t lineno) {
+ [[nodiscard]] bool addCallSiteLineNum(uint32_t lineno) {
return callSiteLineNums_.append(lineno);
}
};
diff --git a/js/src/wasm/WasmInstance.h b/js/src/wasm/WasmInstance.h
index 5c2871259c..523a08c31d 100644
--- a/js/src/wasm/WasmInstance.h
+++ b/js/src/wasm/WasmInstance.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -99,7 +100,7 @@ class Instance
// Execute the given export given the JS call arguments, storing the return
// value in args.rval.
- MOZ_MUST_USE bool callExport(JSContext* cx, uint32_t funcIndex, CallArgs args);
+ [[nodiscard]] bool callExport(JSContext* cx, uint32_t funcIndex, CallArgs args);
// Initially, calls to imports in wasm code call out through the generic
// callImport method. If the imported callee gets JIT compiled and the types
@@ -121,7 +122,7 @@ class Instance
// See Code::ensureProfilingState comment.
- MOZ_MUST_USE bool ensureProfilingState(JSContext* cx, bool enabled);
+ [[nodiscard]] bool ensureProfilingState(JSContext* cx, bool enabled);
// about:memory reporting:
diff --git a/js/src/wasm/WasmIonCompile.h b/js/src/wasm/WasmIonCompile.h
index dcd5c3c633..90f81643ec 100644
--- a/js/src/wasm/WasmIonCompile.h
+++ b/js/src/wasm/WasmIonCompile.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -146,7 +147,7 @@ class IonCompileTask
}
};
-MOZ_MUST_USE bool
+[[nodiscard]] bool
IonCompileFunction(IonCompileTask* task);
bool
diff --git a/js/src/wasm/WasmJS.h b/js/src/wasm/WasmJS.h
index ee1332102f..1ae4714f06 100644
--- a/js/src/wasm/WasmJS.h
+++ b/js/src/wasm/WasmJS.h
@@ -74,7 +74,7 @@ HasSupport(ExclusiveContext* cx);
// Compiles the given binary wasm module given the ArrayBufferObject
// and links the module's imports with the given import object.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
Eval(JSContext* cx, Handle<TypedArrayObject*> code, HandleObject importObj,
MutableHandleWasmInstanceObject instanceObj);
diff --git a/js/src/wasm/WasmSignalHandlers.h b/js/src/wasm/WasmSignalHandlers.h
index 87faa15025..40ebfeb2e2 100644
--- a/js/src/wasm/WasmSignalHandlers.h
+++ b/js/src/wasm/WasmSignalHandlers.h
@@ -38,7 +38,7 @@ namespace wasm {
// Ensure the given JSRuntime is set up to use signals. Failure to enable signal
// handlers indicates some catastrophic failure and creation of the runtime must
// fail.
-MOZ_MUST_USE bool
+[[nodiscard]] bool
EnsureSignalHandlers(JSRuntime* rt);
// Return whether signals can be used in this process for interrupts or
diff --git a/js/src/wasm/WasmTextToBinary.h b/js/src/wasm/WasmTextToBinary.h
index 1d16517586..7e5dce6db9 100644
--- a/js/src/wasm/WasmTextToBinary.h
+++ b/js/src/wasm/WasmTextToBinary.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2015 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,7 +28,7 @@ namespace wasm {
// null-terminated char16_t array) into serialized bytes. If there is an error
// other than out-of-memory an error message string will be stored in 'error'.
-extern MOZ_MUST_USE bool
+[[nodiscard]] extern bool
TextToBinary(const char16_t* text, Bytes* bytes, UniqueChars* error);
} // namespace wasm
diff --git a/js/src/wasm/WasmTextUtils.cpp b/js/src/wasm/WasmTextUtils.cpp
index 197a211f19..b09504fa2b 100644
--- a/js/src/wasm/WasmTextUtils.cpp
+++ b/js/src/wasm/WasmTextUtils.cpp
@@ -73,5 +73,5 @@ js::wasm::RenderNaN(StringBuffer& sb, Raw<T> num)
RenderInBase<16>(sb, payload);
}
-template MOZ_MUST_USE bool js::wasm::RenderNaN(StringBuffer& b, Raw<float> num);
-template MOZ_MUST_USE bool js::wasm::RenderNaN(StringBuffer& b, Raw<double> num);
+template [[nodiscard]] bool js::wasm::RenderNaN(StringBuffer& b, Raw<float> num);
+template [[nodiscard]] bool js::wasm::RenderNaN(StringBuffer& b, Raw<double> num);
diff --git a/js/src/wasm/WasmTextUtils.h b/js/src/wasm/WasmTextUtils.h
index d772e621cd..a154681da9 100644
--- a/js/src/wasm/WasmTextUtils.h
+++ b/js/src/wasm/WasmTextUtils.h
@@ -1,6 +1,7 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* Copyright 2016 Mozilla Foundation
+ * Copyright 2023 Moonchild Productions
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -27,14 +28,14 @@ class StringBuffer;
namespace wasm {
template<size_t base>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RenderInBase(StringBuffer& sb, uint64_t num);
template<class T>
class Raw;
template<class T>
-MOZ_MUST_USE bool
+[[nodiscard]] bool
RenderNaN(StringBuffer& sb, Raw<T> num);
} // namespace wasm
diff --git a/js/src/wasm/WasmTypes.h b/js/src/wasm/WasmTypes.h
index 57c737e454..26112ed137 100644
--- a/js/src/wasm/WasmTypes.h
+++ b/js/src/wasm/WasmTypes.h
@@ -316,7 +316,7 @@ class Sig
Sig() : args_(), ret_(ExprType::Void) {}
Sig(ValTypeVector&& args, ExprType ret) : args_(Move(args)), ret_(ret) {}
- MOZ_MUST_USE bool clone(const Sig& rhs) {
+ [[nodiscard]] bool clone(const Sig& rhs) {
ret_ = rhs.ret_;
MOZ_ASSERT(args_.empty());
return args_.appendAll(rhs.args_);
diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp
index f4f3297469..f8af02ac0d 100644
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -255,7 +255,7 @@ class MOZ_STACK_CLASS ComponentLoaderInfo {
return mResolvedURI->GetSpec(*mKey);
}
- MOZ_MUST_USE nsresult GetLocation(nsCString& aLocation) {
+ [[nodiscard]] nsresult GetLocation(nsCString& aLocation) {
nsresult rv = EnsureURI();
NS_ENSURE_SUCCESS(rv, rv);
return mURI->GetSpec(aLocation);