diff --git a/lib/Differentiator/ReverseModeVisitor.cpp b/lib/Differentiator/ReverseModeVisitor.cpp index 42dce1c33..4e8c8dda4 100644 --- a/lib/Differentiator/ReverseModeVisitor.cpp +++ b/lib/Differentiator/ReverseModeVisitor.cpp @@ -216,16 +216,9 @@ Expr* getArraySizeExpr(const ArrayType* AT, ASTContext& context, ++i) { auto* overloadParam = overloadParams[i]; auto* gradientParam = gradientParams[i]; - - auto* init = ImplicitCastExpr::Create( - m_Context, - gradientParam->getType(), - clang::CK_BitCast, - BuildDeclRef(overloadParam), - nullptr, - clang::VK_RValue, - clang::FPOptionsOverride() - ); + TypeSourceInfo* typeInfo = m_Context.getTrivialTypeSourceInfo(gradientParam->getType()); + SourceLocation fakeLoc = utils::GetValidSLoc(m_Sema); + auto* init = m_Sema.BuildCStyleCastExpr(fakeLoc, typeInfo, fakeLoc, BuildDeclRef(overloadParam)).get(); auto* gradientVD = BuildGlobalVarDecl(gradientParam->getType(), gradientParam->getName(),