summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xpcom/base/nsGZFileWriter.h4
-rw-r--r--xpcom/base/nsIGZFileWriter.idl4
-rw-r--r--xpcom/base/nsIMemoryReporter.idl20
-rw-r--r--xpcom/base/nsMemoryReporterManager.cpp66
-rw-r--r--xpcom/base/nsMemoryReporterManager.h8
-rw-r--r--xpcom/ds/IncrementalTokenizer.h3
-rw-r--r--xpcom/ds/Tokenizer.h50
-rw-r--r--xpcom/ds/nsISupportsArray.idl2
-rw-r--r--xpcom/ds/nsObserverList.h4
-rw-r--r--xpcom/ds/nsObserverService.h4
-rw-r--r--xpcom/ds/nsPersistentProperties.h2
-rw-r--r--xpcom/ds/nsStringEnumerator.h12
-rw-r--r--xpcom/ds/nsSupportsArray.h18
-rw-r--r--xpcom/ds/nsVariant.h72
-rw-r--r--xpcom/ds/nsWindowsRegKey.h6
-rw-r--r--xpcom/glue/nsBaseHashtable.h4
-rw-r--r--xpcom/glue/nsDebug.h6
-rw-r--r--xpcom/glue/nsDeque.h4
-rw-r--r--xpcom/glue/nsInterfaceHashtable.h4
-rw-r--r--xpcom/glue/nsRefPtrHashtable.h4
-rw-r--r--xpcom/glue/nsTArray.h48
-rw-r--r--xpcom/glue/nsTHashtable.h6
-rw-r--r--xpcom/idl-parser/xpidl/header.py4
-rw-r--r--xpcom/io/Base64.h20
-rw-r--r--xpcom/io/nsIPipe.idl4
-rw-r--r--xpcom/string/nsReadableUtils.h10
-rw-r--r--xpcom/string/nsTString.h4
-rw-r--r--xpcom/string/nsTSubstring.h52
28 files changed, 216 insertions, 229 deletions
diff --git a/xpcom/base/nsGZFileWriter.h b/xpcom/base/nsGZFileWriter.h
index e1ba9c8152..ad2ea04fba 100644
--- a/xpcom/base/nsGZFileWriter.h
+++ b/xpcom/base/nsGZFileWriter.h
@@ -34,12 +34,12 @@ public:
* duplicate them here so that you can call these overloads on a pointer to
* the concrete nsGZFileWriter class.
*/
- MOZ_MUST_USE nsresult Write(const char* aStr)
+ [[nodiscard]] nsresult Write(const char* aStr)
{
return nsIGZFileWriter::Write(aStr);
}
- MOZ_MUST_USE nsresult Write(const char* aStr, uint32_t aLen)
+ [[nodiscard]] nsresult Write(const char* aStr, uint32_t aLen)
{
return nsIGZFileWriter::Write(aStr, aLen);
}
diff --git a/xpcom/base/nsIGZFileWriter.idl b/xpcom/base/nsIGZFileWriter.idl
index ad7a32d85d..5179fafec1 100644
--- a/xpcom/base/nsIGZFileWriter.idl
+++ b/xpcom/base/nsIGZFileWriter.idl
@@ -55,7 +55,7 @@ interface nsIGZFileWriter : nsISupports
/**
* Write the given char* to the file (not including the null-terminator).
*/
- MOZ_MUST_USE nsresult Write(const char* str)
+ [[nodiscard]] nsresult Write(const char* str)
{
return Write(str, strlen(str));
}
@@ -63,7 +63,7 @@ interface nsIGZFileWriter : nsISupports
/**
* Write |length| bytes of |str| to the file.
*/
- MOZ_MUST_USE nsresult Write(const char* str, uint32_t len)
+ [[nodiscard]] nsresult Write(const char* str, uint32_t len)
{
return Write(nsDependentCString(str, len));
}
diff --git a/xpcom/base/nsIMemoryReporter.idl b/xpcom/base/nsIMemoryReporter.idl
index 5e2c079db5..7b63cf9dde 100644
--- a/xpcom/base/nsIMemoryReporter.idl
+++ b/xpcom/base/nsIMemoryReporter.idl
@@ -442,7 +442,7 @@ typedef nsIMemoryReporterCallback nsIHandleReportCallback;
namespace mozilla {
// All the following registration/unregistration functions don't use
-// MOZ_MUST_USE because ignoring failures is common and reasonable.
+// [[nodiscard]] because ignoring failures is common and reasonable.
// Register a memory reporter. The manager service will hold a strong
// reference to this reporter.
@@ -494,15 +494,15 @@ DECL_REGISTER_DISTINGUISHED_AMOUNT(Infallible, GhostWindows)
// Likewise for per-tab measurement.
-typedef MOZ_MUST_USE nsresult (*JSSizeOfTabFn)(JSObject* aObj,
- size_t* aJsObjectsSize,
- size_t* aJsStringSize,
- size_t* aJsPrivateSize,
- size_t* aJsOtherSize);
-typedef MOZ_MUST_USE nsresult (*NonJSSizeOfTabFn)(nsPIDOMWindowOuter* aWindow,
- size_t* aDomSize,
- size_t* aStyleSize,
- size_t* aOtherSize);
+typedef nsresult (*JSSizeOfTabFn)(JSObject* aObj,
+ size_t* aJsObjectsSize,
+ size_t* aJsStringSize,
+ size_t* aJsPrivateSize,
+ size_t* aJsOtherSize);
+typedef nsresult (*NonJSSizeOfTabFn)(nsPIDOMWindowOuter* aWindow,
+ size_t* aDomSize,
+ size_t* aStyleSize,
+ size_t* aOtherSize);
nsresult RegisterJSSizeOfTab(JSSizeOfTabFn aSizeOfTabFn);
nsresult RegisterNonJSSizeOfTab(NonJSSizeOfTabFn aSizeOfTabFn);
diff --git a/xpcom/base/nsMemoryReporterManager.cpp b/xpcom/base/nsMemoryReporterManager.cpp
index c47d3c8415..850886947d 100644
--- a/xpcom/base/nsMemoryReporterManager.cpp
+++ b/xpcom/base/nsMemoryReporterManager.cpp
@@ -50,7 +50,7 @@ using namespace mozilla;
#include <string.h>
#include <stdlib.h>
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
GetProcSelfStatmField(int aField, int64_t* aN)
{
// There are more than two fields, but we're only interested in the first
@@ -70,7 +70,7 @@ GetProcSelfStatmField(int aField, int64_t* aN)
return NS_ERROR_FAILURE;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
GetProcSelfSmapsPrivate(int64_t* aN)
{
// You might be tempted to calculate USS by subtracting the "shared" value
@@ -125,26 +125,26 @@ GetProcSelfSmapsPrivate(int64_t* aN)
}
#define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
VsizeDistinguishedAmount(int64_t* aN)
{
return GetProcSelfStatmField(0, aN);
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentDistinguishedAmount(int64_t* aN)
{
return GetProcSelfStatmField(1, aN);
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentFastDistinguishedAmount(int64_t* aN)
{
return ResidentDistinguishedAmount(aN);
}
#define HAVE_RESIDENT_UNIQUE_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentUniqueDistinguishedAmount(int64_t* aN)
{
return GetProcSelfSmapsPrivate(aN);
@@ -152,7 +152,7 @@ ResidentUniqueDistinguishedAmount(int64_t* aN)
#ifdef HAVE_MALLINFO
#define HAVE_SYSTEM_HEAP_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
SystemHeapSize(int64_t* aSizeOut)
{
struct mallinfo info = mallinfo();
@@ -207,7 +207,7 @@ SystemHeapSize(int64_t* aSizeOut)
#define KP_RSS(kp) (kp.p_vm_rssize * getpagesize())
#endif
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
GetKinfoProcSelf(KINFO_PROC* aProc)
{
int mib[] = {
@@ -229,7 +229,7 @@ GetKinfoProcSelf(KINFO_PROC* aProc)
}
#define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
VsizeDistinguishedAmount(int64_t* aN)
{
KINFO_PROC proc;
@@ -240,7 +240,7 @@ VsizeDistinguishedAmount(int64_t* aN)
return rv;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentDistinguishedAmount(int64_t* aN)
{
KINFO_PROC proc;
@@ -251,7 +251,7 @@ ResidentDistinguishedAmount(int64_t* aN)
return rv;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentFastDistinguishedAmount(int64_t* aN)
{
return ResidentDistinguishedAmount(aN);
@@ -261,7 +261,7 @@ ResidentFastDistinguishedAmount(int64_t* aN)
#include <libutil.h>
#include <algorithm>
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
GetKinfoVmentrySelf(int64_t* aPrss, uint64_t* aMaxreg)
{
int cnt;
@@ -292,7 +292,7 @@ GetKinfoVmentrySelf(int64_t* aPrss, uint64_t* aMaxreg)
}
#define HAVE_PRIVATE_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
PrivateDistinguishedAmount(int64_t* aN)
{
int64_t priv;
@@ -303,7 +303,7 @@ PrivateDistinguishedAmount(int64_t* aN)
}
#define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
VsizeMaxContiguousDistinguishedAmount(int64_t* aN)
{
uint64_t biggestRegion;
@@ -364,7 +364,7 @@ XMappingIter(int64_t& aVsize, int64_t& aResident)
}
#define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
VsizeDistinguishedAmount(int64_t* aN)
{
int64_t vsize, resident;
@@ -376,7 +376,7 @@ VsizeDistinguishedAmount(int64_t* aN)
return NS_OK;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentDistinguishedAmount(int64_t* aN)
{
int64_t vsize, resident;
@@ -388,7 +388,7 @@ ResidentDistinguishedAmount(int64_t* aN)
return NS_OK;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentFastDistinguishedAmount(int64_t* aN)
{
return ResidentDistinguishedAmount(aN);
@@ -402,7 +402,7 @@ ResidentFastDistinguishedAmount(int64_t* aN)
#include <mach/task.h>
#include <sys/sysctl.h>
-static MOZ_MUST_USE bool
+[[nodiscard]] static bool
GetTaskBasicInfo(struct task_basic_info* aTi)
{
mach_msg_type_number_t count = TASK_BASIC_INFO_COUNT;
@@ -415,7 +415,7 @@ GetTaskBasicInfo(struct task_basic_info* aTi)
// absurdly high, eg. 2GB+ even at start-up. But both 'top' and 'ps' report
// it, so we might as well too.
#define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
VsizeDistinguishedAmount(int64_t* aN)
{
task_basic_info ti;
@@ -433,7 +433,7 @@ VsizeDistinguishedAmount(int64_t* aN)
//
// Purging these pages can take a long time for some users (see bug 789975),
// so we provide the option to get the RSS without purging first.
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentDistinguishedAmountHelper(int64_t* aN, bool aDoPurge)
{
#ifdef HAVE_JEMALLOC_STATS
@@ -450,13 +450,13 @@ ResidentDistinguishedAmountHelper(int64_t* aN, bool aDoPurge)
return NS_OK;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentFastDistinguishedAmount(int64_t* aN)
{
return ResidentDistinguishedAmountHelper(aN, /* doPurge = */ false);
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentDistinguishedAmount(int64_t* aN)
{
return ResidentDistinguishedAmountHelper(aN, /* doPurge = */ true);
@@ -490,7 +490,7 @@ InSharedRegion(mach_vm_address_t aAddr, cpu_type_t aType)
return base <= aAddr && aAddr < (base + size);
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentUniqueDistinguishedAmount(int64_t* aN)
{
if (!aN) {
@@ -563,7 +563,7 @@ ResidentUniqueDistinguishedAmount(int64_t* aN)
#include <algorithm>
#define HAVE_VSIZE_AND_RESIDENT_REPORTERS 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
VsizeDistinguishedAmount(int64_t* aN)
{
MEMORYSTATUSEX s;
@@ -577,7 +577,7 @@ VsizeDistinguishedAmount(int64_t* aN)
return NS_OK;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentDistinguishedAmount(int64_t* aN)
{
PROCESS_MEMORY_COUNTERS pmc;
@@ -591,7 +591,7 @@ ResidentDistinguishedAmount(int64_t* aN)
return NS_OK;
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentFastDistinguishedAmount(int64_t* aN)
{
return ResidentDistinguishedAmount(aN);
@@ -599,7 +599,7 @@ ResidentFastDistinguishedAmount(int64_t* aN)
#define HAVE_RESIDENT_UNIQUE_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentUniqueDistinguishedAmount(int64_t* aN)
{
// Determine how many entries we need.
@@ -647,7 +647,7 @@ ResidentUniqueDistinguishedAmount(int64_t* aN)
}
#define HAVE_VSIZE_MAX_CONTIGUOUS_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
VsizeMaxContiguousDistinguishedAmount(int64_t* aN)
{
SIZE_T biggestRegion = 0;
@@ -676,7 +676,7 @@ VsizeMaxContiguousDistinguishedAmount(int64_t* aN)
}
#define HAVE_PRIVATE_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
PrivateDistinguishedAmount(int64_t* aN)
{
PROCESS_MEMORY_COUNTERS_EX pmcex;
@@ -695,7 +695,7 @@ PrivateDistinguishedAmount(int64_t* aN)
// Windows can have multiple separate heaps. During testing there were multiple
// heaps present but the non-default ones had sizes no more than a few 10s of
// KiBs. So we combine their sizes into a single measurement.
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
SystemHeapSize(int64_t* aSizeOut)
{
// Get the number of heaps.
@@ -1136,7 +1136,7 @@ NS_IMPL_ISUPPORTS(SystemHeapReporter, nsIMemoryReporter)
#define HAVE_RESIDENT_PEAK_REPORTER 1
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
ResidentPeakDistinguishedAmount(int64_t* aN)
{
struct rusage usage;
@@ -1214,7 +1214,7 @@ public:
};
NS_IMPL_ISUPPORTS(PageFaultsSoftReporter, nsIMemoryReporter)
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
PageFaultsHardDistinguishedAmount(int64_t* aAmount)
{
struct rusage usage;
@@ -2253,7 +2253,7 @@ nsMemoryReporterManager::GetHeapOverheadFraction(int64_t* aAmount)
#endif
}
-static MOZ_MUST_USE nsresult
+[[nodiscard]] static nsresult
GetInfallibleAmount(InfallibleAmountFn aAmountFn, int64_t* aAmount)
{
if (aAmountFn) {
diff --git a/xpcom/base/nsMemoryReporterManager.h b/xpcom/base/nsMemoryReporterManager.h
index 8899d322d2..5d59b94ba9 100644
--- a/xpcom/base/nsMemoryReporterManager.h
+++ b/xpcom/base/nsMemoryReporterManager.h
@@ -182,12 +182,12 @@ public:
SizeOfTabFns mSizeOfTabFns;
private:
- MOZ_MUST_USE nsresult
+ [[nodiscard]] nsresult
RegisterReporterHelper(nsIMemoryReporter* aReporter,
bool aForce, bool aStrongRef, bool aIsAsync);
- MOZ_MUST_USE nsresult StartGettingReports();
- // No MOZ_MUST_USE here because ignoring the result is common and reasonable.
+ [[nodiscard]] nsresult StartGettingReports();
+ // No [[nodiscard]] here because ignoring the result is common and reasonable.
nsresult FinishReporting();
void DispatchReporter(nsIMemoryReporter* aReporter, bool aIsAsync,
@@ -275,7 +275,7 @@ private:
PendingReportersState* mPendingReportersState;
PendingProcessesState* GetStateForGeneration(uint32_t aGeneration);
- static MOZ_MUST_USE bool
+ [[nodiscard]] static bool
StartChildReport(mozilla::dom::ContentParent* aChild,
const PendingProcessesState* aState);
};
diff --git a/xpcom/ds/IncrementalTokenizer.h b/xpcom/ds/IncrementalTokenizer.h
index f72b6d7f98..f7f6729772 100644
--- a/xpcom/ds/IncrementalTokenizer.h
+++ b/xpcom/ds/IncrementalTokenizer.h
@@ -70,8 +70,7 @@ public:
* Returns false if there is not enough data to deterministically recognize
* tokens or when the last returned token was EOF.
*/
- MOZ_MUST_USE
- bool Next(Token& aToken);
+ [[nodiscard]] bool Next(Token& aToken);
/**
* Can only be called from inside the consumer callback.
diff --git a/xpcom/ds/Tokenizer.h b/xpcom/ds/Tokenizer.h
index 46fbfcaa85..c9aa623f2c 100644
--- a/xpcom/ds/Tokenizer.h
+++ b/xpcom/ds/Tokenizer.h
@@ -130,7 +130,7 @@ public:
* Return false iff the last Check*() call has returned false or when we've read past
* the end of the input string.
*/
- MOZ_MUST_USE bool HasFailed() const;
+ [[nodiscard]] bool HasFailed() const;
protected:
explicit TokenizerBase(const char* aWhitespaces = nullptr,
@@ -238,23 +238,20 @@ public:
* to Next() reads another token from the input and shifts the cursor.
* Returns false if we have passed the end of the input.
*/
- MOZ_MUST_USE
- bool Next(Token& aToken);
+ [[nodiscard]] bool Next(Token& aToken);
/**
* Parse the token on the input read cursor position, check its type is equal to aTokenType
* and if so, put it into aResult, shift the cursor and return true. Otherwise, leave
* the input read cursor position intact and return false.
*/
- MOZ_MUST_USE
- bool Check(const TokenType aTokenType, Token& aResult);
+ [[nodiscard]] bool Check(const TokenType aTokenType, Token& aResult);
/**
* Same as above method, just compares both token type and token value passed in aToken.
* When both the type and the value equals, shift the cursor and return true. Otherwise
* return false.
*/
- MOZ_MUST_USE
- bool Check(const Token& aToken);
+ [[nodiscard]] bool Check(const Token& aToken);
/**
* SkipWhites method (below) may also skip new line characters automatically.
@@ -288,14 +285,12 @@ public:
/**
* Check whitespace character is present.
*/
- MOZ_MUST_USE
- bool CheckWhite() { return Check(Token::Whitespace()); }
+ [[nodiscard]] bool CheckWhite() { return Check(Token::Whitespace()); }
/**
* Check there is a single character on the read cursor position. If so, shift the read
* cursor position and return true. Otherwise false.
*/
- MOZ_MUST_USE
- bool CheckChar(const char aChar) { return Check(Token::Char(aChar)); }
+ [[nodiscard]] bool CheckChar(const char aChar) { return Check(Token::Char(aChar)); }
/**
* This is a customizable version of CheckChar. aClassifier is a function called with
* value of the character on the current input read position. If this user function
@@ -303,39 +298,34 @@ public:
* The user classifiction function is not called when we are at or past the end and
* false is immediately returned.
*/
- MOZ_MUST_USE
- bool CheckChar(bool (*aClassifier)(const char aChar));
+ [[nodiscard]] bool CheckChar(bool (*aClassifier)(const char aChar));
/**
* Check for a whole expected word.
*/
- MOZ_MUST_USE
- bool CheckWord(const nsACString& aWord) { return Check(Token::Word(aWord)); }
+ [[nodiscard]] bool CheckWord(const nsACString& aWord) { return Check(Token::Word(aWord)); }
/**
* Shortcut for literal const word check with compile time length calculation.
*/
template <uint32_t N>
- MOZ_MUST_USE
- bool CheckWord(const char (&aWord)[N]) { return Check(Token::Word(nsDependentCString(aWord, N - 1))); }
+ [[nodiscard]] bool CheckWord(const char (&aWord)[N]) { return Check(Token::Word(nsDependentCString(aWord, N - 1))); }
/**
* Checks \r, \n or \r\n.
*/
- MOZ_MUST_USE
- bool CheckEOL() { return Check(Token::NewLine()); }
+ [[nodiscard]] bool CheckEOL() { return Check(Token::NewLine()); }
/**
* Checks we are at the end of the input string reading. If so, shift past the end
* and returns true. Otherwise does nothing and returns false.
*/
- MOZ_MUST_USE
- bool CheckEOF() { return Check(Token::EndOfFile()); }
+ [[nodiscard]] bool CheckEOF() { return Check(Token::EndOfFile()); }
/**
* These are shortcuts to obtain the value immediately when the token type matches.
*/
- MOZ_MUST_USE bool ReadChar(char* aValue);
- MOZ_MUST_USE bool ReadChar(bool (*aClassifier)(const char aChar),
+ [[nodiscard]] bool ReadChar(char* aValue);
+ [[nodiscard]] bool ReadChar(bool (*aClassifier)(const char aChar),
char* aValue);
- MOZ_MUST_USE bool ReadWord(nsACString& aValue);
- MOZ_MUST_USE bool ReadWord(nsDependentCSubstring& aValue);
+ [[nodiscard]] bool ReadWord(nsACString& aValue);
+ [[nodiscard]] bool ReadWord(nsDependentCSubstring& aValue);
/**
* This is an integer read helper. It returns false and doesn't move the read
@@ -346,7 +336,7 @@ public:
* and the cursor is moved forward.
*/
template <typename T>
- MOZ_MUST_USE bool ReadInteger(T* aValue)
+ [[nodiscard]] bool ReadInteger(T* aValue)
{
MOZ_RELEASE_ASSERT(aValue);
@@ -422,10 +412,10 @@ public:
* Calling Rollback() after ReadUntil() will return the read cursor to the
* position it had before ReadUntil was called.
*/
- MOZ_MUST_USE bool ReadUntil(Token const& aToken, nsDependentCSubstring& aResult,
- ClaimInclusion aInclude = EXCLUDE_LAST);
- MOZ_MUST_USE bool ReadUntil(Token const& aToken, nsACString& aResult,
- ClaimInclusion aInclude = EXCLUDE_LAST);
+ [[nodiscard]] bool ReadUntil(Token const& aToken, nsDependentCSubstring& aResult,
+ ClaimInclusion aInclude = EXCLUDE_LAST);
+ [[nodiscard]] bool ReadUntil(Token const& aToken, nsACString& aResult,
+ ClaimInclusion aInclude = EXCLUDE_LAST);
protected:
// All these point to the original buffer passed to the Tokenizer's constructor
diff --git a/xpcom/ds/nsISupportsArray.idl b/xpcom/ds/nsISupportsArray.idl
index 30e2a50352..262e6160d3 100644
--- a/xpcom/ds/nsISupportsArray.idl
+++ b/xpcom/ds/nsISupportsArray.idl
@@ -54,7 +54,7 @@ interface nsISupportsArray : nsICollection {
%{C++
// Construct and return a default implementation of nsISupportsArray:
-extern MOZ_MUST_USE nsresult
+[[nodiscard]] extern nsresult
NS_NewISupportsArray(nsISupportsArray** aInstancePtrResult);
%}
diff --git a/xpcom/ds/nsObserverList.h b/xpcom/ds/nsObserverList.h
index 4c43380cc7..e590450a71 100644
--- a/xpcom/ds/nsObserverList.h
+++ b/xpcom/ds/nsObserverList.h
@@ -55,8 +55,8 @@ public:
MOZ_COUNT_DTOR(nsObserverList);
}
- MOZ_MUST_USE nsresult AddObserver(nsIObserver* aObserver, bool aOwnsWeak);
- MOZ_MUST_USE nsresult RemoveObserver(nsIObserver* aObserver);
+ [[nodiscard]] nsresult AddObserver(nsIObserver* aObserver, bool aOwnsWeak);
+ [[nodiscard]] nsresult RemoveObserver(nsIObserver* aObserver);
void NotifyObservers(nsISupports* aSubject,
const char* aTopic,
diff --git a/xpcom/ds/nsObserverService.h b/xpcom/ds/nsObserverService.h
index 48c6dd90c9..8a9ee692cc 100644
--- a/xpcom/ds/nsObserverService.h
+++ b/xpcom/ds/nsObserverService.h
@@ -33,8 +33,8 @@ public:
void Shutdown();
- static MOZ_MUST_USE nsresult Create(nsISupports* aOuter, const nsIID& aIID,
- void** aInstancePtr);
+ [[nodiscard]] static nsresult Create(nsISupports* aOuter, const nsIID& aIID,
+ void** aInstancePtr);
// Unmark any strongly held observers implemented in JS so the cycle
// collector will not traverse them.
diff --git a/xpcom/ds/nsPersistentProperties.h b/xpcom/ds/nsPersistentProperties.h
index 3f52bf8470..f598541a09 100644
--- a/xpcom/ds/nsPersistentProperties.h
+++ b/xpcom/ds/nsPersistentProperties.h
@@ -24,7 +24,7 @@ public:
NS_DECL_NSIPROPERTIES
NS_DECL_NSIPERSISTENTPROPERTIES
- static MOZ_MUST_USE nsresult
+ [[nodiscard]] static nsresult
Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
private:
diff --git a/xpcom/ds/nsStringEnumerator.h b/xpcom/ds/nsStringEnumerator.h
index 74cc23968d..53a1dcac72 100644
--- a/xpcom/ds/nsStringEnumerator.h
+++ b/xpcom/ds/nsStringEnumerator.h
@@ -42,15 +42,15 @@
// InternalMethod(enumerator);
// NS_RELEASE(enumerator);
//
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
const nsTArray<nsString>* aArray,
nsISupports* aOwner);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
const nsTArray<nsCString>* aArray);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
NS_NewStringEnumerator(nsIStringEnumerator** aResult,
const nsTArray<nsString>* aArray);
@@ -63,11 +63,11 @@ NS_NewStringEnumerator(nsIStringEnumerator** aResult,
// nsTArray<nsCString>* array = new nsTArray<nsCString>;
// array->AppendString("abcd");
// NS_NewAdoptingStringEnumerator(&result, array);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
NS_NewAdoptingStringEnumerator(nsIStringEnumerator** aResult,
nsTArray<nsString>* aArray);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
nsTArray<nsCString>* aArray);
@@ -84,7 +84,7 @@ NS_NewAdoptingUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
// return NS_NewStringEnumerator(aResult, mCategoryList, this);
// }
//
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
NS_NewUTF8StringEnumerator(nsIUTF8StringEnumerator** aResult,
const nsTArray<nsCString>* aArray,
nsISupports* aOwner);
diff --git a/xpcom/ds/nsSupportsArray.h b/xpcom/ds/nsSupportsArray.h
index dc7a4a40d9..acbaecd6be 100644
--- a/xpcom/ds/nsSupportsArray.h
+++ b/xpcom/ds/nsSupportsArray.h
@@ -31,7 +31,7 @@ class nsSupportsArray final : public nsISupportsArray,
public:
nsSupportsArray(void);
- static MOZ_MUST_USE nsresult
+ [[nodiscard]]static nsresult
Create(nsISupports* aOuter, REFNSIID aIID, void** aResult);
NS_DECL_THREADSAFE_ISUPPORTS
@@ -45,18 +45,18 @@ public:
return NS_OK;
}
NS_IMETHOD GetElementAt(uint32_t aIndex, nsISupports** aResult) override;
- MOZ_MUST_USE NS_IMETHOD
+ [[nodiscard]] NS_IMETHOD
SetElementAt(uint32_t aIndex, nsISupports* aValue) override
{
return ReplaceElementAt(aValue, aIndex) ? NS_OK : NS_ERROR_FAILURE;
}
- MOZ_MUST_USE NS_IMETHOD AppendElement(nsISupports* aElement) override
+ [[nodiscard]] NS_IMETHOD AppendElement(nsISupports* aElement) override
{
// XXX Invalid cast of bool to nsresult (bug 778110)
return (nsresult)InsertElementAt(aElement, mArray.Length())/* ? NS_OK : NS_ERROR_FAILURE*/;
}
// XXX this is badly named - should be RemoveFirstElement
- MOZ_MUST_USE NS_IMETHOD RemoveElement(nsISupports* aElement) override;
+ [[nodiscard]] NS_IMETHOD RemoveElement(nsISupports* aElement) override;
NS_IMETHOD DeprecatedEnumerate(nsIEnumerator** aResult) override;
NS_IMETHOD Clear(void) override;
@@ -69,21 +69,21 @@ public:
return NS_OK;
}
- MOZ_MUST_USE NS_IMETHOD_(bool)
+ [[nodiscard]] NS_IMETHOD_(bool)
InsertElementAt(nsISupports* aElement, uint32_t aIndex) override;
- MOZ_MUST_USE NS_IMETHOD_(bool)
+ [[nodiscard]] NS_IMETHOD_(bool)
ReplaceElementAt(nsISupports* aElement, uint32_t aIndex) override;
- MOZ_MUST_USE NS_IMETHOD_(bool)
+ [[nodiscard]] NS_IMETHOD_(bool)
RemoveElementAt(uint32_t aIndex) override;
- MOZ_MUST_USE NS_IMETHOD DeleteElementAt(uint32_t aIndex) override
+ [[nodiscard]] NS_IMETHOD DeleteElementAt(uint32_t aIndex) override
{
return (RemoveElementAt(aIndex) ? NS_OK : NS_ERROR_FAILURE);
}
- MOZ_MUST_USE NS_IMETHOD Clone(nsISupportsArray** aResult) override;
+ [[nodiscard]] NS_IMETHOD Clone(nsISupportsArray** aResult) override;
/**
* nsIArray adapters.
diff --git a/xpcom/ds/nsVariant.h b/xpcom/ds/nsVariant.h
index c56652bfc0..146810ead7 100644
--- a/xpcom/ds/nsVariant.h
+++ b/xpcom/ds/nsVariant.h
@@ -42,36 +42,36 @@ public:
uint16_t GetType() const { return mType; }
- MOZ_MUST_USE nsresult ConvertToInt8(uint8_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToInt16(int16_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToInt32(int32_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToInt64(int64_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToUint8(uint8_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToUint16(uint16_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToUint32(uint32_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToUint64(uint64_t* aResult) const;
- MOZ_MUST_USE nsresult ConvertToFloat(float* aResult) const;
- MOZ_MUST_USE nsresult ConvertToDouble(double* aResult) const;
- MOZ_MUST_USE nsresult ConvertToBool(bool* aResult) const;
- MOZ_MUST_USE nsresult ConvertToChar(char* aResult) const;
- MOZ_MUST_USE nsresult ConvertToWChar(char16_t* aResult) const;
-
- MOZ_MUST_USE nsresult ConvertToID(nsID* aResult) const;
-
- MOZ_MUST_USE nsresult ConvertToAString(nsAString& aResult) const;
- MOZ_MUST_USE nsresult ConvertToAUTF8String(nsAUTF8String& aResult) const;
- MOZ_MUST_USE nsresult ConvertToACString(nsACString& aResult) const;
- MOZ_MUST_USE nsresult ConvertToString(char** aResult) const;
- MOZ_MUST_USE nsresult ConvertToWString(char16_t** aResult) const;
- MOZ_MUST_USE nsresult ConvertToStringWithSize(uint32_t* aSize, char** aStr) const;
- MOZ_MUST_USE nsresult ConvertToWStringWithSize(uint32_t* aSize, char16_t** aStr) const;
-
- MOZ_MUST_USE nsresult ConvertToISupports(nsISupports** aResult) const;
- MOZ_MUST_USE nsresult ConvertToInterface(nsIID** aIID, void** aInterface) const;
- MOZ_MUST_USE nsresult ConvertToArray(uint16_t* aType, nsIID* aIID,
+ [[nodiscard]] nsresult ConvertToInt8(uint8_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToInt16(int16_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToInt32(int32_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToInt64(int64_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToUint8(uint8_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToUint16(uint16_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToUint32(uint32_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToUint64(uint64_t* aResult) const;
+ [[nodiscard]] nsresult ConvertToFloat(float* aResult) const;
+ [[nodiscard]] nsresult ConvertToDouble(double* aResult) const;
+ [[nodiscard]] nsresult ConvertToBool(bool* aResult) const;
+ [[nodiscard]] nsresult ConvertToChar(char* aResult) const;
+ [[nodiscard]] nsresult ConvertToWChar(char16_t* aResult) const;
+
+ [[nodiscard]] nsresult ConvertToID(nsID* aResult) const;
+
+ [[nodiscard]] nsresult ConvertToAString(nsAString& aResult) const;
+ [[nodiscard]] nsresult ConvertToAUTF8String(nsAUTF8String& aResult) const;
+ [[nodiscard]] nsresult ConvertToACString(nsACString& aResult) const;
+ [[nodiscard]] nsresult ConvertToString(char** aResult) const;
+ [[nodiscard]] nsresult ConvertToWString(char16_t** aResult) const;
+ [[nodiscard]] nsresult ConvertToStringWithSize(uint32_t* aSize, char** aStr) const;
+ [[nodiscard]] nsresult ConvertToWStringWithSize(uint32_t* aSize, char16_t** aStr) const;
+
+ [[nodiscard]] nsresult ConvertToISupports(nsISupports** aResult) const;
+ [[nodiscard]] nsresult ConvertToInterface(nsIID** aIID, void** aInterface) const;
+ [[nodiscard]] nsresult ConvertToArray(uint16_t* aType, nsIID* aIID,
uint32_t* aCount, void** aPtr) const;
- MOZ_MUST_USE nsresult SetFromVariant(nsIVariant* aValue);
+ [[nodiscard]] nsresult SetFromVariant(nsIVariant* aValue);
void SetFromInt8(uint8_t aValue);
void SetFromInt16(int16_t aValue);
@@ -91,15 +91,15 @@ public:
void SetFromDOMString(const nsAString& aValue);
void SetFromAUTF8String(const nsAUTF8String& aValue);
void SetFromACString(const nsACString& aValue);
- MOZ_MUST_USE nsresult SetFromString(const char* aValue);
- MOZ_MUST_USE nsresult SetFromWString(const char16_t* aValue);
+ [[nodiscard]] nsresult SetFromString(const char* aValue);
+ [[nodiscard]] nsresult SetFromWString(const char16_t* aValue);
void SetFromISupports(nsISupports* aValue);
void SetFromInterface(const nsIID& aIID, nsISupports* aValue);
- MOZ_MUST_USE nsresult SetFromArray(uint16_t aType, const nsIID* aIID,
+ [[nodiscard]] nsresult SetFromArray(uint16_t aType, const nsIID* aIID,
uint32_t aCount, void* aValue);
- MOZ_MUST_USE nsresult SetFromStringWithSize(uint32_t aSize,
+ [[nodiscard]] nsresult SetFromStringWithSize(uint32_t aSize,
const char* aValue);
- MOZ_MUST_USE nsresult SetFromWStringWithSize(uint32_t aSize,
+ [[nodiscard]] nsresult SetFromWStringWithSize(uint32_t aSize,
const char16_t* aValue);
// Like SetFromWStringWithSize, but leaves the string uninitialized. It does
@@ -113,11 +113,11 @@ public:
void Traverse(nsCycleCollectionTraversalCallback& aCb) const;
private:
- MOZ_MUST_USE nsresult
+ [[nodiscard]] nsresult
ToManageableNumber(nsDiscriminatedUnion* aOutData) const;
void FreeArray();
- MOZ_MUST_USE bool String2ID(nsID* aPid) const;
- MOZ_MUST_USE nsresult ToString(nsACString& aOutString) const;
+ [[nodiscard]] bool String2ID(nsID* aPid) const;
+ [[nodiscard]] nsresult ToString(nsACString& aOutString) const;
public:
union
diff --git a/xpcom/ds/nsWindowsRegKey.h b/xpcom/ds/nsWindowsRegKey.h
index 46bba1b118..1f50637d63 100644
--- a/xpcom/ds/nsWindowsRegKey.h
+++ b/xpcom/ds/nsWindowsRegKey.h
@@ -31,9 +31,9 @@ extern "C" void NS_NewWindowsRegKey(nsIWindowsRegKey** aResult);
{ 0xa53bc624, 0xd577, 0x4839, \
{ 0xb8, 0xec, 0xbb, 0x50, 0x40, 0xa5, 0x2f, 0xf4 } }
-extern MOZ_MUST_USE nsresult nsWindowsRegKeyConstructor(nsISupports* aOuter,
- const nsIID& aIID,
- void** aResult);
+[[nodiscard]] extern nsresult nsWindowsRegKeyConstructor(nsISupports* aOuter,
+ const nsIID& aIID,
+ void** aResult);
#endif // IMPL_LIBXUL
diff --git a/xpcom/glue/nsBaseHashtable.h b/xpcom/glue/nsBaseHashtable.h
index 4dbb58805a..00de479b66 100644
--- a/xpcom/glue/nsBaseHashtable.h
+++ b/xpcom/glue/nsBaseHashtable.h
@@ -144,8 +144,8 @@ public:
}
}
- MOZ_MUST_USE bool Put(KeyType aKey, const UserDataType& aData,
- const fallible_t&)
+ [[nodiscard]] bool Put(KeyType aKey, const UserDataType& aData,
+ const fallible_t&)
{
EntryType* ent = this->PutEntry(aKey, mozilla::fallible);
if (!ent) {
diff --git a/xpcom/glue/nsDebug.h b/xpcom/glue/nsDebug.h
index eca36c5137..1608186745 100644
--- a/xpcom/glue/nsDebug.h
+++ b/xpcom/glue/nsDebug.h
@@ -35,7 +35,7 @@
*
* Unused << NS_WARN_IF(NS_FAILED(FnWithSideEffects());
*
- * (The |Unused <<| is necessary because of the MOZ_MUST_USE annotation.)
+ * (The |Unused <<| is necessary because of the [[nodiscard]] annotation.)
*
* However, note that the argument to this macro is evaluated in all builds. If
* you just want a warning assertion, it is better to use NS_WARNING_ASSERTION
@@ -47,8 +47,8 @@
*/
#ifdef __cplusplus
#ifdef DEBUG
-inline MOZ_MUST_USE bool NS_warn_if_impl(bool aCondition, const char* aExpr,
- const char* aFile, int32_t aLine)
+[[nodiscard]] inline bool NS_warn_if_impl(bool aCondition, const char* aExpr,
+ const char* aFile, int32_t aLine)
{
if (MOZ_UNLIKELY(aCondition)) {
NS_DebugBreak(NS_DEBUG_WARNING, nullptr, aExpr, aFile, aLine);
diff --git a/xpcom/glue/nsDeque.h b/xpcom/glue/nsDeque.h
index 723c021228..9e98b09bbb 100644
--- a/xpcom/glue/nsDeque.h
+++ b/xpcom/glue/nsDeque.h
@@ -87,7 +87,7 @@ public:
}
}
- MOZ_MUST_USE bool Push(void* aItem, const fallible_t&);
+ [[nodiscard]] bool Push(void* aItem, const fallible_t&);
/**
* Inserts new member at the front of the deque.
@@ -101,7 +101,7 @@ public:
}
}
- MOZ_MUST_USE bool PushFront(void* aItem, const fallible_t&);
+ [[nodiscard]] bool PushFront(void* aItem, const fallible_t&);
/**
* Remove and return the last item in the container.
diff --git a/xpcom/glue/nsInterfaceHashtable.h b/xpcom/glue/nsInterfaceHashtable.h
index cdd36924ec..44dc309783 100644
--- a/xpcom/glue/nsInterfaceHashtable.h
+++ b/xpcom/glue/nsInterfaceHashtable.h
@@ -64,8 +64,8 @@ public:
}
}
- MOZ_MUST_USE bool Put(KeyType aKey, already_AddRefed<Interface>&& aData,
- const mozilla::fallible_t&);
+ [[nodiscard]] bool Put(KeyType aKey, already_AddRefed<Interface>&& aData,
+ const mozilla::fallible_t&);
using base_type::Put;
};
diff --git a/xpcom/glue/nsRefPtrHashtable.h b/xpcom/glue/nsRefPtrHashtable.h
index ef527b6885..4f3816106e 100644
--- a/xpcom/glue/nsRefPtrHashtable.h
+++ b/xpcom/glue/nsRefPtrHashtable.h
@@ -53,8 +53,8 @@ public:
void Put(KeyType aKey, already_AddRefed<PtrType> aData);
- MOZ_MUST_USE bool Put(KeyType aKey, already_AddRefed<PtrType> aData,
- const mozilla::fallible_t&);
+ [[nodiscard]] bool Put(KeyType aKey, already_AddRefed<PtrType> aData,
+ const mozilla::fallible_t&);
// Overload Remove, rather than overriding it.
using base_type::Remove;
diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h
index 47635de318..9604c54dd9 100644
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -1274,7 +1274,7 @@ public:
}
template<class Allocator>
- MOZ_MUST_USE
+ [[nodiscard]]
bool Assign(const nsTArray_Impl<E, Allocator>& aOther,
const mozilla::fallible_t&)
{
@@ -1343,7 +1343,7 @@ protected:
public:
template<class Item>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item* aArray, size_type aArrayLen,
const mozilla::fallible_t&)
@@ -1374,7 +1374,7 @@ protected:
public:
template<class Item>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const nsTArray<Item>& aArray,
const mozilla::fallible_t&)
@@ -1383,7 +1383,7 @@ public:
}
template<class Item>
- MOZ_MUST_USE elem_type* ReplaceElementsAt(index_type aStart,
+ [[nodiscard]] elem_type* ReplaceElementsAt(index_type aStart,
size_type aCount,
mozilla::Span<const Item> aSpan,
const mozilla::fallible_t&)
@@ -1402,7 +1402,7 @@ protected:
public:
template<class Item>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item& aItem, const mozilla::fallible_t&)
{
@@ -1427,7 +1427,7 @@ protected:
public:
template<class Item>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementsAt(index_type aIndex, const Item* aArray,
size_type aArrayLen, const mozilla::fallible_t&)
{
@@ -1455,7 +1455,7 @@ protected:
public:
template<class Item, class Allocator>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementsAt(index_type aIndex,
const nsTArray_Impl<Item, Allocator>& aArray,
const mozilla::fallible_t&)
@@ -1472,14 +1472,14 @@ protected:
public:
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementAt(index_type aIndex, const mozilla::fallible_t&)
{
return InsertElementAt<FallibleAlloc>(aIndex);
}
template<class Item>
- MOZ_MUST_USE elem_type* InsertElementsAt(index_type aIndex,
+ [[nodiscard]] elem_type* InsertElementsAt(index_type aIndex,
mozilla::Span<const Item> aSpan,
const mozilla::fallible_t&)
{
@@ -1494,7 +1494,7 @@ protected:
public:
template<class Item>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementAt(index_type aIndex, Item&& aItem,
const mozilla::fallible_t&)
{
@@ -1569,7 +1569,7 @@ protected:
public:
template<class Item, class Comparator>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementSorted(Item&& aItem, const Comparator& aComp,
const mozilla::fallible_t&)
{
@@ -1589,7 +1589,7 @@ protected:
public:
template<class Item>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementSorted(Item&& aItem, const mozilla::fallible_t&)
{
return InsertElementSorted<Item, FallibleAlloc>(
@@ -1615,7 +1615,7 @@ protected:
public:
template<class Item>
- /* MOZ_MUST_USE */
+ /* [[nodiscard]] */
elem_type* AppendElements(const Item* aArray, size_type aArrayLen,
const mozilla::fallible_t&)
{
@@ -1623,7 +1623,7 @@ public:
}
template<class Item>
- /* MOZ_MUST_USE */
+ /* [[nodiscard]] */
elem_type* AppendElements(mozilla::Span<const Item> aSpan,
const mozilla::fallible_t&)
{
@@ -1641,7 +1641,7 @@ protected:
public:
template<class Item, class Allocator>
- /* MOZ_MUST_USE */
+ /* [[nodiscard]] */
elem_type* AppendElements(const nsTArray_Impl<Item, Allocator>& aArray,
const mozilla::fallible_t&)
{
@@ -1657,7 +1657,7 @@ protected:
public:
template<class Item, class Allocator, typename ActualAlloc = Alloc>
- /* MOZ_MUST_USE */
+ /* [[nodiscard]] */
elem_type* AppendElements(nsTArray_Impl<Item, Allocator>&& aArray,
const mozilla::fallible_t&)
{
@@ -1672,7 +1672,7 @@ protected:
public:
template<class Item>
- /* MOZ_MUST_USE */
+ /* [[nodiscard]] */
elem_type* AppendElement(Item&& aItem,
const mozilla::fallible_t&)
{
@@ -1699,7 +1699,7 @@ protected:
}
public:
- /* MOZ_MUST_USE */
+ /* [[nodiscard]] */
elem_type* AppendElements(size_type aCount,
const mozilla::fallible_t&)
{
@@ -1717,7 +1717,7 @@ protected:
}
public:
- /* MOZ_MUST_USE */
+ /* [[nodiscard]] */
elem_type* AppendElement(const mozilla::fallible_t&)
{
return AppendElement<FallibleAlloc>();
@@ -1819,7 +1819,7 @@ protected:
}
public:
- MOZ_MUST_USE
+ [[nodiscard]]
bool SetCapacity(size_type aCapacity, const mozilla::fallible_t&)
{
return SetCapacity<FallibleAlloc>(aCapacity);
@@ -1848,7 +1848,7 @@ protected:
}
public:
- MOZ_MUST_USE
+ [[nodiscard]]
bool SetLength(size_type aNewLen, const mozilla::fallible_t&)
{
return SetLength<FallibleAlloc>(aNewLen);
@@ -1887,7 +1887,7 @@ protected:
}
public:
- MOZ_MUST_USE
+ [[nodiscard]]
bool EnsureLengthAtLeast(size_type aMinLen, const mozilla::fallible_t&)
{
return EnsureLengthAtLeast<FallibleAlloc>(aMinLen);
@@ -1918,7 +1918,7 @@ protected:
}
public:
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
const mozilla::fallible_t&)
{
@@ -1940,7 +1940,7 @@ protected:
public:
template<class Item>
- MOZ_MUST_USE
+ [[nodiscard]]
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
const Item& aItem, const mozilla::fallible_t&)
{
diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h
index b382da0bcc..dd78476ece 100644
--- a/xpcom/glue/nsTHashtable.h
+++ b/xpcom/glue/nsTHashtable.h
@@ -154,8 +154,7 @@ public:
return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey)));
}
- MOZ_MUST_USE
- EntryType* PutEntry(KeyType aKey, const fallible_t&)
+ [[nodiscard]] EntryType* PutEntry(KeyType aKey, const fallible_t&)
{
return static_cast<EntryType*>(mTable.Add(EntryType::KeyToPointer(aKey),
mozilla::fallible));
@@ -520,8 +519,7 @@ public:
return reinterpret_cast<EntryType*>(Base::PutEntry(aKey));
}
- MOZ_MUST_USE
- EntryType* PutEntry(T* aKey, const mozilla::fallible_t&)
+ [[nodiscard]] EntryType* PutEntry(T* aKey, const mozilla::fallible_t&)
{
return reinterpret_cast<EntryType*>(
Base::PutEntry(aKey, mozilla::fallible));
diff --git a/xpcom/idl-parser/xpidl/header.py b/xpcom/idl-parser/xpidl/header.py
index 8e02a7d11b..8e854c4da8 100644
--- a/xpcom/idl-parser/xpidl/header.py
+++ b/xpcom/idl-parser/xpidl/header.py
@@ -52,7 +52,7 @@ def attributeReturnType(a, macro):
else:
ret = macro
if a.must_use:
- ret = "MOZ_MUST_USE " + ret
+ ret = "[[nodiscard]] " + ret
return ret
@@ -90,7 +90,7 @@ def methodReturnType(m, macro):
else:
ret = macro
if m.must_use:
- ret = "MOZ_MUST_USE " + ret
+ ret = "[[nodiscard]] " + ret
return ret
diff --git a/xpcom/io/Base64.h b/xpcom/io/Base64.h
index cc8ea07981..aa175eea3a 100644
--- a/xpcom/io/Base64.h
+++ b/xpcom/io/Base64.h
@@ -12,30 +12,30 @@ class nsIInputStream;
namespace mozilla {
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64EncodeInputStream(nsIInputStream* aInputStream,
nsACString& aDest,
uint32_t aCount,
uint32_t aOffset = 0);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64EncodeInputStream(nsIInputStream* aInputStream,
nsAString& aDest,
uint32_t aCount,
uint32_t aOffset = 0);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64Encode(const char* aBinary, uint32_t aBinaryLen, char** aBase64);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64Encode(const nsACString& aBinary, nsACString& aBase64);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64Encode(const nsAString& aBinary, nsAString& aBase64);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64Decode(const char* aBase64, uint32_t aBase64Len, char** aBinary,
uint32_t* aBinaryLen);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64Decode(const nsACString& aBase64, nsACString& aBinary);
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64Decode(const nsAString& aBase64, nsAString& aBinary);
enum class Base64URLEncodePaddingPolicy {
@@ -48,7 +48,7 @@ enum class Base64URLEncodePaddingPolicy {
* Aims to encode the data in constant time. The caller retains ownership
* of |aBinary|.
*/
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64URLEncode(uint32_t aBinaryLen, const uint8_t* aBinary,
Base64URLEncodePaddingPolicy aPaddingPolicy,
nsACString& aBase64);
@@ -62,7 +62,7 @@ enum class Base64URLDecodePaddingPolicy {
/**
* Decodes a Base64 URL-encoded |aBase64| into |aBinary|.
*/
-MOZ_MUST_USE nsresult
+[[nodiscard]] nsresult
Base64URLDecode(const nsACString& aBase64,
Base64URLDecodePaddingPolicy aPaddingPolicy,
FallibleTArray<uint8_t>& aBinary);
diff --git a/xpcom/io/nsIPipe.idl b/xpcom/io/nsIPipe.idl
index 596be92e9f..3442f1734c 100644
--- a/xpcom/io/nsIPipe.idl
+++ b/xpcom/io/nsIPipe.idl
@@ -127,7 +127,7 @@ class nsIOutputStream;
* this mode can be useful in some cases, but should always be used with
* caution. the default value for this parameter is a finite value.
*/
-extern MOZ_MUST_USE nsresult
+extern [[nodiscard]] nsresult
NS_NewPipe2(nsIAsyncInputStream **pipeIn,
nsIAsyncOutputStream **pipeOut,
bool nonBlockingInput = false,
@@ -160,7 +160,7 @@ NS_NewPipe2(nsIAsyncInputStream **pipeIn,
* @param nonBlockingOutput
* true specifies non-blocking output stream behavior
*/
-extern MOZ_MUST_USE nsresult
+extern [[nodiscard]] nsresult
NS_NewPipe(nsIInputStream **pipeIn,
nsIOutputStream **pipeOut,
uint32_t segmentSize = 0,
diff --git a/xpcom/string/nsReadableUtils.h b/xpcom/string/nsReadableUtils.h
index f3de301055..e187f09e0c 100644
--- a/xpcom/string/nsReadableUtils.h
+++ b/xpcom/string/nsReadableUtils.h
@@ -39,7 +39,7 @@ void LossyCopyUTF16toASCII(const char16ptr_t aSource, nsACString& aDest);
void CopyASCIItoUTF16(const char* aSource, nsAString& aDest);
void CopyUTF16toUTF8(const nsAString& aSource, nsACString& aDest);
-MOZ_MUST_USE bool CopyUTF16toUTF8(const nsAString& aSource, nsACString& aDest,
+[[nodiscard]] bool CopyUTF16toUTF8(const nsAString& aSource, nsACString& aDest,
const mozilla::fallible_t&);
void CopyUTF8toUTF16(const nsACString& aSource, nsAString& aDest);
@@ -48,22 +48,22 @@ void CopyUTF8toUTF16(const char* aSource, nsAString& aDest);
void LossyAppendUTF16toASCII(const nsAString& aSource, nsACString& aDest);
void AppendASCIItoUTF16(const nsACString& aSource, nsAString& aDest);
-MOZ_MUST_USE bool AppendASCIItoUTF16(const nsACString& aSource,
+[[nodiscard]] bool AppendASCIItoUTF16(const nsACString& aSource,
nsAString& aDest,
const mozilla::fallible_t&);
void LossyAppendUTF16toASCII(const char16ptr_t aSource, nsACString& aDest);
-MOZ_MUST_USE bool AppendASCIItoUTF16(const char* aSource,
+[[nodiscard]] bool AppendASCIItoUTF16(const char* aSource,
nsAString& aDest,
const mozilla::fallible_t&);
void AppendASCIItoUTF16(const char* aSource, nsAString& aDest);
void AppendUTF16toUTF8(const nsAString& aSource, nsACString& aDest);
-MOZ_MUST_USE bool AppendUTF16toUTF8(const nsAString& aSource,
+[[nodiscard]] bool AppendUTF16toUTF8(const nsAString& aSource,
nsACString& aDest,
const mozilla::fallible_t&);
void AppendUTF8toUTF16(const nsACString& aSource, nsAString& aDest);
-MOZ_MUST_USE bool AppendUTF8toUTF16(const nsACString& aSource,
+[[nodiscard]] bool AppendUTF8toUTF16(const nsACString& aSource,
nsAString& aDest,
const mozilla::fallible_t&);
diff --git a/xpcom/string/nsTString.h b/xpcom/string/nsTString.h
index 7bd9396e84..411b238de1 100644
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -394,10 +394,10 @@ public:
*/
void ReplaceSubstring(const self_type& aTarget, const self_type& aNewValue);
void ReplaceSubstring(const char_type* aTarget, const char_type* aNewValue);
- MOZ_MUST_USE bool ReplaceSubstring(const self_type& aTarget,
+ [[nodiscard]] bool ReplaceSubstring(const self_type& aTarget,
const self_type& aNewValue,
const fallible_t&);
- MOZ_MUST_USE bool ReplaceSubstring(const char_type* aTarget,
+ [[nodiscard]] bool ReplaceSubstring(const char_type* aTarget,
const char_type* aNewValue,
const fallible_t&);
diff --git a/xpcom/string/nsTSubstring.h b/xpcom/string/nsTSubstring.h
index a1c1264193..9b57f01704 100644
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -370,21 +370,21 @@ public:
*/
void NS_FASTCALL Assign(char_type aChar);
- MOZ_MUST_USE bool NS_FASTCALL Assign(char_type aChar, const fallible_t&);
+ [[nodiscard]] bool NS_FASTCALL Assign(char_type aChar, const fallible_t&);
void NS_FASTCALL Assign(const char_type* aData);
- MOZ_MUST_USE bool NS_FASTCALL Assign(const char_type* aData,
+ [[nodiscard]] bool NS_FASTCALL Assign(const char_type* aData,
const fallible_t&);
void NS_FASTCALL Assign(const char_type* aData, size_type aLength);
- MOZ_MUST_USE bool NS_FASTCALL Assign(const char_type* aData,
+ [[nodiscard]] bool NS_FASTCALL Assign(const char_type* aData,
size_type aLength, const fallible_t&);
void NS_FASTCALL Assign(const self_type&);
- MOZ_MUST_USE bool NS_FASTCALL Assign(const self_type&, const fallible_t&);
+ [[nodiscard]] bool NS_FASTCALL Assign(const self_type&, const fallible_t&);
void NS_FASTCALL Assign(const substring_tuple_type&);
- MOZ_MUST_USE bool NS_FASTCALL Assign(const substring_tuple_type&,
+ [[nodiscard]] bool NS_FASTCALL Assign(const substring_tuple_type&,
const fallible_t&);
#if defined(CharT_is_PRUnichar) && defined(MOZ_USE_CHAR16_WRAPPER)
@@ -398,7 +398,7 @@ public:
Assign(static_cast<const char16_t*>(aData), aLength);
}
- MOZ_MUST_USE bool Assign(char16ptr_t aData, size_type aLength,
+ [[nodiscard]] bool Assign(char16ptr_t aData, size_type aLength,
const fallible_t& aFallible)
{
return Assign(static_cast<const char16_t*>(aData), aLength,
@@ -407,7 +407,7 @@ public:
#endif
void NS_FASTCALL AssignASCII(const char* aData, size_type aLength);
- MOZ_MUST_USE bool NS_FASTCALL AssignASCII(const char* aData,
+ [[nodiscard]] bool NS_FASTCALL AssignASCII(const char* aData,
size_type aLength,
const fallible_t&);
@@ -415,7 +415,7 @@ public:
{
AssignASCII(aData, mozilla::AssertedCast<size_type, size_t>(strlen(aData)));
}
- MOZ_MUST_USE bool NS_FASTCALL AssignASCII(const char* aData,
+ [[nodiscard]] bool NS_FASTCALL AssignASCII(const char* aData,
const fallible_t& aFallible)
{
return AssignASCII(aData,
@@ -479,14 +479,14 @@ public:
void NS_FASTCALL Replace(index_type aCutStart, size_type aCutLength,
char_type aChar);
- MOZ_MUST_USE bool NS_FASTCALL Replace(index_type aCutStart,
+ [[nodiscard]] bool NS_FASTCALL Replace(index_type aCutStart,
size_type aCutLength,
char_type aChar,
const fallible_t&);
void NS_FASTCALL Replace(index_type aCutStart, size_type aCutLength,
const char_type* aData,
size_type aLength = size_type(-1));
- MOZ_MUST_USE bool NS_FASTCALL Replace(index_type aCutStart,
+ [[nodiscard]] bool NS_FASTCALL Replace(index_type aCutStart,
size_type aCutLength,
const char_type* aData,
size_type aLength,
@@ -496,7 +496,7 @@ public:
{
Replace(aCutStart, aCutLength, aStr.Data(), aStr.Length());
}
- MOZ_MUST_USE bool Replace(index_type aCutStart,
+ [[nodiscard]] bool Replace(index_type aCutStart,
size_type aCutLength,
const self_type& aStr,
const fallible_t& aFallible)
@@ -511,7 +511,7 @@ public:
const char* aData,
size_type aLength = size_type(-1));
- MOZ_MUST_USE bool NS_FASTCALL ReplaceASCII(index_type aCutStart, size_type aCutLength,
+ [[nodiscard]] bool NS_FASTCALL ReplaceASCII(index_type aCutStart, size_type aCutLength,
const char* aData,
size_type aLength,
const fallible_t&);
@@ -530,7 +530,7 @@ public:
{
Replace(mLength, 0, aChar);
}
- MOZ_MUST_USE bool Append(char_type aChar, const fallible_t& aFallible)
+ [[nodiscard]] bool Append(char_type aChar, const fallible_t& aFallible)
{
return Replace(mLength, 0, aChar, aFallible);
}
@@ -538,7 +538,7 @@ public:
{
Replace(mLength, 0, aData, aLength);
}
- MOZ_MUST_USE bool Append(const char_type* aData, size_type aLength,
+ [[nodiscard]] bool Append(const char_type* aData, size_type aLength,
const fallible_t& aFallible)
{
return Replace(mLength, 0, aData, aLength, aFallible);
@@ -555,7 +555,7 @@ public:
{
Replace(mLength, 0, aStr);
}
- MOZ_MUST_USE bool Append(const self_type& aStr, const fallible_t& aFallible)
+ [[nodiscard]] bool Append(const self_type& aStr, const fallible_t& aFallible)
{
return Replace(mLength, 0, aStr, aFallible);
}
@@ -569,12 +569,12 @@ public:
ReplaceASCII(mLength, 0, aData, aLength);
}
- MOZ_MUST_USE bool AppendASCII(const char* aData, const fallible_t& aFallible)
+ [[nodiscard]] bool AppendASCII(const char* aData, const fallible_t& aFallible)
{
return ReplaceASCII(mLength, 0, aData, size_type(-1), aFallible);
}
- MOZ_MUST_USE bool AppendASCII(const char* aData, size_type aLength, const fallible_t& aFallible)
+ [[nodiscard]] bool AppendASCII(const char* aData, size_type aLength, const fallible_t& aFallible)
{
return ReplaceASCII(mLength, 0, aData, aLength, aFallible);
}
@@ -656,7 +656,7 @@ public:
}
template<int N>
- MOZ_MUST_USE bool AppendLiteral(const char (&aStr)[N], const fallible_t& aFallible)
+ [[nodiscard]] bool AppendLiteral(const char (&aStr)[N], const fallible_t& aFallible)
{
return AppendASCII(aStr, N - 1, aFallible);
}
@@ -742,11 +742,11 @@ public:
* Also ensures that the buffer is mutable.
*/
void NS_FASTCALL SetCapacity(size_type aNewCapacity);
- MOZ_MUST_USE bool NS_FASTCALL SetCapacity(size_type aNewCapacity,
+ [[nodiscard]] bool NS_FASTCALL SetCapacity(size_type aNewCapacity,
const fallible_t&);
void NS_FASTCALL SetLength(size_type aNewLength);
- MOZ_MUST_USE bool NS_FASTCALL SetLength(size_type aNewLength,
+ [[nodiscard]] bool NS_FASTCALL SetLength(size_type aNewLength,
const fallible_t&);
void Truncate(size_type aNewLength = 0)
@@ -839,7 +839,7 @@ public:
Append(aSpan.Elements(), len);
}
- MOZ_MUST_USE bool Append(mozilla::Span<const char_type> aSpan,
+ [[nodiscard]] bool Append(mozilla::Span<const char_type> aSpan,
const fallible_t& aFallible)
{
auto len = aSpan.Length();
@@ -869,7 +869,7 @@ public:
Append(reinterpret_cast<const char*>(aSpan.Elements()), len);
}
- MOZ_MUST_USE bool Append(mozilla::Span<const uint8_t> aSpan,
+ [[nodiscard]] bool Append(mozilla::Span<const uint8_t> aSpan,
const fallible_t& aFallible)
{
auto len = aSpan.Length();
@@ -1069,11 +1069,11 @@ protected:
* this function returns false if is unable to allocate sufficient
* memory.
*/
- MOZ_MUST_USE bool ReplacePrep(index_type aCutStart,
+ [[nodiscard]] bool ReplacePrep(index_type aCutStart,
size_type aCutLength,
size_type aNewLength);
- MOZ_MUST_USE bool NS_FASTCALL ReplacePrepInternal(
+ [[nodiscard]] bool NS_FASTCALL ReplacePrepInternal(
index_type aCutStart,
size_type aCutLength,
size_type aNewFragLength,
@@ -1092,7 +1092,7 @@ protected:
* this helper function can be called prior to directly manipulating
* the contents of mData. see, for example, BeginWriting.
*/
- MOZ_MUST_USE bool NS_FASTCALL EnsureMutable(
+ [[nodiscard]] bool NS_FASTCALL EnsureMutable(
size_type aNewLen = size_type(-1));
/**
@@ -1114,7 +1114,7 @@ protected:
/**
* Checks if the given capacity is valid for this string type.
*/
- static MOZ_MUST_USE bool CheckCapacity(size_type aCapacity) {
+ [[nodiscard]] static bool CheckCapacity(size_type aCapacity) {
if (aCapacity > kMaxCapacity) {
// Also assert for |aCapacity| equal to |size_type(-1)|, since we used to
// use that value to flag immutability.