Add braces to C++ single-line loops and conditionals (NFC) (#2973)

This makes code easier to read and more consistent between C++ and Java.
Also update clang-format settings to always add a line break (even if no braces are used).
This commit is contained in:
Peter Johnson
2020-12-28 12:58:06 -08:00
committed by GitHub
parent 0291a3ff56
commit 2aed432b4b
634 changed files with 10716 additions and 3938 deletions

View File

@@ -22,21 +22,24 @@ static void DefaultLogger(unsigned int level, const char* file,
}
wpi::StringRef levelmsg;
if (level >= 50)
if (level >= 50) {
levelmsg = "CRITICAL: ";
else if (level >= 40)
} else if (level >= 40) {
levelmsg = "ERROR: ";
else if (level >= 30)
} else if (level >= 30) {
levelmsg = "WARNING: ";
else
} else {
return;
}
oss << "NT: " << levelmsg << msg << " (" << file << ':' << line << ")\n";
wpi::errs() << oss.str();
}
LoggerImpl::LoggerImpl(int inst) : m_inst(inst) {}
void LoggerImpl::Start() { DoStart(m_inst); }
void LoggerImpl::Start() {
DoStart(m_inst);
}
unsigned int LoggerImpl::Add(
std::function<void(const LogMessage& msg)> callback, unsigned int min_level,
@@ -52,11 +55,15 @@ unsigned int LoggerImpl::AddPolled(unsigned int poller_uid,
unsigned int LoggerImpl::GetMinLevel() {
auto thr = GetThread();
if (!thr) return NT_LOG_INFO;
if (!thr) {
return NT_LOG_INFO;
}
unsigned int level = NT_LOG_INFO;
for (size_t i = 0; i < thr->m_listeners.size(); ++i) {
const auto& listener = thr->m_listeners[i];
if (listener && listener.min_level < level) level = listener.min_level;
if (listener && listener.min_level < level) {
level = listener.min_level;
}
}
return level;
}
@@ -67,8 +74,9 @@ void LoggerImpl::Log(unsigned int level, const char* file, unsigned int line,
const char* filename = wpi::sys::path::filename(file).data();
{
auto thr = GetThread();
if (!thr || thr->m_listeners.empty())
if (!thr || thr->m_listeners.empty()) {
DefaultLogger(level, filename, line, msg);
}
}
Send(UINT_MAX, 0, level, filename, line, msg);
}