Detangle CHECK() failures from std::ostream
This adjusts code paths to not rely on streaming CHECK() failures to a std::ostream, which required both that an underlying ostream object exists and that the logged type was not the first argument streamed to a CHECK() failure. This intends to unlock further optimizations (can skip logging steps) as no std::ostream object needs to be generated. This may be used for skipping constant strings in official builds where they don't contribute to debuggability (i.e. streaming a string constant may for instance just return *this). Bug: 378574882 Change-Id: I594c1fec8ed8757ac54ecef5239de24db82a80cb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6332885 Owners-Override: Peter Kasting <pkasting@chromium.org> Auto-Submit: Peter Boström <pbos@chromium.org> Reviewed-by: Peter Kasting <pkasting@chromium.org> Commit-Queue: Peter Boström <pbos@chromium.org> Commit-Queue: Peter Kasting <pkasting@chromium.org> Cr-Commit-Position: refs/heads/main@{#1430504}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5478540d68
commit
abe9494f43
ash/wm/overview/birch
base
components/viz/common
services/webnn/public/cpp
third_party/blink/renderer/core/editing
@ -6,6 +6,7 @@
|
||||
|
||||
#include <array>
|
||||
#include <ostream>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include "ash/birch/birch_item.h"
|
||||
@ -125,20 +126,20 @@ bool IsLoadingState(State state) {
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
// Gets the string of given state.
|
||||
std::ostream& operator<<(std::ostream& stream, State state) {
|
||||
std::string_view ToString(State state) {
|
||||
switch (state) {
|
||||
case State::kLoading:
|
||||
return stream << "loading";
|
||||
return "loading";
|
||||
case State::kLoadingForInformedRestore:
|
||||
return stream << "loading for informed restore";
|
||||
return "loading for informed restore";
|
||||
case State::kLoadingByUser:
|
||||
return stream << "loading by user";
|
||||
return "loading by user";
|
||||
case State::kReloading:
|
||||
return stream << "reloading";
|
||||
return "reloading";
|
||||
case State::kShuttingDown:
|
||||
return stream << "shutting down";
|
||||
return "shutting down";
|
||||
case State::kNormal:
|
||||
return stream << "normal";
|
||||
return "normal";
|
||||
}
|
||||
}
|
||||
|
||||
@ -227,8 +228,8 @@ void BirchBarView::SetState(State state) {
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
if (!IsValidStateTransition(state_, state)) {
|
||||
NOTREACHED() << "Transition from state " << state_ << " to state " << state
|
||||
<< " is invalid.";
|
||||
NOTREACHED() << "Transition from state " << ToString(state_) << " to state "
|
||||
<< ToString(state) << " is invalid.";
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -135,8 +135,9 @@ class BASE_EXPORT CheckError {
|
||||
CheckError& operator=(const CheckError&) = delete;
|
||||
|
||||
template <typename T>
|
||||
std::ostream& operator<<(T&& streamed_type) {
|
||||
return stream() << streamed_type;
|
||||
CheckError& operator<<(T&& streamed_type) {
|
||||
stream() << streamed_type;
|
||||
return *this;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -91,7 +91,7 @@ class YUVReadbackTest : public testing::Test {
|
||||
auto parsed_json = base::JSONReader::ReadAndReturnValueWithError(json_data);
|
||||
CHECK(parsed_json.has_value())
|
||||
<< "JSON parsing failed (" << parsed_json.error().message
|
||||
<< ") JSON data:" << std::endl
|
||||
<< ") JSON data:\n"
|
||||
<< json_data;
|
||||
|
||||
CHECK(parsed_json->is_list());
|
||||
|
@ -72,7 +72,7 @@ class ScopedTraceTest : public testing::Test {
|
||||
base::JSONReader::ReadAndReturnValueWithError(json_data.json_output);
|
||||
CHECK(parsed_json.has_value())
|
||||
<< "JSON parsing failed (" << parsed_json.error().message
|
||||
<< ") JSON data:" << std::endl
|
||||
<< ") JSON data:\n"
|
||||
<< json_data.json_output;
|
||||
|
||||
CHECK(parsed_json->is_list());
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
|
||||
|
||||
#include <array>
|
||||
#include <string_view>
|
||||
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "third_party/blink/renderer/core/clipboard/clipboard_mime_types.h"
|
||||
@ -105,12 +106,12 @@ using mojom::blink::FormControlType;
|
||||
|
||||
namespace {
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, PositionMoveType type) {
|
||||
static const std::array<const char*, 3> kTexts = {
|
||||
std::string_view ToString(PositionMoveType type) {
|
||||
static const std::array<std::string_view, 3> kTexts = {
|
||||
"CodeUnit", "BackwardDeletion", "GraphemeCluster"};
|
||||
DCHECK_LT(static_cast<size_t>(type), kTexts.size())
|
||||
<< "Unknown PositionMoveType value";
|
||||
return os << kTexts[static_cast<size_t>(type)];
|
||||
return kTexts[static_cast<size_t>(type)];
|
||||
}
|
||||
|
||||
UChar WhitespaceRebalancingCharToAppend(const String& string,
|
||||
@ -743,7 +744,7 @@ PositionTemplate<Strategy> PreviousPositionOfAlgorithm(
|
||||
return PositionTemplate<Strategy>(
|
||||
node, PreviousGraphemeBoundaryOf(*node, offset));
|
||||
default:
|
||||
NOTREACHED() << "Unhandled moveType: " << move_type;
|
||||
NOTREACHED() << "Unhandled moveType: " << ToString(move_type);
|
||||
}
|
||||
}
|
||||
|
||||
@ -805,7 +806,7 @@ PositionTemplate<Strategy> NextPositionOfAlgorithm(
|
||||
return PositionTemplate<Strategy>::EditingPositionOf(
|
||||
node, NextGraphemeBoundaryOf(*node, offset));
|
||||
default:
|
||||
NOTREACHED() << "Unhandled moveType: " << move_type;
|
||||
NOTREACHED() << "Unhandled moveType: " << ToString(move_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user