[clang] c8ba57e - [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#125157)

via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 31 07:50:08 PST 2025


Author: Kazu Hirata
Date: 2025-01-31T07:50:04-08:00
New Revision: c8ba57ec23ddf6ab9a178dbabc8b61924f0f36fa

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

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

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 NodeOrVector to be nonnull.

Added: 
    

Modified: 
    clang/lib/AST/ParentMapContext.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/ParentMapContext.cpp b/clang/lib/AST/ParentMapContext.cpp
index 2e77e1d7c4c644..e9387ec79c3738 100644
--- a/clang/lib/AST/ParentMapContext.cpp
+++ b/clang/lib/AST/ParentMapContext.cpp
@@ -395,7 +395,7 @@ class ParentMapContext::ParentMap::ASTVisitor
       if (!isa<ParentVector *>(NodeOrVector)) {
         auto *Vector = new ParentVector(
             1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
-        delete NodeOrVector.template dyn_cast<DynTypedNode *>();
+        delete dyn_cast<DynTypedNode *>(NodeOrVector);
         NodeOrVector = Vector;
       }
 


        


More information about the cfe-commits mailing list