Skip to content

Commit d2c2fa9

Browse files
committed
[clang][NFC] Replace deprected *cast_or_null casts
1 parent 8248388 commit d2c2fa9

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

clang/lib/AST/Decl.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void PrettyDeclStackTraceEntry::print(raw_ostream &OS) const {
8787
}
8888
OS << Message;
8989

90-
if (auto *ND = dyn_cast_or_null<NamedDecl>(TheDecl)) {
90+
if (auto *ND = dyn_cast_if_present<NamedDecl>(TheDecl)) {
9191
OS << " '";
9292
ND->getNameForDiagnostic(OS, Context.getPrintingPolicy(), true);
9393
OS << "'";
@@ -1948,7 +1948,7 @@ bool NamedDecl::isCXXInstanceMember() const {
19481948

19491949
if (isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D) || isa<MSPropertyDecl>(D))
19501950
return true;
1951-
if (const auto *MD = dyn_cast_or_null<CXXMethodDecl>(D->getAsFunction()))
1951+
if (const auto *MD = dyn_cast_if_present<CXXMethodDecl>(D->getAsFunction()))
19521952
return MD->isInstance();
19531953
return false;
19541954
}
@@ -2944,7 +2944,7 @@ Expr *ParmVarDecl::getDefaultArg() {
29442944
"Default argument is not yet instantiated!");
29452945

29462946
Expr *Arg = getInit();
2947-
if (auto *E = dyn_cast_or_null<FullExpr>(Arg))
2947+
if (auto *E = dyn_cast_if_present<FullExpr>(Arg))
29482948
return E->getSubExpr();
29492949

29502950
return Arg;
@@ -2983,7 +2983,7 @@ void ParmVarDecl::setUninstantiatedDefaultArg(Expr *arg) {
29832983
Expr *ParmVarDecl::getUninstantiatedDefaultArg() {
29842984
assert(hasUninstantiatedDefaultArg() &&
29852985
"Wrong kind of initialization expression!");
2986-
return cast_or_null<Expr>(Init.get<Stmt *>());
2986+
return cast_if_present<Expr>(Init.get<Stmt *>());
29872987
}
29882988

29892989
bool ParmVarDecl::hasDefaultArg() const {
@@ -3950,7 +3950,7 @@ FunctionDecl::setInstantiationOfMemberFunction(ASTContext &C,
39503950
}
39513951

39523952
FunctionTemplateDecl *FunctionDecl::getDescribedFunctionTemplate() const {
3953-
return dyn_cast_or_null<FunctionTemplateDecl>(
3953+
return dyn_cast_if_present<FunctionTemplateDecl>(
39543954
TemplateOrSpecialization.dyn_cast<NamedDecl *>());
39553955
}
39563956

@@ -3968,7 +3968,7 @@ void FunctionDecl::setInstantiatedFromDecl(FunctionDecl *FD) {
39683968
}
39693969

39703970
FunctionDecl *FunctionDecl::getInstantiatedFromDecl() const {
3971-
return dyn_cast_or_null<FunctionDecl>(
3971+
return dyn_cast_if_present<FunctionDecl>(
39723972
TemplateOrSpecialization.dyn_cast<NamedDecl *>());
39733973
}
39743974

@@ -4452,7 +4452,7 @@ Expr *FieldDecl::getInClassInitializer() const {
44524452
return nullptr;
44534453

44544454
LazyDeclStmtPtr InitPtr = BitField ? InitAndBitWidth->Init : Init;
4455-
return cast_or_null<Expr>(
4455+
return cast_if_present<Expr>(
44564456
InitPtr.isOffset() ? InitPtr.get(getASTContext().getExternalSource())
44574457
: InitPtr.get(nullptr));
44584458
}

0 commit comments

Comments
 (0)