[clang] [ByteCode] Migrate away from PointerUnion::{is, get, dyn_cast} (NFC) (PR #115809)

2024-11-11 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/115809
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ByteCode] Migrate away from PointerUnion::{is, get, dyn_cast} (NFC) (PR #115809)

2024-11-11 Thread Fangrui Song via cfe-commits

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


https://github.com/llvm/llvm-project/pull/115809
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ByteCode] Migrate away from PointerUnion::{is, get, dyn_cast} (NFC) (PR #115809)

2024-11-11 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes

Note that PointerUnion::{is,get,dyn_cast} have been soft deprecated in
PointerUnion.h:

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


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


4 Files Affected:

- (modified) clang/lib/AST/ByteCode/Descriptor.h (+2-2) 
- (modified) clang/lib/AST/ByteCode/Function.h (+7-7) 
- (modified) clang/lib/AST/ByteCode/Source.cpp (+1-1) 
- (modified) clang/lib/AST/ByteCode/Source.h (+2-2) 


``diff
diff --git a/clang/lib/AST/ByteCode/Descriptor.h 
b/clang/lib/AST/ByteCode/Descriptor.h
index bcb635e157f009..a73e28d2e600e8 100644
--- a/clang/lib/AST/ByteCode/Descriptor.h
+++ b/clang/lib/AST/ByteCode/Descriptor.h
@@ -201,8 +201,8 @@ struct Descriptor final {
   SourceLocation getLocation() const;
   SourceInfo getLoc() const;
 
-  const Decl *asDecl() const { return Source.dyn_cast(); }
-  const Expr *asExpr() const { return Source.dyn_cast(); }
+  const Decl *asDecl() const { return dyn_cast(Source); }
+  const Expr *asExpr() const { return dyn_cast(Source); }
   const DeclTy &getSource() const { return Source; }
 
   const ValueDecl *asValueDecl() const {
diff --git a/clang/lib/AST/ByteCode/Function.h 
b/clang/lib/AST/ByteCode/Function.h
index 7fe9aeb1101204..409a80f59f1e94 100644
--- a/clang/lib/AST/ByteCode/Function.h
+++ b/clang/lib/AST/ByteCode/Function.h
@@ -94,10 +94,10 @@ class Function final {
 
   /// Returns the original FunctionDecl.
   const FunctionDecl *getDecl() const {
-return Source.dyn_cast();
+return dyn_cast(Source);
   }
   const BlockExpr *getExpr() const {
-return Source.dyn_cast();
+return dyn_cast(Source);
   }
 
   /// Returns the name of the function decl this code
@@ -146,18 +146,18 @@ class Function final {
   /// Checks if the function is a constructor.
   bool isConstructor() const {
 return isa_and_nonnull(
-Source.dyn_cast());
+dyn_cast(Source));
   }
   /// Checks if the function is a destructor.
   bool isDestructor() const {
 return isa_and_nonnull(
-Source.dyn_cast());
+dyn_cast(Source));
   }
 
   /// Returns the parent record decl, if any.
   const CXXRecordDecl *getParentDecl() const {
 if (const auto *MD = dyn_cast_if_present(
-Source.dyn_cast()))
+dyn_cast(Source)))
   return MD->getParent();
 return nullptr;
   }
@@ -166,7 +166,7 @@ class Function final {
   /// which we generate custom byte code for.
   bool isLambdaStaticInvoker() const {
 if (const auto *MD = dyn_cast_if_present(
-Source.dyn_cast()))
+dyn_cast(Source)))
   return MD->isLambdaStaticInvoker();
 return false;
   }
@@ -175,7 +175,7 @@ class Function final {
   /// of a lambda record decl.
   bool isLambdaCallOperator() const {
 if (const auto *MD = dyn_cast_if_present(
-Source.dyn_cast()))
+dyn_cast(Source)))
   return clang::isLambdaCallOperator(MD);
 return false;
   }
diff --git a/clang/lib/AST/ByteCode/Source.cpp 
b/clang/lib/AST/ByteCode/Source.cpp
index 77796b00ca52cb..55296ddd8c5583 100644
--- a/clang/lib/AST/ByteCode/Source.cpp
+++ b/clang/lib/AST/ByteCode/Source.cpp
@@ -33,7 +33,7 @@ SourceRange SourceInfo::getRange() const {
 }
 
 const Expr *SourceInfo::asExpr() const {
-  if (const auto *S = Source.dyn_cast())
+  if (const auto *S = dyn_cast(Source))
 return dyn_cast(S);
   return nullptr;
 }
