[clang] 5de6b94 - [clang][Interp][NFC] Replace remaining dyn_cast_or_null uses

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 25 07:39:37 PST 2023


Author: Timm Bäder
Date: 2023-01-25T16:39:26+01:00
New Revision: 5de6b94f856f696832ce7df167e1dbc096fbe598

URL: https://github.com/llvm/llvm-project/commit/5de6b94f856f696832ce7df167e1dbc096fbe598
DIFF: https://github.com/llvm/llvm-project/commit/5de6b94f856f696832ce7df167e1dbc096fbe598.diff

LOG: [clang][Interp][NFC] Replace remaining dyn_cast_or_null uses

Added: 
    

Modified: 
    clang/lib/AST/Interp/ByteCodeExprGen.cpp
    clang/lib/AST/Interp/Interp.cpp
    clang/lib/AST/Interp/State.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index d7b429c38f10..7777392052f2 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -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;

diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 648f63105985..31f141b9dde3 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -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)

diff  --git a/clang/lib/AST/Interp/State.cpp b/clang/lib/AST/Interp/State.cpp
index 56774f88fb45..f0eed85054ce 100644
--- a/clang/lib/AST/Interp/State.cpp
+++ b/clang/lib/AST/Interp/State.cpp
@@ -142,7 +142,7 @@ void State::addCallStack(unsigned Limit) {
 
     // Use a 
diff erent 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();


        


More information about the cfe-commits mailing list