[clang] 657dc6d - [AST] Migrate away from PointerUnion::dyn_cast (NFC) (#125335)

via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 1 08:13:24 PST 2025


Author: Kazu Hirata
Date: 2025-02-01T08:13:20-08:00
New Revision: 657dc6d05e8e20d5c3b41161ace7fba5d2cb6e26

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

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

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 InVectors.front() and P to be nonnull.

Added: 
    

Modified: 
    clang/lib/AST/TemplateName.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/TemplateName.cpp b/clang/lib/AST/TemplateName.cpp
index 3a1eb1ca12f453..9e0a7dc2b8cdcb 100644
--- a/clang/lib/AST/TemplateName.cpp
+++ b/clang/lib/AST/TemplateName.cpp
@@ -144,7 +144,7 @@ TemplateName::TemplateName(DeducedTemplateStorage *Deduced)
 bool TemplateName::isNull() const { return Storage.isNull(); }
 
 TemplateName::NameKind TemplateName::getKind() const {
-  if (auto *ND = Storage.dyn_cast<Decl *>()) {
+  if (auto *ND = dyn_cast<Decl *>(Storage)) {
     if (isa<UsingShadowDecl>(ND))
       return UsingTemplate;
     assert(isa<TemplateDecl>(ND));


        


More information about the cfe-commits mailing list