Bug 1627490 - Replace MOZ_MUST_USE with [[nodiscard]] in tools/profiler. r=mstange
authorChris Peterson <cpeterson@mozilla.com>
Tue, 07 Apr 2020 18:38:52 +0000
changeset 590133 a876822484b0d51fd90decb354062d8c2868b0b7
parent 590132 fbd06f30bb6d768b320c23dcd8a8a8f262e8763e
child 590134 7d4ac54cd44a76b04cd022a081f006691fdc3205
push id2335
push userffxbld-merge
push dateMon, 25 May 2020 13:47:24 +0000
treeherdermozilla-release@69ca1d06f46a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1627490
milestone77.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1627490 - Replace MOZ_MUST_USE with [[nodiscard]] in tools/profiler. r=mstange Also move MOZ_MUST_USE before function declarations' specifiers and return type. While clang and gcc's __attribute__((warn_unused_result)) can appear before, between, or after function specifiers and return types, the [[nodiscard]] attribute must precede the function specifiers. Differential Revision: https://phabricator.services.mozilla.com/D69739
tools/profiler/core/ProfileBufferEntry.h
tools/profiler/core/platform.cpp
tools/profiler/public/ChildProfilerController.h
tools/profiler/public/GeckoProfiler.h
--- a/tools/profiler/core/ProfileBufferEntry.h
+++ b/tools/profiler/core/ProfileBufferEntry.h
@@ -388,33 +388,33 @@ class UniqueStacks {
     static void rekey(StackKey& aKey, const StackKey& aNewKey) {
       aKey = aNewKey;
     }
   };
 
   explicit UniqueStacks(JITFrameInfo&& aJITFrameInfo);
 
   // Return a StackKey for aFrame as the stack's root frame (no prefix).
-  MOZ_MUST_USE StackKey BeginStack(const FrameKey& aFrame);
+  [[nodiscard]] StackKey BeginStack(const FrameKey& aFrame);
 
   // Return a new StackKey that is obtained by appending aFrame to aStack.
-  MOZ_MUST_USE StackKey AppendFrame(const StackKey& aStack,
-                                    const FrameKey& aFrame);
+  [[nodiscard]] StackKey AppendFrame(const StackKey& aStack,
+                                     const FrameKey& aFrame);
 
   // Look up frame keys for the given JIT address, and ensure that our frame
   // table has entries for the returned frame keys. The JSON for these frames
   // is taken from mJITInfoRanges.
   // aBufferPosition is needed in order to look up the correct JIT frame info
   // object in mJITInfoRanges.
-  MOZ_MUST_USE mozilla::Maybe<mozilla::Vector<UniqueStacks::FrameKey>>
+  [[nodiscard]] mozilla::Maybe<mozilla::Vector<UniqueStacks::FrameKey>>
   LookupFramesForJITAddressFromBufferPos(void* aJITAddress,
                                          uint64_t aBufferPosition);
 
-  MOZ_MUST_USE uint32_t GetOrAddFrameIndex(const FrameKey& aFrame);
-  MOZ_MUST_USE uint32_t GetOrAddStackIndex(const StackKey& aStack);
+  [[nodiscard]] uint32_t GetOrAddFrameIndex(const FrameKey& aFrame);
+  [[nodiscard]] uint32_t GetOrAddStackIndex(const StackKey& aStack);
 
   void SpliceFrameTableElements(SpliceableJSONWriter& aWriter);
   void SpliceStackTableElements(SpliceableJSONWriter& aWriter);
 
  private:
   void StreamNonJITFrame(const FrameKey& aFrame);
   void StreamStack(const StackKey& aStack);
 
--- a/tools/profiler/core/platform.cpp
+++ b/tools/profiler/core/platform.cpp
@@ -734,17 +734,17 @@ class ActivePS {
                      uint32_t aFeatures, const char** aFilters,
                      uint32_t aFilterCount, uint64_t aActiveBrowsingContextID,
                      const Maybe<double>& aDuration) {
     MOZ_ASSERT(!sInstance);
     sInstance = new ActivePS(aLock, aCapacity, aInterval, aFeatures, aFilters,
                              aFilterCount, aActiveBrowsingContextID, aDuration);
   }
 
