[clang] [Clang][Sema][NFC]Use isa_and_nonnull to simplify the code and avoid build warning (PR #84181)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 6 07:46:49 PST 2024
https://github.com/ZERO-N updated https://github.com/llvm/llvm-project/pull/84181
>From 37a165ba331c796f41f68e6a29102ec9c1b608bf Mon Sep 17 00:00:00 2001
From: nwh <nwh_work at foxmail.com>
Date: Wed, 6 Mar 2024 23:45:40 +0800
Subject: [PATCH] [Clang][Sema][NFC]Use isa_and_nonnull to simplify the code
and avoid build warning
Signed-off-by: nwh <nwh_work at foxmail.com>
---
clang/lib/Sema/SemaExceptionSpec.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index 3563b4f683f079..00384f9dc16aa0 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -1017,13 +1017,13 @@ CanThrowResult Sema::canCalleeThrow(Sema &S, const Expr *E, const Decl *D,
SourceLocation Loc) {
// As an extension, we assume that __attribute__((nothrow)) functions don't
// throw.
- if (D && isa<FunctionDecl>(D) && D->hasAttr<NoThrowAttr>())
+ if (isa_and_nonnull<FunctionDecl>(D) && D->hasAttr<NoThrowAttr>())
return CT_Cannot;
QualType T;
// In C++1z, just look at the function type of the callee.
- if (S.getLangOpts().CPlusPlus17 && E && isa<CallExpr>(E)) {
+ if (S.getLangOpts().CPlusPlus17 && isa_and_nonnull<CallExpr>(E)) {
E = cast<CallExpr>(E)->getCallee();
T = E->getType();
if (T->isSpecificPlaceholderType(BuiltinType::BoundMember)) {
More information about the cfe-commits
mailing list