Skip to content

Commit

Permalink
Fix LOG(FATAL) compile errors
Browse files Browse the repository at this point in the history
This disables C4722 for intentionally-[[noreturn]] destructors and IWYUs
base/immediate_crash.h for fuchsia_logging.cc.

Bug: chromium:40254046
Change-Id: I9df3ab96d4d6489485bca55748dfe806a1f0f444
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/mini_chromium/+/5907038
Reviewed-by: Mark Mentovai <mark@chromium.org>
  • Loading branch information
pbos committed Oct 3, 2024
1 parent 4027559 commit d288241
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions base/fuchsia/fuchsia_logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <iomanip>

#include "base/immediate_crash.h"

namespace logging {

ZxLogMessage::ZxLogMessage(const char* function,
Expand Down
22 changes: 22 additions & 0 deletions base/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,22 @@ void LogMessage::Init(const char* function) {
message_start_ = stream_.str().size();
}

// We intentionally don't return from these destructors. Disable MSVC's warning
// about the destructor never returning as we do so intentionally here.
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4722)
#endif

LogMessageFatal::~LogMessageFatal() {
Flush();
base::ImmediateCrash();
}

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif

#if BUILDFLAG(IS_WIN)

unsigned long GetLastSystemErrorCode() {
Expand All @@ -503,12 +514,23 @@ void Win32ErrorLogMessage::AppendError() {
stream() << ": " << SystemErrorCodeToString(err_);
}

// We intentionally don't return from these destructors. Disable MSVC's warning
// about the destructor never returning as we do so intentionally here.
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(push)
#pragma warning(disable : 4722)
#endif

Win32ErrorLogMessageFatal::~Win32ErrorLogMessageFatal() {
AppendError();
Flush();
base::ImmediateCrash();
}

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif

#elif BUILDFLAG(IS_POSIX)

ErrnoLogMessage::ErrnoLogMessage(const char* function,
Expand Down

0 comments on commit d288241

Please sign in to comment.