mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 12:54:11 +08:00
[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:
committed by
PyTorch MergeBot
parent
321bdcb372
commit
e0bba37d66
@ -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)
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user