Revert "Add InsertBraces to .clang-format"
This reverts commit fc97b3cffd
.
Reason for revert: Adds wrong braces in some cases. See crbug.com/1392808#c2
Original change's description:
> Add InsertBraces to .clang-format
>
> This formalizes curly braces as our style, even for single-line
> statements. It can also fix existing braceless if-else style violations.
>
> Consensus was reached in cxx@chromium.org, and we'll make use of
> .clang-format to enforce this. An upstream change will be made to make
> InsertBraces the default for BasedOnStyle: Chromium.
>
> It's expected that with clang-format enforcement we won't need to update
> our local style rules in tree. The new rule is not an exception to
> Google C++ style and `git cl format` will quickly teach the new
> behavior.
>
> As an example a small whitespace change was made to base/check.cc and
> then formatted using `git cl format --full`.
>
> Formatting the entire codebase is separable and may be separately
> proposed (but seems feasible per trying on //base, which passed
> trybots).
>
> Bug: 1392808
> Change-Id: I00384fbee13d01d8c5dbf98d54256c9cbcf9b62e
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4048911
> Reviewed-by: danakj <danakj@chromium.org>
> Owners-Override: danakj <danakj@chromium.org>
> Commit-Queue: danakj <danakj@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#1078642}
Bug: 1392808
Change-Id: Ideb2890143a5cde80d68908511083198b163060b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4076867
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: danakj <danakj@chromium.org>
Owners-Override: danakj <danakj@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1078718}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5a61567102
commit
1bae8bc87a
@ -7,10 +7,6 @@ BasedOnStyle: Chromium
|
||||
# 'int>>' if the file already contains at least one such instance.)
|
||||
Standard: Cpp11
|
||||
|
||||
# TODO(crbug.com/1392808): Remove when InsertBraces has been upstreamed into
|
||||
# the Chromium style (is implied by BasedOnStyle: Chromium).
|
||||
InsertBraces: true
|
||||
|
||||
# Make sure code like:
|
||||
# IPC_BEGIN_MESSAGE_MAP()
|
||||
# IPC_MESSAGE_HANDLER(WidgetHostViewHost_Update, OnUpdate)
|
||||
|
@ -40,9 +40,8 @@ void DumpOnceWithoutCrashing(LogMessage* log_message) {
|
||||
|
||||
// Note that dumping may fail if the crash handler hasn't been set yet. In
|
||||
// that case we want to try again on the next failing DCHECK.
|
||||
if (base::debug::DumpWithoutCrashingUnthrottled()) {
|
||||
if (base::debug::DumpWithoutCrashingUnthrottled())
|
||||
has_dumped.store(true, std::memory_order_relaxed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,9 +57,8 @@ class NotReachedLogMessage : public LogMessage {
|
||||
public:
|
||||
using LogMessage::LogMessage;
|
||||
~NotReachedLogMessage() override {
|
||||
if (severity() != logging::LOGGING_FATAL) {
|
||||
if (severity() != logging::LOGGING_FATAL)
|
||||
NotReachedDumpOnceWithoutCrashing(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
#else
|
||||
@ -82,9 +80,8 @@ class DCheckLogMessage : public LogMessage {
|
||||
public:
|
||||
using LogMessage::LogMessage;
|
||||
~DCheckLogMessage() override {
|
||||
if (severity() != logging::LOGGING_FATAL) {
|
||||
if (severity() != logging::LOGGING_FATAL)
|
||||
DCheckDumpOnceWithoutCrashing(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@ -93,9 +90,8 @@ class DCheckWin32ErrorLogMessage : public Win32ErrorLogMessage {
|
||||
public:
|
||||
using Win32ErrorLogMessage::Win32ErrorLogMessage;
|
||||
~DCheckWin32ErrorLogMessage() override {
|
||||
if (severity() != logging::LOGGING_FATAL) {
|
||||
if (severity() != logging::LOGGING_FATAL)
|
||||
DCheckDumpOnceWithoutCrashing(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
#elif BUILDFLAG(IS_POSIX) || BUILDFLAG(IS_FUCHSIA)
|
||||
@ -103,9 +99,8 @@ class DCheckErrnoLogMessage : public ErrnoLogMessage {
|
||||
public:
|
||||
using ErrnoLogMessage::ErrnoLogMessage;
|
||||
~DCheckErrnoLogMessage() override {
|
||||
if (severity() != logging::LOGGING_FATAL) {
|
||||
if (severity() != logging::LOGGING_FATAL)
|
||||
DCheckDumpOnceWithoutCrashing(this);
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif // BUILDFLAG(IS_WIN)
|
||||
|
@ -304,9 +304,8 @@ these:
|
||||
following:
|
||||
```c++
|
||||
DCHECK(foo);
|
||||
if (!foo) { // Eliminate this code.
|
||||
if (!foo) // Eliminate this code.
|
||||
...
|
||||
}
|
||||
|
||||
if (!bar) { // Replace this whole conditional with "DCHECK(bar);".
|
||||
NOTREACHED();
|
||||
|
Reference in New Issue
Block a user