[clang] ab895ad - [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#124446)

via cfe-commits cfe-commits at lists.llvm.org
Sun Jan 26 01:34:44 PST 2025


Author: Kazu Hirata
Date: 2025-01-26T01:34:41-08:00
New Revision: ab895ad2bfb6835e8c47d8e616edb6cadaf59b77

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

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

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

Added: 
    

Modified: 
    clang/lib/AST/DeclTemplate.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index e4cb7dcb16a456..de81bc64106f18 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -1463,7 +1463,7 @@ SourceRange VarTemplateSpecializationDecl::getSourceRange() const {
     assert(!Pattern.isNull() &&
            "Variable template specialization without pattern?");
     if (const auto *VTPSD =
-            Pattern.dyn_cast<VarTemplatePartialSpecializationDecl *>())
+            dyn_cast<VarTemplatePartialSpecializationDecl *>(Pattern))
       return VTPSD->getSourceRange();
     VarTemplateDecl *VTD = cast<VarTemplateDecl *>(Pattern);
     if (hasInit()) {


        


More information about the cfe-commits mailing list