[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124074)

2025-01-23 Thread Kazu Hirata via cfe-commits

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


[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124074)

2025-01-23 Thread Nikita Popov via cfe-commits

https://github.com/nikic approved this pull request.


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


[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124074)

2025-01-22 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes

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

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

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


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


1 Files Affected:

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


``diff
diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index ddbe2136a671f3..36ef1fc8c79db0 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1537,9 +1537,9 @@ void JSONNodeDumper::VisitExprWithCleanups(const 
ExprWithCleanups *EWC) {
   if (EWC->getNumObjects()) {
 JOS.attributeArray("cleanups", [this, EWC] {
   for (const ExprWithCleanups::CleanupObject &CO : EWC->getObjects())
-if (auto *BD = CO.dyn_cast()) {
+if (auto *BD = dyn_cast(CO)) {
   JOS.value(createBareDeclRef(BD));
-} else if (auto *CLE = CO.dyn_cast()) {
+} else if (auto *CLE = dyn_cast(CO)) {
   llvm::json::Object Obj;
   Obj["id"] = createPointerRepresentation(CLE);
   Obj["kind"] = CLE->getStmtClassName();

``




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


[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #124074)

2025-01-22 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/124074

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

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

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


>From c9889e71a1de9b3904cceb02a1d325b4d401b04d Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Wed, 22 Jan 2025 00:28:16 -0800
Subject: [PATCH] [AST] Migrate away from PointerUnion::dyn_cast (NFC)

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

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

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 CO to be nonnull.
---
 clang/lib/AST/JSONNodeDumper.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/JSONNodeDumper.cpp b/clang/lib/AST/JSONNodeDumper.cpp
index ddbe2136a671f3..36ef1fc8c79db0 100644
--- a/clang/lib/AST/JSONNodeDumper.cpp
+++ b/clang/lib/AST/JSONNodeDumper.cpp
@@ -1537,9 +1537,9 @@ void JSONNodeDumper::VisitExprWithCleanups(const 
ExprWithCleanups *EWC) {
   if (EWC->getNumObjects()) {
 JOS.attributeArray("cleanups", [this, EWC] {
   for (const ExprWithCleanups::CleanupObject &CO : EWC->getObjects())
-if (auto *BD = CO.dyn_cast()) {
+if (auto *BD = dyn_cast(CO)) {
   JOS.value(createBareDeclRef(BD));
-} else if (auto *CLE = CO.dyn_cast()) {
+} else if (auto *CLE = dyn_cast(CO)) {
   llvm::json::Object Obj;
   Obj["id"] = createPointerRepresentation(CLE);
   Obj["kind"] = CLE->getStmtClassName();

___
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits