Skip to content

Commit

Permalink
[snippy][NFC]: Mark snippy::fatal with [[noreturn]]
Browse files Browse the repository at this point in the history
For DiagnosticSeverity of llvm::DS_Error SnippyDiagnosticInfo
always uses report_fatal_error:

```
if (Severity == llvm::DS_Error)
  llvm::report_fatal_error(StringRef(Description), false);
```

So snippy::fatal will never return, since llvm::report_fatal_error
is also [[noreturn]].
  • Loading branch information
sizn-sc authored and sc-sw-publisher committed Oct 7, 2024
1 parent 2f5bfe3 commit 6a3797b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,13 @@ void notice(WarningName WN, llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
void warn(WarningName WN, llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
const llvm::Twine &Desc);

void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
const llvm::Twine &Desc);
[[noreturn]] void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
const llvm::Twine &Desc);

void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix, Error E);
[[noreturn]] void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
Error E);

void fatal(const llvm::Twine &Prefix, const llvm::Twine &Desc);
[[noreturn]] void fatal(const llvm::Twine &Prefix, const llvm::Twine &Desc);

} // namespace snippy

Expand Down
9 changes: 5 additions & 4 deletions llvm/tools/llvm-snippy/lib/Support/DiagnosticInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,21 @@ void warn(WarningName WN, llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
Ctx.diagnose(Diag);
}

void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
const llvm::Twine &Desc) {
[[noreturn]] void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
const llvm::Twine &Desc) {
SnippyDiagnosticInfo Diag(Prefix, Desc, llvm::DS_Error,
WarningName::NotAWarning);
Ctx.diagnose(Diag);
}

void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix, Error E) {
[[noreturn]] void fatal(llvm::LLVMContext &Ctx, const llvm::Twine &Prefix,
Error E) {
SnippyDiagnosticInfo Diag(Prefix, toString(std::move(E)), llvm::DS_Error,
WarningName::NotAWarning);
Ctx.diagnose(Diag);
}

void fatal(const llvm::Twine &Prefix, const llvm::Twine &Desc) {
[[noreturn]] void fatal(const llvm::Twine &Prefix, const llvm::Twine &Desc) {
llvm::LLVMContext Ctx;
SnippyDiagnosticInfo Diag(Prefix, Desc, llvm::DS_Error,
WarningName::NotAWarning);
Expand Down

0 comments on commit 6a3797b

Please sign in to comment.