Author: Victor Chernyakin
Date: 2025-12-17T20:14:45-08:00
New Revision: 686c2a14766aab8aec6580b9622ad4f551797973

URL: 
https://github.com/llvm/llvm-project/commit/686c2a14766aab8aec6580b9622ad4f551797973
DIFF: 
https://github.com/llvm/llvm-project/commit/686c2a14766aab8aec6580b9622ad4f551797973.diff

LOG: [clang-tidy][NFC] Prefer `isa<T>` over `T::classof` (#172772)

We overwhelmingly prefer `isa` already, and I would argue it's more
readable.

Added: 
    

Modified: 
    clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
    
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.cpp
    clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp

Removed: 
    


################################################################################
diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
index d821c40f2760a..1c74b90be8ec1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SwitchMissingDefaultCaseCheck.cpp
@@ -17,7 +17,7 @@ namespace {
 AST_MATCHER(SwitchStmt, hasDefaultCase) {
   const SwitchCase *Case = Node.getSwitchCaseList();
   while (Case) {
-    if (DefaultStmt::classof(Case))
+    if (isa<DefaultStmt>(Case))
       return true;
 
     Case = Case->getNextSwitchCase();

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.cpp
index 15fb53c5c57b7..618554663ab91 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidCapturingLambdaCoroutinesCheck.cpp
@@ -17,7 +17,7 @@ namespace clang::tidy::cppcoreguidelines {
 namespace {
 AST_MATCHER(LambdaExpr, hasCoroutineBody) {
   const Stmt *Body = Node.getBody();
-  return Body != nullptr && CoroutineBodyStmt::classof(Body);
+  return Body != nullptr && isa<CoroutineBodyStmt>(Body);
 }
 
 AST_MATCHER(LambdaExpr, hasCaptures) { return Node.capture_size() != 0U; }

diff  --git 
a/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
index 75bf8aa8734d5..8691db34ac298 100644
--- a/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
@@ -30,7 +30,7 @@ DiagnosticBuilder 
NoexceptMoveConstructorCheck::reportMissingNoexcept(
   return diag(FuncDecl->getLocation(),
               "move %select{assignment operator|constructor}0s should "
               "be marked noexcept")
-         << CXXConstructorDecl::classof(FuncDecl);
+         << isa<CXXConstructorDecl>(FuncDecl);
 }
 
 void NoexceptMoveConstructorCheck::reportNoexceptEvaluatedToFalse(
@@ -38,7 +38,7 @@ void 
NoexceptMoveConstructorCheck::reportNoexceptEvaluatedToFalse(
   diag(NoexceptExpr->getExprLoc(),
        "noexcept specifier on the move %select{assignment "
        "operator|constructor}0 evaluates to 'false'")
-      << CXXConstructorDecl::classof(FuncDecl);
+      << isa<CXXConstructorDecl>(FuncDecl);
 }
 
 } // namespace clang::tidy::performance


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to