[clang] [Clang][Sema][NFC]Use isa_and_nonnull to simplify the code (PR #84181)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 6 06:49:31 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: None (ZERO-N)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/84181.diff
1 Files Affected:
- (modified) clang/lib/Sema/SemaExceptionSpec.cpp (+3-2)
``````````diff
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index 3563b4f683f079..0ce00dd0f847ec 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -21,6 +21,7 @@
#include "clang/Basic/SourceManager.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/Support/Casting.h"
#include <optional>
namespace clang {
@@ -1017,13 +1018,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)) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/84181
More information about the cfe-commits
mailing list