[clang][Interp][NFC] Replace remaining dyn_cast_or_null uses
authorTimm Bäder <tbaeder@redhat.com>
Fri, 23 Dec 2022 06:56:58 +0000 (07:56 +0100)
committerTimm Bäder <tbaeder@redhat.com>
Wed, 25 Jan 2023 15:39:26 +0000 (16:39 +0100)
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/Interp.cpp
clang/lib/AST/Interp/State.cpp

index d7b429c..7777392 100644 (file)
@@ -965,7 +965,7 @@ unsigned ByteCodeExprGen<Emitter>::allocateLocalPrimitive(DeclTy &&Src,
   Descriptor *D = P.createDescriptor(Src, Ty, Descriptor::InlineDescMD, IsConst,
                                      Src.is<const Expr *>());
   Scope::Local Local = this->createLocal(D);
-  if (auto *VD = dyn_cast_or_null<ValueDecl>(Src.dyn_cast<const Decl *>()))
+  if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>()))
     Locals.insert({VD, Local});
   VarScope->add(Local, IsExtended);
   return Local.Offset;
@@ -1433,7 +1433,7 @@ bool ByteCodeExprGen<Emitter>::VisitCallExpr(const CallExpr *E) {
     return VisitBuiltinCallExpr(E);
 
   const Decl *Callee = E->getCalleeDecl();
-  if (const auto *FuncDecl = dyn_cast_or_null<FunctionDecl>(Callee)) {
+  if (const auto *FuncDecl = dyn_cast_if_present<FunctionDecl>(Callee)) {
     const Function *Func = getFunction(FuncDecl);
     if (!Func)
       return false;
index 648f631..31f141b 100644 (file)
@@ -381,7 +381,7 @@ bool CheckThis(InterpState &S, CodePtr OpPC, const Pointer &This) {
   const SourceInfo &Loc = S.Current->getSource(OpPC);
 
   bool IsImplicit = false;
-  if (auto *E = dyn_cast_or_null<CXXThisExpr>(Loc.asExpr()))
+  if (auto *E = dyn_cast_if_present<CXXThisExpr>(Loc.asExpr()))
     IsImplicit = E->isImplicit();
 
   if (S.getLangOpts().CPlusPlus11)
index 56774f8..f0eed85 100644 (file)
@@ -142,7 +142,7 @@ void State::addCallStack(unsigned Limit) {
 
     // Use a different note for an inheriting constructor, because from the
     // user's perspective it's not really a function at all.
-    if (auto *CD = dyn_cast_or_null<CXXConstructorDecl>(F->getCallee())) {
+    if (auto *CD = dyn_cast_if_present<CXXConstructorDecl>(F->getCallee())) {
       if (CD->isInheritingConstructor()) {
         addDiag(CallLocation, diag::note_constexpr_inherited_ctor_call_here)
             << CD->getParent();