Enable log macros to work with no args (#4475)

This is enabled by the C++20 __VA_OPT__ feature.
Uses of "{}" format string were updated.
Some warning suppressions were required for older clang versions.
Also improve codegen of wpi::Logger::Log(), frc::ReportError(), and frc::MakeError();
these generate better and less redundant code if they use fmt::string_view for the
format string instead of templating on it.
This commit is contained in:
Tyler Veness
2022-10-19 10:49:27 -07:00
committed by GitHub
parent 878cc8defb
commit 1fc098e696
70 changed files with 373 additions and 338 deletions

View File

@@ -21,7 +21,7 @@ SynchronousInterrupt::SynchronousInterrupt(DigitalSource& source)
SynchronousInterrupt::SynchronousInterrupt(DigitalSource* source)
: m_source{source, wpi::NullDeleter<DigitalSource>()} {
if (m_source == nullptr) {
FRC_CheckErrorStatus(frc::err::NullParameter, "{}", "Source is null");
FRC_CheckErrorStatus(frc::err::NullParameter, "Source is null");
} else {
InitSynchronousInterrupt();
}
@@ -30,7 +30,7 @@ SynchronousInterrupt::SynchronousInterrupt(
std::shared_ptr<DigitalSource> source)
: m_source{std::move(source)} {
if (m_source == nullptr) {
FRC_CheckErrorStatus(frc::err::NullParameter, "{}", "Source is null");
FRC_CheckErrorStatus(frc::err::NullParameter, "Source is null");
} else {
InitSynchronousInterrupt();
}
@@ -39,14 +39,14 @@ SynchronousInterrupt::SynchronousInterrupt(
void SynchronousInterrupt::InitSynchronousInterrupt() {
int32_t status = 0;
m_handle = HAL_InitializeInterrupts(&status);
FRC_CheckErrorStatus(status, "{}", "Interrupt failed to initialize");
FRC_CheckErrorStatus(status, "Interrupt failed to initialize");
HAL_RequestInterrupts(m_handle, m_source->GetPortHandleForRouting(),
static_cast<HAL_AnalogTriggerType>(
m_source->GetAnalogTriggerTypeForRouting()),
&status);
FRC_CheckErrorStatus(status, "{}", "Interrupt request failed");
FRC_CheckErrorStatus(status, "Interrupt request failed");
HAL_SetInterruptUpSourceEdge(m_handle, true, false, &status);
FRC_CheckErrorStatus(status, "{}", "Interrupt setting up source edge failed");
FRC_CheckErrorStatus(status, "Interrupt setting up source edge failed");
}
SynchronousInterrupt::~SynchronousInterrupt() {
@@ -79,19 +79,19 @@ void SynchronousInterrupt::SetInterruptEdges(bool risingEdge,
bool fallingEdge) {
int32_t status = 0;
HAL_SetInterruptUpSourceEdge(m_handle, risingEdge, fallingEdge, &status);
FRC_CheckErrorStatus(status, "{}", "Interrupt setting edges failed");
FRC_CheckErrorStatus(status, "Interrupt setting edges failed");
}
void SynchronousInterrupt::WakeupWaitingInterrupt() {
int32_t status = 0;
HAL_ReleaseWaitingInterrupt(m_handle, &status);
FRC_CheckErrorStatus(status, "{}", "Interrupt wakeup failed");
FRC_CheckErrorStatus(status, "Interrupt wakeup failed");
}
units::second_t SynchronousInterrupt::GetRisingTimestamp() {
int32_t status = 0;
auto ts = HAL_ReadInterruptRisingTimestamp(m_handle, &status);
FRC_CheckErrorStatus(status, "{}", "Interrupt rising timestamp failed");
FRC_CheckErrorStatus(status, "Interrupt rising timestamp failed");
units::microsecond_t ms{static_cast<double>(ts)};
return ms;
}
@@ -99,7 +99,7 @@ units::second_t SynchronousInterrupt::GetRisingTimestamp() {
units::second_t SynchronousInterrupt::GetFallingTimestamp() {
int32_t status = 0;
auto ts = HAL_ReadInterruptFallingTimestamp(m_handle, &status);
FRC_CheckErrorStatus(status, "{}", "Interrupt falling timestamp failed");
FRC_CheckErrorStatus(status, "Interrupt falling timestamp failed");
units::microsecond_t ms{static_cast<double>(ts)};
return ms;
}