[all-commits] [llvm/llvm-project] 55c365: Add LLVM_ATTRIBUTE_NORETURN to report_bad_alloc_error
Aaron Puchert via All-commits
all-commits at lists.llvm.org
Tue Jun 9 08:46:23 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 55c365d247b1df358eddba5a98337c8ab9f1e7b0
https://github.com/llvm/llvm-project/commit/55c365d247b1df358eddba5a98337c8ab9f1e7b0
Author: Aaron Puchert <aaronpuchert at alice-dsl.net>
Date: 2020-06-09 (Tue, 09 Jun 2020)
Changed paths:
M llvm/include/llvm/Support/ErrorHandling.h
Log Message:
-----------
Add LLVM_ATTRIBUTE_NORETURN to report_bad_alloc_error
Summary:
The attribute just means that there will be no regular return, it still
leaves room for exceptions to be thrown. It is easily verified: there
are no direct returns and the last statement is either a throw or a call
to abort.
Having the annotation helps static analyzers with this code from
Support/MemAlloc.h (slightly simplified):
LLVM_ATTRIBUTE_RETURNS_NONNULL inline void *safe_malloc(size_t Sz) {
void *Result = std::malloc(Sz);
if (Result == nullptr)
report_bad_alloc_error("Allocation failed");
return Result;
}
Were report_bad_alloc_error to return regularly, the function would
return nullptr, contradicting the attribute.
Reviewers: rnk, sepavloff, dblaikie, aaron.ballman
Reviewed By: dblaikie, aaron.ballman
Differential Revision: https://reviews.llvm.org/D81318
More information about the All-commits
mailing list