Bug 1267551 - Use MOZ_MUST_USE in js/public/UbiNodeCensus.h; r=jimb

This commit is contained in:
Nick Fitzgerald 2016-06-17 13:52:43 +01:00
parent 7b5d1178b4
commit 8d76510cde

View File

@ -7,6 +7,7 @@
#ifndef js_UbiNodeCensus_h
#define js_UbiNodeCensus_h
#include "mozilla/Attributes.h"
#include "mozilla/Move.h"
#include <algorithm>
@ -104,13 +105,14 @@ struct CountType {
// Implement the 'count' method for counts returned by this CountType
// instance's 'newCount' method.
virtual bool count(CountBase& count,
mozilla::MallocSizeOf mallocSizeOf,
const Node& node) = 0;
virtual MOZ_MUST_USE 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 bool report(JSContext* cx, CountBase& count, MutableHandleValue report) = 0;
virtual MOZ_MUST_USE bool report(JSContext* cx, CountBase& count,
MutableHandleValue report) = 0;
};
using CountTypePtr = js::UniquePtr<CountType>;
@ -134,7 +136,7 @@ class CountBase {
{ }
// Categorize and count |node| as appropriate for this count's type.
bool count(mozilla::MallocSizeOf mallocSizeOf, const Node& node) {
MOZ_MUST_USE bool count(mozilla::MallocSizeOf mallocSizeOf, const Node& node) {
total_++;
auto id = node.identifier();
@ -157,7 +159,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.
bool report(JSContext* cx, MutableHandleValue report) {
MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) {
return type.report(cx, *this, report);
}
@ -201,7 +203,7 @@ struct Census {
explicit Census(JSContext* cx) : cx(cx), atomsZone(nullptr) { }
bool init();
MOZ_MUST_USE bool init();
};
// A BreadthFirst handler type that conducts a census, using a CountBase to
@ -218,24 +220,24 @@ class CensusHandler {
mallocSizeOf(mallocSizeOf)
{ }
bool report(JSContext* cx, MutableHandleValue report) {
MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) {
return rootCount->report(cx, report);
}
// This class needs to retain no per-node data.
class NodeData { };
bool operator() (BreadthFirst<CensusHandler>& traversal,
Node origin, const Edge& edge,
NodeData* referentData, bool first);
MOZ_MUST_USE bool operator() (BreadthFirst<CensusHandler>& traversal,
Node origin, const Edge& edge,
NodeData* referentData, bool first);
};
using CensusTraversal = BreadthFirst<CensusHandler>;
// Examine the census options supplied by the API consumer, and (among other
// things) use that to build a CountType tree.
bool ParseCensusOptions(JSContext* cx, Census& census, HandleObject options,
CountTypePtr& outResult);
MOZ_MUST_USE bool ParseCensusOptions(JSContext* cx, Census& census, HandleObject options,
CountTypePtr& outResult);
// Parse the breakdown language (as described in
// js/src/doc/Debugger/Debugger.Memory.md) into a CountTypePtr. A null pointer