[clang-tools-extra] [Clang-Tidy] Handle nested-name-specifier in "llvm-prefer-isa-or-dyn-cast-in-conditionals" (PR #155982)
Yanzuo Liu via cfe-commits
cfe-commits at lists.llvm.org
Sat Aug 30 19:17:05 PDT 2025
================
@@ -76,6 +136,16 @@ bool foo(Y *y, Z *z) {
// CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
// CHECK-FIXES: if (isa_and_nonnull<Y>(z->bar()))
+ if (z->bar() && cast_or_null<Y>(z->bar()))
+ return true;
+ // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+ // CHECK-FIXES: if (isa_and_nonnull<Y>(z->bar()))
+
+ if (z->bar() && cast_if_present<Y>(z->bar()))
+ return true;
+ // CHECK-MESSAGES: :[[@LINE-2]]:7: warning: isa_and_nonnull<> is preferred
+ // CHECK-FIXES: if (isa_and_nonnull<Y>(z->bar()))
----------------
zwuis wrote:
I want to revert this part and add support in a separate PR that
- Keep `_present` and `_or_null` as written.
- Replace `x && isa<Y>(x)` with what configuration files choose (`isa_and_nonnull` or `isa_and_present`).
WDYT?
https://github.com/llvm/llvm-project/pull/155982
More information about the cfe-commits
mailing list