-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[ByteCode] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) #115809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_PointerUnion_ByteCode
Nov 12, 2024
Merged
[ByteCode] Migrate away from PointerUnion::{is,get,dyn_cast} (NFC) #115809
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_001_PointerUnion_ByteCode
Nov 12, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<T>, cast<T> and the llvm::dyn_cast<T>
@llvm/pr-subscribers-clang Author: Kazu Hirata (kazutakahirata) ChangesNote that PointerUnion::{is,get,dyn_cast} have been soft deprecated in // FIXME: Replace the uses of is(), get() and dyn_cast() with Full diff: https://github.com/llvm/llvm-project/pull/115809.diff 4 Files Affected:
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 Decl *>(); }
- const Expr *asExpr() const { return Source.dyn_cast<const Expr *>(); }
+ const Decl *asDecl() const { return dyn_cast<const Decl *>(Source); }
+ const Expr *asExpr() const { return dyn_cast<const Expr *>(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<const FunctionDecl *>();
+ return dyn_cast<const FunctionDecl *>(Source);
}
const BlockExpr *getExpr() const {
- return Source.dyn_cast<const BlockExpr *>();
+ return dyn_cast<const BlockExpr *>(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<CXXConstructorDecl>(
- Source.dyn_cast<const FunctionDecl *>());
+ dyn_cast<const FunctionDecl *>(Source));
}
/// Checks if the function is a destructor.
bool isDestructor() const {
return isa_and_nonnull<CXXDestructorDecl>(
- Source.dyn_cast<const FunctionDecl *>());
+ dyn_cast<const FunctionDecl *>(Source));
}
/// Returns the parent record decl, if any.
const CXXRecordDecl *getParentDecl() const {
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(
- Source.dyn_cast<const FunctionDecl *>()))
+ dyn_cast<const FunctionDecl *>(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<CXXMethodDecl>(
- Source.dyn_cast<const FunctionDecl *>()))
+ dyn_cast<const FunctionDecl *>(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<CXXMethodDecl>(
- Source.dyn_cast<const FunctionDecl *>()))
+ dyn_cast<const FunctionDecl *>(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<const Stmt *>())
+ if (const auto *S = dyn_cast<const Stmt *>(Source))
return dyn_cast<Expr>(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 Stmt *>(); }
- const Decl *asDecl() const { return Source.dyn_cast<const Decl *>(); }
+ const Stmt *asStmt() const { return dyn_cast<const Stmt *>(Source); }
+ const Decl *asDecl() const { return dyn_cast<const Decl *>(Source); }
const Expr *asExpr() const;
operator bool() const { return !Source.isNull(); }
|
MaskRay
approved these changes
Nov 12, 2024
Groverkss
pushed a commit
to iree-org/llvm-project
that referenced
this pull request
Nov 15, 2024
…lvm#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<T>, cast<T> and the llvm::dyn_cast<T>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
clang:frontend
Language frontend issues, e.g. anything involving "Sema"
clang
Clang issues not falling into any other category
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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