Repository: google/filament
File: libs/utils/include/utils/Panic.h (C/C++)

Code before:
    char const* mLiteral;
};

template<typename T>
class TPanicStream : public PanicStream {
public:
    using PanicStream::PanicStream;
    ~TPanicStream() noexcept(false) UTILS_NORETURN {
        T::panic(mFunction, mFile, mLine, mLiteral, mStream.c_str());
    }
};

template<typename PanicType>
class FlagGuardedStream : public PanicStream {
public:
    FlagGuardedStream(bool enable, char const* function, char const* file, int line,
            char const* condition)
        : PanicStream(function, file, line, condition),
          mEnablePanic(enable) {}
    ~FlagGuardedStream() noexcept(false) {
        if (mEnablePanic) {
            PanicType::panic(mFunction, mFile, mLine, mLiteral, mStream.c_str());
        } else {
            LOG(WARNING) << "Failed [" << mLiteral << "]" << "\n  file=" << mFile
                         << "\n  function=" << mFunction << "\n  line=" << mLine << "\n  info=\""
                         << mStream.c_str() << "\"";
        }
    }

private:
    bool mEnablePanic;
};

} // namespace details

// -----------------------------------------------------------------------------------------------
}  // namespace utils

#ifndef NDEBUG
#   define PANIC_FILE(F) (F)
#   define PANIC_FUNCTION __PRETTY_FUNCTION__
#else
#   define PANIC_FILE(F) ""
#   define PANIC_FUNCTION __func__
#endif


#define FILAMENT_CHECK_CONDITION_IMPL(cond)                                                        \
    switch (0)                                                                                     \
    case 0:                                                                                        \
    default:                                                                                       \

Review comment (suggestion):
This is not dependent on `PanicType` so there is no need to inline it. Basically I think the `else` should be a function call implemented in the CPP.

Code after:
};

template<typename T>
class TPanicStream : public PanicStream {
public:
    using PanicStream::PanicStream;
    ~TPanicStream() noexcept(false) UTILS_NORETURN {
        T::panic(mFunction, mFile, mLine, mLiteral, mStream.c_str());
    }
};

template<typename PanicType>
class FlagGuardedStream : public PanicStream {
public:
    FlagGuardedStream(bool enable, char const* function, char const* file, int line,
            char const* condition)
        : PanicStream(function, file, line, condition),
          mEnablePanic(enable) {}
    ~FlagGuardedStream() noexcept(false) {
        if (mEnablePanic) {
            PanicType::panic(mFunction, mFile, mLine, mLiteral, mStream.c_str());
        } else {
            logWarning();
        }
    }

private:
    void logWarning() noexcept;

    bool mEnablePanic;
};

} // namespace details

// -----------------------------------------------------------------------------------------------
}  // namespace utils

#ifndef NDEBUG
#   define PANIC_FILE(F) (F)
#   define PANIC_FUNCTION __PRETTY_FUNCTION__
#else
#   define PANIC_FILE(F) ""
#   define PANIC_FUNCTION __func__
#endif


#define FILAMENT_CHECK_CONDITION_IMPL(cond)                                                        \
    switch (0)                                                                                     \
    case 0:                                                                                        \
    default:                                                                                       \
        UTILS_VERY_LIKELY(cond) ? (void)0 : ::utils::details::Voidify()&&