Skip to content

Commit 91d6e10

Browse files
[CodeGen] Migrate away from PointerUnion::{is,get} (NFC) (llvm#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.
1 parent 6f190ca commit 91d6e10

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4529,7 +4529,7 @@ void CodeGenFunction::EmitCallArgs(
45294529
ArgTypes.assign(MD->param_type_begin() + ParamsToSkip,
45304530
MD->param_type_end());
45314531
} else {
4532-
const auto *FPT = Prototype.P.get<const FunctionProtoType *>();
4532+
const auto *FPT = cast<const FunctionProtoType *>(Prototype.P);
45334533
IsVariadic = FPT->isVariadic();
45344534
ExplicitCC = FPT->getExtInfo().getCC();
45354535
ArgTypes.assign(FPT->param_type_begin() + ParamsToSkip,

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7770,7 +7770,7 @@ class MappableExprsHandler {
77707770
if (const auto *Base = Data.dyn_cast<const CXXRecordDecl *>())
77717771
getPlainLayout(Base, Layout, /*AsBase=*/true);
77727772
else
7773-
Layout.push_back(Data.get<const FieldDecl *>());
7773+
Layout.push_back(cast<const FieldDecl *>(Data));
77747774
}
77757775
}
77767776

@@ -8333,9 +8333,9 @@ class MappableExprsHandler {
83338333
MapCombinedInfoTy &CombinedInfo, llvm::OpenMPIRBuilder &OMPBuilder,
83348334
const llvm::DenseSet<CanonicalDeclPtr<const Decl>> &SkipVarSet =
83358335
llvm::DenseSet<CanonicalDeclPtr<const Decl>>()) const {
8336-
assert(CurDir.is<const OMPExecutableDirective *>() &&
8336+
assert(isa<const OMPExecutableDirective *>(CurDir) &&
83378337
"Expect a executable directive");
8338-
const auto *CurExecDir = CurDir.get<const OMPExecutableDirective *>();
8338+
const auto *CurExecDir = cast<const OMPExecutableDirective *>(CurDir);
83398339
generateAllInfoForClauses(CurExecDir->clauses(), CombinedInfo, OMPBuilder,
83408340
SkipVarSet);
83418341
}
@@ -8345,9 +8345,9 @@ class MappableExprsHandler {
83458345
/// in \a CombinedInfo).
83468346
void generateAllInfoForMapper(MapCombinedInfoTy &CombinedInfo,
83478347
llvm::OpenMPIRBuilder &OMPBuilder) const {
8348-
assert(CurDir.is<const OMPDeclareMapperDecl *>() &&
8348+
assert(isa<const OMPDeclareMapperDecl *>(CurDir) &&
83498349
"Expect a declare mapper directive");
8350-
const auto *CurMapperDir = CurDir.get<const OMPDeclareMapperDecl *>();
8350+
const auto *CurMapperDir = cast<const OMPDeclareMapperDecl *>(CurDir);
83518351
generateAllInfoForClauses(CurMapperDir->clauses(), CombinedInfo,
83528352
OMPBuilder);
83538353
}
@@ -8519,9 +8519,9 @@ class MappableExprsHandler {
85198519
DeclComponentLists.emplace_back(MCL, OMPC_MAP_tofrom, Unknown,
85208520
/*IsImpicit = */ true, nullptr,
85218521
nullptr);
8522-
assert(CurDir.is<const OMPExecutableDirective *>() &&
8522+
assert(isa<const OMPExecutableDirective *>(CurDir) &&
85238523
"Expect a executable directive");
8524-
const auto *CurExecDir = CurDir.get<const OMPExecutableDirective *>();
8524+
const auto *CurExecDir = cast<const OMPExecutableDirective *>(CurDir);
85258525
bool HasMapBasePtr = false;
85268526
bool HasMapArraySec = false;
85278527
for (const auto *C : CurExecDir->getClausesOfKind<OMPMapClause>()) {

clang/lib/CodeGen/ConstantInitBuilder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ using namespace CodeGen;
2020

2121
llvm::Type *ConstantInitFuture::getType() const {
2222
assert(Data && "dereferencing null future");
23-
if (Data.is<llvm::Constant*>()) {
24-
return Data.get<llvm::Constant*>()->getType();
23+
if (const auto *C = dyn_cast<llvm::Constant *>(Data)) {
24+
return C->getType();
2525
} else {
26-
return Data.get<ConstantInitBuilderBase*>()->Buffer[0]->getType();
26+
return cast<ConstantInitBuilderBase *>(Data)->Buffer[0]->getType();
2727
}
2828
}
2929

@@ -37,10 +37,10 @@ void ConstantInitFuture::abandon() {
3737

3838
void ConstantInitFuture::installInGlobal(llvm::GlobalVariable *GV) {
3939
assert(Data && "installing null future");
40-
if (Data.is<llvm::Constant*>()) {
41-
GV->setInitializer(Data.get<llvm::Constant*>());
40+
if (auto *C = dyn_cast<llvm::Constant *>(Data)) {
41+
GV->setInitializer(C);
4242
} else {
43-
auto &builder = *Data.get<ConstantInitBuilderBase*>();
43+
auto &builder = *cast<ConstantInitBuilderBase *>(Data);
4444
assert(builder.Buffer.size() == 1);
4545
builder.setGlobalInitializer(GV, builder.Buffer[0]);
4646
builder.Buffer.clear();

0 commit comments

Comments
 (0)