Skip to content

Commit

Permalink
Replace asserts with diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristin22 committed Nov 3, 2024
1 parent cf71bcc commit 7d561f3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/Differentiator/ReverseModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,10 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
cudaMemcpyKindDecl = enumDecl;
break;
}
assert(cudaMemcpyKindDecl && "cudaMemcpyKind not found");
if (!cudaMemcpyKindDecl) {
diag(DiagnosticsEngine::Warning, CE->getEndLoc(),
"Failed to create cudaMemcpy call; cudaMemcpyKind not found");
}
QualType cudaMemcpyKindType =
m_Context.getTypeDeclType(cudaMemcpyKindDecl);
EnumConstantDecl* deviceToHostEnumDecl = nullptr;
Expand All @@ -1926,7 +1929,11 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context,
break;
}
}
assert(deviceToHostEnumDecl && "cudaMemcpyDeviceToHost not found");
if (!deviceToHostEnumDecl) {
diag(DiagnosticsEngine::Warning, CE->getEndLoc(),
"Failed to create cudaMemcpy call; cudaMemcpyDeviceToHost not "
"found");
}
auto* deviceToHostDeclRef = clad_compat::GetResult<Expr*>(
m_Sema.BuildDeclRefExpr(deviceToHostEnumDecl, cudaMemcpyKindType,
CLAD_COMPAT_ExprValueKind_R_or_PR_Value,
Expand Down

0 comments on commit 7d561f3

Please sign in to comment.