aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-12-06 01:45:56 -0800
committerGitHub <noreply@github.com>2024-12-06 01:45:56 -0800
commit91d6e10cca4ea8d50927aba024f33c9076785d3a (patch)
treecbd24698449b7aa81f1186c354d606fc8afb54f8
parent6f190cabe0a0409aecbf000ee78aa786dfc715f7 (diff)
downloadllvm-91d6e10cca4ea8d50927aba024f33c9076785d3a.zip
llvm-91d6e10cca4ea8d50927aba024f33c9076785d3a.tar.gz
llvm-91d6e10cca4ea8d50927aba024f33c9076785d3a.tar.bz2
[CodeGen] Migrate away from PointerUnion::{is,get} (NFC) (#118600)
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> I'm not touching PointerUnion::dyn_cast for now because it's a bit complicated; we could blindly migrate it to dyn_cast_if_present, but we should probably use dyn_cast when the operand is known to be non-null.
-rw-r--r--clang/lib/CodeGen/CGCall.cpp2
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp14
-rw-r--r--clang/lib/CodeGen/ConstantInitBuilder.cpp12
3 files changed, 14 insertions, 14 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 7c8d962..3cefc9da 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -4529,7 +4529,7 @@ void CodeGenFunction::EmitCallArgs(
ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
MD->param_type_end());
} else {
- const auto *FPT = Prototype.P.get<const FunctionProtoType *>();
+ const auto *FPT = cast<const FunctionProtoType *>(Prototype.P);
IsVariadic = FPT->isVariadic();
ExplicitCC = FPT->getExtInfo().getCC();
ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 6a58602..2deb91f 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7770,7 +7770,7 @@ private:
if (const auto *Base = Data.dyn_cast<const CXXRecordDecl *>())
getPlainLayout(Base, Layout, /*AsBase=*/true);
else
- Layout.push_back(Data.get<const FieldDecl *>());
+ Layout.push_back(cast<const FieldDecl *>(Data));
}
}
@@ -8333,9 +8333,9 @@ public:
MapCombinedInfoTy &CombinedInfo, llvm::OpenMPIRBuilder &OMPBuilder,
const llvm::DenseSet<CanonicalDeclPtr<const Decl>> &SkipVarSet =
llvm::DenseSet<CanonicalDeclPtr<const Decl>>()) const {
- assert(CurDir.is<const OMPExecutableDirective *>() &&
+ assert(isa<const OMPExecutableDirective *>(CurDir) &&
"Expect a executable directive");
- const auto *CurExecDir = CurDir.get<const OMPExecutableDirective *>();
+ const auto *CurExecDir = cast<const OMPExecutableDirective *>(CurDir);
generateAllInfoForClauses(CurExecDir->clauses(), CombinedInfo, OMPBuilder,
SkipVarSet);
}
@@ -8345,9 +8345,9 @@ public:
/// in \a CombinedInfo).
void generateAllInfoForMapper(MapCombinedInfoTy &CombinedInfo,
llvm::OpenMPIRBuilder &OMPBuilder) const {
- assert(CurDir.is<const OMPDeclareMapperDecl *>() &&
+ assert(isa<const OMPDeclareMapperDecl *>(CurDir) &&
"Expect a declare mapper directive");
- const auto *CurMapperDir = CurDir.get<const OMPDeclareMapperDecl *>();
+ const auto *CurMapperDir = cast<const OMPDeclareMapperDecl *>(CurDir);
generateAllInfoForClauses(CurMapperDir->clauses(), CombinedInfo,
OMPBuilder);
}
@@ -8519,9 +8519,9 @@ public:
DeclComponentLists.emplace_back(MCL, OMPC_MAP_tofrom, Unknown,
/*IsImpicit = */ true, nullptr,
nullptr);
- assert(CurDir.is<const OMPExecutableDirective *>() &&
+ assert(isa<const OMPExecutableDirective *>(CurDir) &&
"Expect a executable directive");
- const auto *CurExecDir = CurDir.get<const OMPExecutableDirective *>();
+ const auto *CurExecDir = cast<const OMPExecutableDirective *>(CurDir);
bool HasMapBasePtr = false;
bool HasMapArraySec = false;
for (const auto *C : CurExecDir->getClausesOfKind<OMPMapClause>()) {
diff --git a/clang/lib/CodeGen/ConstantInitBuilder.cpp b/clang/lib/CodeGen/ConstantInitBuilder.cpp
index 549d5dd..ddbf3ef 100644
--- a/clang/lib/CodeGen/ConstantInitBuilder.cpp
+++ b/clang/lib/CodeGen/ConstantInitBuilder.cpp
@@ -20,10 +20,10 @@ using namespace CodeGen;
llvm::Type *ConstantInitFuture::getType() const {
assert(Data && "dereferencing null future");
- if (Data.is<llvm::Constant*>()) {
- return Data.get<llvm::Constant*>()->getType();
+ if (const auto *C = dyn_cast<llvm::Constant *>(Data)) {
+ return C->getType();
} else {
- return Data.get<ConstantInitBuilderBase*>()->Buffer[0]->getType();
+ return cast<ConstantInitBuilderBase *>(Data)->Buffer[0]->getType();
}
}
@@ -37,10 +37,10 @@ void ConstantInitFuture::abandon() {
void ConstantInitFuture::installInGlobal(llvm::GlobalVariable *GV) {
assert(Data && "installing null future");
- if (Data.is<llvm::Constant*>()) {
- GV->setInitializer(Data.get<llvm::Constant*>());
+ if (auto *C = dyn_cast<llvm::Constant *>(Data)) {
+ GV->setInitializer(C);
} else {
- auto &builder = *Data.get<ConstantInitBuilderBase*>();
+ auto &builder = *cast<ConstantInitBuilderBase *>(Data);
assert(builder.Buffer.size() == 1);
builder.setGlobalInitializer(GV, builder.Buffer[0]);
builder.Buffer.clear();