[codemod] Add [[noreturn]] to 2 files inc caffe2/c10/util/TypeCast.cpp (#129575)

Summary: LLVM-15 has a warning `-Wno-return` which can be used to identify functions that do not return. Qualifying these functions with `[[noreturn]]` is a perf optimization.

Test Plan: Sandcastle

Reviewed By: dmm-fb

Differential Revision: D59003594

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129575
Approved by: https://github.com/Skylion007
This commit is contained in:
Richard Barnes
2024-06-27 17:23:22 +00:00
committed by PyTorch MergeBot
parent 321bdcb372
commit e0bba37d66
2 changed files with 2 additions and 2 deletions

View File

@ -2,7 +2,7 @@
namespace c10 {
void report_overflow(const char* name) {
[[noreturn]] void report_overflow(const char* name) {
std::ostringstream oss;
oss << "value cannot be converted to type " << name << " without overflow";
throw std::runtime_error(oss.str()); // rather than domain_error (issue 33562)

View File

@ -177,7 +177,7 @@ C10_HOST_DEVICE To convert(From f) {
}
// Define separately to avoid being inlined and prevent code-size bloat
C10_API void report_overflow(const char* name);
[[noreturn]] C10_API void report_overflow(const char* name);
template <typename To, typename From>
To checked_convert(From f, const char* name) {