[clang] [clang] Replace X && isa<Y>(X) with isa_and_nonnull<Y>(X). NFC (PR #94987)
DonĂ¡t Nagy via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 10 09:58:21 PDT 2024
================
@@ -2772,7 +2772,7 @@ fixVariable(const VarDecl *VD, FixitStrategy::Kind K,
// also covers call-operator of lamdas
isa<CXXMethodDecl>(FD) ||
// skip when the function body is a try-block
- (FD->hasBody() && isa<CXXTryStmt>(FD->getBody())) ||
+ isa_and_nonnull<CXXTryStmt>(FD->getBody()) ||
----------------
NagyDonat wrote:
The comment before the definition of `getBody()` says that
```
/// NOTE: For checking if there is a body, use hasBody() instead, to avoid
/// unnecessary AST de-serialization of the body.
```
so perhaps it would be better to keep `hasBody()`. (Although I don't know whether performance is relevant at this point -- if we're handling an unusual case, then the runtime doesn't matter.)
https://github.com/llvm/llvm-project/pull/94987
More information about the cfe-commits
mailing list