-  static MOZ_MUST_USE SamplerThread* Destroy(PSLockRef aLock) {
+  [[nodiscard]] static SamplerThread* Destroy(PSLockRef aLock) {
     MOZ_ASSERT(sInstance);
     auto samplerThread = sInstance->mSamplerThread;
     delete sInstance;
     sInstance = nullptr;
 
     return samplerThread;
   }
 
@@ -789,17 +789,17 @@ class ActivePS {
   }
 
   static bool ShouldProfileThread(PSLockRef aLock, ThreadInfo* aInfo) {
     MOZ_ASSERT(sInstance);
     return ((aInfo->IsMainThread() || FeatureThreads(aLock)) &&
             sInstance->ThreadSelected(aInfo->Name()));
   }
 
-  static MOZ_MUST_USE bool AppendPostSamplingCallback(
+  [[nodiscard]] static bool AppendPostSamplingCallback(
       PSLockRef, PostSamplingCallback&& aCallback);
 
   // Writes out the current active configuration of the profile.
   static void WriteActiveConfiguration(PSLockRef aLock, JSONWriter& aWriter,
                                        const char* aPropertyName = nullptr) {
     if (!sInstance) {
       if (aPropertyName) {
         aWriter.NullProperty(aPropertyName);
@@ -2761,17 +2761,17 @@ class SamplerThread {
     UniquePtr<PostSamplingCallbackListItem> mPrev;
     PostSamplingCallback mCallback;
 
     PostSamplingCallbackListItem(UniquePtr<PostSamplingCallbackListItem> aPrev,
                                  PostSamplingCallback&& aCallback)
         : mPrev(std::move(aPrev)), mCallback(std::move(aCallback)) {}
   };
 
-  MOZ_MUST_USE UniquePtr<PostSamplingCallbackListItem>
+  [[nodiscard]] UniquePtr<PostSamplingCallbackListItem>
   TakePostSamplingCallbacks(PSLockRef) {
     return std::move(mPostSamplingCallbackList);
   }
 
   static void InvokePostSamplingCallbacks(
       UniquePtr<PostSamplingCallbackListItem> aCallbacks,
       SamplingState aSamplingState) {
     if (!aCallbacks) {
@@ -2817,17 +2817,17 @@ class SamplerThread {
   // Post-sampling callbacks are kept in a simple linked list, which will be
   // stolen by the sampler thread at the end of its next run.
   UniquePtr<PostSamplingCallbackListItem> mPostSamplingCallbackList;
 
   SamplerThread(const SamplerThread&) = delete;
   void operator=(const SamplerThread&) = delete;
 };
 
-// static MOZ_MUST_USE
+// [[nodiscard]] static
 bool ActivePS::AppendPostSamplingCallback(PSLockRef aLock,
                                           PostSamplingCallback&& aCallback) {
   if (!sInstance || !sInstance->mSamplerThread) {
     return false;
   }
   sInstance->mSamplerThread->AppendPostSamplingCallback(aLock,
                                                         std::move(aCallback));
   return true;
@@ -4306,17 +4306,17 @@ void profiler_ensure_started(PowerOfTwo3
   }
 
   if (startedProfiler) {
     NotifyProfilerStarted(aCapacity, aDuration, aInterval, aFeatures, aFilters,
                           aFilterCount, aActiveBrowsingContextID);
   }
 }
 
-static MOZ_MUST_USE SamplerThread* locked_profiler_stop(PSLockRef aLock) {
+[[nodiscard]] static SamplerThread* locked_profiler_stop(PSLockRef aLock) {
   LOG("locked_profiler_stop");
 
   MOZ_RELEASE_ASSERT(CorePS::Exists() && ActivePS::Exists(aLock));
 
   // At the very start, clear RacyFeatures.
   RacyFeatures::SetInactive();
 
 #if defined(GP_OS_android)
@@ -4421,17 +4421,17 @@ bool profiler_is_paused() {
 
   if (!ActivePS::Exists(lock)) {
     return false;
   }
 
   return ActivePS::IsPaused(lock);
 }
 
-/* MOZ_MUST_USE */ bool profiler_callback_after_sampling(
+/* [[nodiscard]] */ bool profiler_callback_after_sampling(
     PostSamplingCallback&& aCallback) {
   LOG("profiler_callback_after_sampling");
 
   MOZ_RELEASE_ASSERT(CorePS::Exists());
 
   PSAutoLock lock(gPSMutex);
 
   return ActivePS::AppendPostSamplingCallback(lock, std::move(aCallback));
--- a/tools/profiler/public/ChildProfilerController.h
+++ b/tools/profiler/public/ChildProfilerController.h
@@ -24,17 +24,17 @@ class PProfilerParent;
 // It manages a background thread that ProfilerChild runs on.
 class ChildProfilerController final {
  public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ChildProfilerController)
 
   static already_AddRefed<ChildProfilerController> Create(
       mozilla::ipc::Endpoint<PProfilerChild>&& aEndpoint);
 
-  MOZ_MUST_USE nsCString GrabShutdownProfileAndShutdown();
+  [[nodiscard]] nsCString GrabShutdownProfileAndShutdown();
   void Shutdown();
 
  private:
   ChildProfilerController();
   ~ChildProfilerController();
   void Init(mozilla::ipc::Endpoint<PProfilerChild>&& aEndpoint);
   void ShutdownAndMaybeGrabShutdownProfileFirst(nsCString* aOutShutdownProfile);
 
--- a/tools/profiler/public/GeckoProfiler.h
+++ b/tools/profiler/public/GeckoProfiler.h
@@ -433,17 +433,17 @@ using PostSamplingCallback = std::functi
 // Install a callback to be invoked at the end of the next sampling loop.
 // - `false` if profiler is not active, `aCallback` will stay untouched.
 // - `true` if `aCallback` was successfully moved-from into internal storage,
 //   and *will* be invoked at the end of the next sampling cycle. Note that this
 //   will happen on the Sampler thread, and will block further sampling, so
 //   please be mindful not to block for a long time (e.g., just dispatch a
 //   runnable to another thread.) Calling profiler functions from the callback
 //   is allowed.
-MOZ_MUST_USE bool profiler_callback_after_sampling(
+[[nodiscard]] bool profiler_callback_after_sampling(
     PostSamplingCallback&& aCallback);
 
 // Pause and resume the profiler. No-ops if the profiler is inactive. While
 // paused the profile will not take any samples and will not record any data
 // into its buffers. The profiler remains fully initialized in this state.
 // Timeline markers will still be stored. This feature will keep JavaScript
 // profiling enabled, thus allowing toggling the profiler without invalidating
 // the JIT.