-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
[lldb] Migrate away from PointerUnion::{is,get} (NFC) #122420
Open
kazutakahirata
wants to merge
1
commit into
llvm:main
Choose a base branch
from
kazutakahirata:cleanup_001_PointerUnion_lldb
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[lldb] Migrate away from PointerUnion::{is,get} (NFC) #122420
kazutakahirata
wants to merge
1
commit into
llvm:main
from
kazutakahirata:cleanup_001_PointerUnion_lldb
+29
−29
Conversation
This file contains 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} 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>
kazutakahirata
requested review from
nikic
and removed request for
JDevlieghere
January 10, 2025 05:24
@llvm/pr-subscribers-lldb Author: Kazu Hirata (kazutakahirata) ChangesNote that PointerUnion::{is,get} 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/122420.diff 1 Files Affected:
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index b16cb114bec88e..6452baa4f84afd 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -123,7 +123,7 @@ class ELFRelocation {
static elf_sxword RelocAddend64(const ELFRelocation &rel);
- bool IsRela() { return (reloc.is<ELFRela *>()); }
+ bool IsRela() { return (llvm::isa<ELFRela *>(reloc)); }
private:
typedef llvm::PointerUnion<ELFRel *, ELFRela *> RelocUnion;
@@ -144,74 +144,74 @@ ELFRelocation::ELFRelocation(unsigned type) {
}
ELFRelocation::~ELFRelocation() {
- if (reloc.is<ELFRel *>())
- delete reloc.get<ELFRel *>();
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(reloc))
+ delete elfrel;
else
- delete reloc.get<ELFRela *>();
+ delete llvm::cast<ELFRela *>(reloc);
}
bool ELFRelocation::Parse(const lldb_private::DataExtractor &data,
lldb::offset_t *offset) {
- if (reloc.is<ELFRel *>())
- return reloc.get<ELFRel *>()->Parse(data, offset);
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(reloc))
+ return elfrel->Parse(data, offset);
else
- return reloc.get<ELFRela *>()->Parse(data, offset);
+ return llvm::cast<ELFRela *>(reloc)->Parse(data, offset);
}
unsigned ELFRelocation::RelocType32(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
- return ELFRel::RelocType32(*rel.reloc.get<ELFRel *>());
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
+ return ELFRel::RelocType32(*elfrel);
else
- return ELFRela::RelocType32(*rel.reloc.get<ELFRela *>());
+ return ELFRela::RelocType32(*llvm::cast<ELFRela *>(rel.reloc));
}
unsigned ELFRelocation::RelocType64(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
- return ELFRel::RelocType64(*rel.reloc.get<ELFRel *>());
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
+ return ELFRel::RelocType64(*elfrel);
else
- return ELFRela::RelocType64(*rel.reloc.get<ELFRela *>());
+ return ELFRela::RelocType64(*llvm::cast<ELFRela *>(rel.reloc));
}
unsigned ELFRelocation::RelocSymbol32(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
- return ELFRel::RelocSymbol32(*rel.reloc.get<ELFRel *>());
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
+ return ELFRel::RelocSymbol32(*elfrel);
else
- return ELFRela::RelocSymbol32(*rel.reloc.get<ELFRela *>());
+ return ELFRela::RelocSymbol32(*llvm::cast<ELFRela *>(rel.reloc));
}
unsigned ELFRelocation::RelocSymbol64(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
- return ELFRel::RelocSymbol64(*rel.reloc.get<ELFRel *>());
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
+ return ELFRel::RelocSymbol64(*elfrel);
else
- return ELFRela::RelocSymbol64(*rel.reloc.get<ELFRela *>());
+ return ELFRela::RelocSymbol64(*llvm::cast<ELFRela *>(rel.reloc));
}
elf_addr ELFRelocation::RelocOffset32(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
- return rel.reloc.get<ELFRel *>()->r_offset;
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
+ return elfrel->r_offset;
else
- return rel.reloc.get<ELFRela *>()->r_offset;
+ return llvm::cast<ELFRela *>(rel.reloc)->r_offset;
}
elf_addr ELFRelocation::RelocOffset64(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
- return rel.reloc.get<ELFRel *>()->r_offset;
+ if (auto *elfrel = llvm::dyn_cast<ELFRel *>(rel.reloc))
+ return elfrel->r_offset;
else
- return rel.reloc.get<ELFRela *>()->r_offset;
+ return llvm::cast<ELFRela *>(rel.reloc)->r_offset;
}
elf_sxword ELFRelocation::RelocAddend32(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
+ if (llvm::isa<ELFRel *>(rel.reloc))
return 0;
else
- return rel.reloc.get<ELFRela *>()->r_addend;
+ return llvm::cast<ELFRela *>(rel.reloc)->r_addend;
}
elf_sxword ELFRelocation::RelocAddend64(const ELFRelocation &rel) {
- if (rel.reloc.is<ELFRel *>())
+ if (llvm::isa<ELFRel *>(rel.reloc))
return 0;
else
- return rel.reloc.get<ELFRela *>()->r_addend;
+ return llvm::cast<ELFRela *>(rel.reloc)->r_addend;
}
static user_id_t SegmentID(size_t PHdrIndex) {
|
nikic
approved these changes
Jan 10, 2025
DavidSpickett
approved these changes
Jan 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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} 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