Skip to content

Commit f522b75

Browse files
committed
Address review feedback
1 parent 97c482c commit f522b75

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ Improvements to Clang's diagnostics
705705
- Clang now does not issue a warning about returning from a function declared with
706706
the ``[[noreturn]]`` attribute when the function body is ended with a call via
707707
pointer, provided it can be proven that the pointer only points to
708-
``[[noreturn]]`` functions..
708+
``[[noreturn]]`` functions.
709709

710710
Improvements to Clang's time-trace
711711
----------------------------------

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -403,29 +403,27 @@ static bool isNoexcept(const FunctionDecl *FD) {
403403
return false;
404404
}
405405

406+
/// Checks if the given expression is a reference to a function with
407+
/// 'noreturn' attribute.
408+
static bool isReferenceToNoReturn(const Expr *E) {
409+
if (auto *DRef = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts()))
410+
if (auto *FD = dyn_cast<FunctionDecl>(DRef->getDecl()))
411+
return FD->isNoReturn();
412+
return false;
413+
}
414+
406415
/// Checks if the given variable, which is assumed to be a function pointer, is
407416
/// initialized with a function having 'noreturn' attribute.
408417
static bool isInitializedWithNoReturn(const VarDecl *VD) {
409418
if (const Expr *Init = VD->getInit()) {
410419
if (auto *ListInit = dyn_cast<InitListExpr>(Init);
411420
ListInit && ListInit->getNumInits() > 0)
412421
Init = ListInit->getInit(0);
413-
if (auto *DeclRef = dyn_cast<DeclRefExpr>(Init->IgnoreParenCasts()))
414-
if (auto *FD = dyn_cast<FunctionDecl>(DeclRef->getDecl()))
415-
return FD->isNoReturn();
422+
return isReferenceToNoReturn(Init);
416423
}
417424
return false;
418425
}
419426

420-
/// Checks if the given expression is a reference to a function with
421-
/// 'noreturn' attribute.
422-
static bool isReferenceToNoReturn(const Expr *E) {
423-
if (auto *DRef = dyn_cast<DeclRefExpr>(E->IgnoreParenCasts()))
424-
if (auto *FD = dyn_cast<FunctionDecl>(DRef->getDecl()))
425-
return FD->isNoReturn();
426-
return false;
427-
}
428-
429427
namespace {
430428

431429
/// Looks for statements, that can define value of the given variable.

0 commit comments

Comments
 (0)