diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 8b1a45748dd1..cbbbf80515d8 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -719,7 +719,7 @@ public: block->mNext = nullptr; mNextBlock = &block->mNext; } - return new (mNext++) PtrInfo(aPointer, aParticipant); + return new (mozilla::KnownNotNull, mNext++) PtrInfo(aPointer, aParticipant); } private: NodeBlock** mNextBlock; diff --git a/xpcom/glue/PLDHashTable.cpp b/xpcom/glue/PLDHashTable.cpp index 41e2a03c91f2..6152e90003c0 100644 --- a/xpcom/glue/PLDHashTable.cpp +++ b/xpcom/glue/PLDHashTable.cpp @@ -11,6 +11,7 @@ #include "PLDHashTable.h" #include "mozilla/HashFunctions.h" #include "mozilla/MathAlgorithms.h" +#include "mozilla/OperatorNewExtensions.h" #include "nsAlgorithm.h" #include "mozilla/Likely.h" #include "mozilla/MemoryReporting.h" @@ -317,7 +318,7 @@ PLDHashTable::ClearAndPrepareForLength(uint32_t aLength) uint32_t entrySize = mEntrySize; this->~PLDHashTable(); - new (this) PLDHashTable(ops, entrySize, aLength); + new (KnownNotNull, this) PLDHashTable(ops, entrySize, aLength); } void diff --git a/xpcom/glue/nsCOMArray.cpp b/xpcom/glue/nsCOMArray.cpp index 904cf70cb37c..3522f7b0d1e8 100644 --- a/xpcom/glue/nsCOMArray.cpp +++ b/xpcom/glue/nsCOMArray.cpp @@ -7,6 +7,7 @@ #include "nsCOMArray.h" #include "mozilla/MemoryReporting.h" +#include "mozilla/OperatorNewExtensions.h" #include "nsCOMPtr.h" @@ -20,13 +21,13 @@ public: // Zero out the value static inline void Construct(E* aE) { - new (static_cast(aE)) E(); + new (mozilla::KnownNotNull, static_cast(aE)) E(); } // Invoke the copy-constructor in place. template static inline void Construct(E* aE, const A& aArg) { - new (static_cast(aE)) E(aArg); + new (mozilla::KnownNotNull, static_cast(aE)) E(aArg); } // Invoke the destructor in place. static inline void Destruct(E* aE) diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index e6dde16b4442..543c422cb356 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -18,6 +18,7 @@ #include "mozilla/MathAlgorithms.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" +#include "mozilla/OperatorNewExtensions.h" #include "mozilla/ReverseIterator.h" #include "mozilla/TypeTraits.h" @@ -504,7 +505,7 @@ public: // ints. We don't want that because it can be a performance issue // and people don't expect it; nsTArray should work like a regular // C/C++ array in this respect. - new (static_cast(aE)) E; + new (mozilla::KnownNotNull, static_cast(aE)) E; } // Invoke the copy-constructor in place. template @@ -515,7 +516,7 @@ public: static_assert(!mozilla::IsSame::value, "For safety, we disallow constructing nsTArray elements " "from E* pointers. See bug 960591."); - new (static_cast(aE)) E(mozilla::Forward(aArg)); + new (mozilla::KnownNotNull, static_cast(aE)) E(mozilla::Forward(aArg)); } // Invoke the destructor in place. static inline void Destruct(E* aE) { aE->~E(); } diff --git a/xpcom/glue/nsTHashtable.h b/xpcom/glue/nsTHashtable.h index c2509e036a23..10d6435f059c 100644 --- a/xpcom/glue/nsTHashtable.h +++ b/xpcom/glue/nsTHashtable.h @@ -14,6 +14,7 @@ #include "mozilla/MemoryChecking.h" #include "mozilla/MemoryReporting.h" #include "mozilla/Move.h" +#include "mozilla/OperatorNewExtensions.h" #include "mozilla/PodOperations.h" #include "mozilla/TypeTraits.h" @@ -391,7 +392,7 @@ nsTHashtable::s_CopyEntry(PLDHashTable* aTable, EntryType* fromEntry = const_cast(static_cast(aFrom)); - new (aTo) EntryType(mozilla::Move(*fromEntry)); + new (mozilla::KnownNotNull, aTo) EntryType(mozilla::Move(*fromEntry)); fromEntry->~EntryType(); } @@ -409,7 +410,7 @@ void nsTHashtable::s_InitEntry(PLDHashEntryHdr* aEntry, const void* aKey) { - new (aEntry) EntryType(static_cast(aKey)); + new (mozilla::KnownNotNull, aEntry) EntryType(static_cast(aKey)); } class nsCycleCollectionTraversalCallback;