[clang] 3fd296e - [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#123012)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 15 07:55:35 PST 2025


Author: Kazu Hirata
Date: 2025-01-15T07:55:28-08:00
New Revision: 3fd296ece69c0bab77ce0df9a128202746ffce94

URL: https://github.com/llvm/llvm-project/commit/3fd296ece69c0bab77ce0df9a128202746ffce94
DIFF: https://github.com/llvm/llvm-project/commit/3fd296ece69c0bab77ce0df9a128202746ffce94.diff

LOG: [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#123012)

Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //        isa<T>, cast<T> and the llvm::dyn_cast<T>

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect P to be nonnull.

Added: 
    

Modified: 
    clang/lib/AST/ASTImporter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index dec4c7221bc776..0669aa1b809c34 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -6376,7 +6376,7 @@ ExpectedDecl ASTNodeImporter::VisitClassTemplateSpecializationDecl(
   D2->setTemplateSpecializationKind(D->getTemplateSpecializationKind());
 
   if (auto P = D->getInstantiatedFrom()) {
-    if (auto *CTD = P.dyn_cast<ClassTemplateDecl *>()) {
+    if (auto *CTD = dyn_cast<ClassTemplateDecl *>(P)) {
       if (auto CTDorErr = import(CTD))
         D2->setInstantiationOf(*CTDorErr);
     } else {


        


More information about the cfe-commits mailing list