diff --git a/clang/lib/AST/ByteCode/Source.h b/clang/lib/AST/ByteCode/Source.h
index 88b5ec7740df51..3b025535d00b19 100644
--- a/clang/lib/AST/ByteCode/Source.h
+++ b/clang/lib/AST/ByteCode/Source.h
@@ -83,8 +83,8 @@ class SourceInfo final {
   SourceLocation getLoc() const;
   SourceRange getRange() const;
 
-  const Stmt *asStmt() const { return Source.dyn_cast(); }
-  const Decl *asDecl() const { return Source.dyn_cast(); }
+  const Stmt *asStmt() const { return dyn_cast(Source); }
+  const Decl *asDecl() const { return dyn_cast(Source); }
   const Expr *asExpr() const;
 
   operator bool() const { return !Source.isNull(); }

``




https://github.com/llvm/llvm-project/pull/115809
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ByteCode] Migrate away from PointerUnion::{is, get, dyn_cast} (NFC) (PR #115809)

2024-11-11 Thread Kazu Hirata via cfe-commits

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

Note that PointerUnion::{is,get,dyn_cast} have been soft deprecated in
PointerUnion.h:

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


>From 55ea5ca478a35a7bdc1b95dd8c53d5bfdb3462d3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Mon, 11 Nov 2024 10:15:45 -0800
Subject: [PATCH] [ByteCode] Migrate away from PointerUnion::{is,get,dyn_cast}
 (NFC)

Note that PointerUnion::{is,get,dyn_cast} have been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast
---
 clang/lib/AST/ByteCode/Descriptor.h |  4 ++--
 clang/lib/AST/ByteCode/Function.h   | 14 +++---
 clang/lib/AST/ByteCode/Source.cpp   |  2 +-
 clang/lib/AST/ByteCode/Source.h |  4 ++--
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/clang/lib/AST/ByteCode/Descriptor.h 
b/clang/lib/AST/ByteCode/Descriptor.h
index bcb635e157f009..a73e28d2e600e8 100644
--- a/clang/lib/AST/ByteCode/Descriptor.h
+++ b/clang/lib/AST/ByteCode/Descriptor.h
@@ -201,8 +201,8 @@ struct Descriptor final {
   SourceLocation getLocation() const;
   SourceInfo getLoc() const;
 
-  const Decl *asDecl() const { return Source.dyn_cast(); }
-  const Expr *asExpr() const { return Source.dyn_cast(); }
+  const Decl *asDecl() const { return dyn_cast(Source); }
+  const Expr *asExpr() const { return dyn_cast(Source); }
   const DeclTy &getSource() const { return Source; }
 
   const ValueDecl *asValueDecl() const {
diff --git a/clang/lib/AST/ByteCode/Function.h 
b/clang/lib/AST/ByteCode/Function.h
index 7fe9aeb1101204..409a80f59f1e94 100644
--- a/clang/lib/AST/ByteCode/Function.h
+++ b/clang/lib/AST/ByteCode/Function.h
@@ -94,10 +94,10 @@ class Function final {
 
   /// Returns the original FunctionDecl.
   const FunctionDecl *getDecl() const {
-return Source.dyn_cast();
+return dyn_cast(Source);
   }
   const BlockExpr *getExpr() const {
-return Source.dyn_cast();
+return dyn_cast(Source);
   }
 
   /// Returns the name of the function decl this code
@@ -146,18 +146,18 @@ class Function final {
   /// Checks if the function is a constructor.
   bool isConstructor() const {
 return isa_and_nonnull(
-Source.dyn_cast());
+dyn_cast(Source));
   }
   /// Checks if the function is a destructor.
   bool isDestructor() const {
 return isa_and_nonnull(
-Source.dyn_cast());
+dyn_cast(Source));
   }
 
   /// Returns the parent record decl, if any.
   const CXXRecordDecl *getParentDecl() const {
 if (const auto *MD = dyn_cast_if_present(
-Source.dyn_cast()))
+dyn_cast(Source)))
   return MD->getParent();
 return nullptr;
   }
@@ -166,7 +166,7 @@ class Function final {
   /// which we generate custom byte code for.
   bool isLambdaStaticInvoker() const {
 if (const auto *MD = dyn_cast_if_present(
-Source.dyn_cast()))
+dyn_cast(Source)))
   return MD->isLambdaStaticInvoker();
 return false;
   }
@@ -175,7 +175,7 @@ class Function final {
   /// of a lambda record decl.
   bool isLambdaCallOperator() const {
 if (const auto *MD = dyn_cast_if_present(
-Source.dyn_cast()))
+dyn_cast(Source)))
   return clang::isLambdaCallOperator(MD);
 return false;
   }
diff --git a/clang/lib/AST/ByteCode/Source.cpp 
b/clang/lib/AST/ByteCode/Source.cpp
index 77796b00ca52cb..55296ddd8c5583 100644
--- a/clang/lib/AST/ByteCode/Source.cpp
+++ b/clang/lib/AST/ByteCode/Source.cpp
@@ -33,7 +33,7 @@ SourceRange SourceInfo::getRange() const {
 }
 
 const Expr *SourceInfo::asExpr() const {
-  if (const auto *S = Source.dyn_cast())
+  if (const auto *S = dyn_cast(Source))
 return dyn_cast(S);
   return nullptr;
 }
diff --git a/clang/lib/AST/ByteCode/Source.h b/clang/lib/AST/ByteCode/Source.h
index 88b5ec7740df51..3b025535d00b19 100644
--- a/clang/lib/AST/ByteCode/Source.h
+++ b/clang/lib/AST/ByteCode/Source.h
@@ -83,8 +83,8 @@ class SourceInfo final {
   SourceLocation getLoc() const;
   SourceRange getRange() const;
 
-  const Stmt *asStmt() const { return Source.dyn_cast(); }
-  const Decl *asDecl() const { return Source.dyn_cast(); }
+  const Stmt *asStmt() const { return dyn_cast(Source); }
+  const Decl *asDecl() const { return dyn_cast(Source); }
   const Expr *asExpr() const;
 
   operator bool() const { return !Source.isNull(); }

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits