handle potentially throwing functions in no_cfi_icall

Define templates for potentially throwing functions at C++17
when noexcept becomes part of a function's type.

Change-Id: I8e9cbf4b0702ad6b9b9a9d7560418908045fd11a
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/2454835
Reviewed-by: Eric Astor <epastor@google.com>
This commit is contained in:
Joshua Peraza 2020-10-26 10:38:33 -07:00
parent 71e8ec7987
commit 5368dc6389

View File

@ -76,6 +76,28 @@ struct FunctorTraits<R(__stdcall*)(Args...) noexcept> {
};
#endif // OS_WIN && ARCH_CPU_X86
#if __cplusplus >= 201703L
// These specializations match functions which are not explicitly declared
// noexcept. They must only be present at C++17 when noexcept is part of a
// function's type. If they are present earlier, they redefine the
// specializations above.
template <typename R, typename... Args>
struct FunctorTraits<R (*)(Args...)> {
template <typename Function, typename... RunArgs>
DISABLE_CFI_ICALL static R Invoke(Function&& function, RunArgs&&... args) {
return std::forward<Function>(function)(std::forward<RunArgs>(args)...);
}
};
template <typename R, typename... Args>
struct FunctorTraits<R (*)(Args..., ...)> {
template <typename Function, typename... RunArgs>
DISABLE_CFI_ICALL static R Invoke(Function&& function, RunArgs&&... args) {
return std::forward<Function>(function)(std::forward<RunArgs>(args)...);
}
};
#endif
} // namespace
//! \brief Disables cfi-icall for calls made through a function pointer.