[clang][sema] checkNoThrow - use cast<> instead of dyn_cast<> to avoid dereference...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 12 Feb 2022 11:18:49 +0000 (11:18 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Sat, 12 Feb 2022 11:18:49 +0000 (11:18 +0000)
The pointer is referenced immediately, so assert the cast is correct instead of returning nullptr

clang/lib/Sema/SemaCoroutine.cpp

index aae90c4..71fcf4a 100644 (file)
@@ -680,7 +680,7 @@ static void checkNoThrow(Sema &S, const Stmt *E,
         QualType::DestructionKind::DK_cxx_destructor) {
       const auto *T =
           cast<RecordType>(ReturnType.getCanonicalType().getTypePtr());
-      checkDeclNoexcept(dyn_cast<CXXRecordDecl>(T->getDecl())->getDestructor(),
+      checkDeclNoexcept(cast<CXXRecordDecl>(T->getDecl())->getDestructor(),
                         /*IsDtor=*/true);
     }
   } else