llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

PointerUnion::dyn_cast has been soft-deprecated in favor of
llvm::dyn_cast and llvm::dyn_cast_if_present.  This patch replaces the
former with llvm::dyn_cast where the operand is guaranteed to be
nonnull.

Note that VDTemplSpec-&gt;getInstantiatedFrom() here returns
getSpecializedTemplateOrPartial() because the enclosing if statement
checks isTemplateInstantiation(...).  In turn,
getSpecializedTemplateOrPartial() always returns a nonnull pointer by
construction.

Assisted-by: Antigravity


---
Full diff: https://github.com/llvm/llvm-project/pull/231074.diff


1 Files Affected:

- (modified) clang/lib/AST/Decl.cpp (+2-2) 


``````````diff
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 0c79fe07f8d0c..969339a00d1a6 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -2717,7 +2717,7 @@ VarDecl *VarDecl::getTemplateInstantiationPattern() const 
{
   if (auto *VDTemplSpec = dyn_cast<VarTemplateSpecializationDecl>(VD)) {
     if (isTemplateInstantiation(VDTemplSpec->getTemplateSpecializationKind())) 
{
       auto From = VDTemplSpec->getInstantiatedFrom();
-      if (auto *VTD = From.dyn_cast<VarTemplateDecl *>()) {
+      if (auto *VTD = dyn_cast<VarTemplateDecl *>(From)) {
         while (!VTD->isMemberSpecialization()) {
           auto *NewVTD = VTD->getInstantiatedFromMemberTemplate();
           if (!NewVTD)
@@ -2727,7 +2727,7 @@ VarDecl *VarDecl::getTemplateInstantiationPattern() const 
{
         return VTD->getTemplatedDecl();
       }
       if (auto *VTPSD =
-              From.dyn_cast<VarTemplatePartialSpecializationDecl *>()) {
+              dyn_cast<VarTemplatePartialSpecializationDecl *>(From)) {
         while (!VTPSD->isMemberSpecialization()) {
           auto *NewVTPSD = VTPSD->getInstantiatedFromMember();
           if (!NewVTPSD)

``````````

</details>


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

Reply via email to