From fe68ca5b4d07d5a3a9bb54055e8718e4c322e0b2 Mon Sep 17 00:00:00 2001 From: kchristin Date: Sun, 3 Nov 2024 18:33:15 +0200 Subject: [PATCH] Fix compatibility for CI tests and clang-tidy suggestions --- lib/Differentiator/ReverseModeVisitor.cpp | 8 +++++--- test/CUDA/tensor_demo.cu | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index 956c6c5e1..a8e2526be 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -1911,8 +1911,10 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, m_Sema.LookupName(result, m_Sema.getCurScope()); EnumDecl* cudaMemcpyKindDecl = nullptr; for (NamedDecl* decl : result) - if ((cudaMemcpyKindDecl = dyn_cast(decl))) + if (auto* enumDecl = dyn_cast(decl)) { + cudaMemcpyKindDecl = enumDecl; break; + } assert(cudaMemcpyKindDecl && "cudaMemcpyKind not found"); QualType cudaMemcpyKindType = m_Context.getTypeDeclType(cudaMemcpyKindDecl); @@ -1925,10 +1927,10 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, } } assert(deviceToHostEnumDecl && "cudaMemcpyDeviceToHost not found"); - DeclRefExpr* deviceToHostDeclRef = + auto* deviceToHostDeclRef = clad_compat::GetResult( m_Sema.BuildDeclRefExpr(deviceToHostEnumDecl, cudaMemcpyKindType, CLAD_COMPAT_ExprValueKind_R_or_PR_Value, - SourceLocation(), nullptr); + SourceLocation(), nullptr)); PreCallStmts.push_back(BuildDeclStmt(dArgDeclCUDA)); Expr* refOp = BuildOp(UO_AddrOf, BuildDeclRef(dArgDeclCUDA)); diff --git a/test/CUDA/tensor_demo.cu b/test/CUDA/tensor_demo.cu index c75de4942..43bcc32ee 100644 --- a/test/CUDA/tensor_demo.cu +++ b/test/CUDA/tensor_demo.cu @@ -1,6 +1,7 @@ // RUN: %cladclang_cuda -I%S/../../include --cuda-path=%cudapath \ // RUN: --cuda-gpu-arch=%cudaarch %cudaldflags -otensor_demo.out %s // RUN: ./tensor_demo.out | %filecheck_exec %s +// REQUIRES: cuda-runtime #include "clad/Differentiator/Differentiator.h"