Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assertions seen in clang13 due to type mismatches. #664

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,14 @@ namespace clad {
}

Expr* VisitorBase::getZeroInit(QualType T) {
if (T->isScalarType())
return ConstantFolder::synthesizeLiteral(m_Context.IntTy, m_Context, 0);
else
return m_Sema.ActOnInitList(noLoc, {}, noLoc).get();
// FIXME: Consolidate other uses of synthesizeLiteral for creation 0 or 1.
if (T->isScalarType()) {
ExprResult Zero =
ConstantFolder::synthesizeLiteral(m_Context.IntTy, m_Context, 0);
parth-07 marked this conversation as resolved.
Show resolved Hide resolved
CastKind CK = m_Sema.PrepareScalarCast(Zero, T);
return m_Sema.ImpCastExprToType(Zero.get(), T, CK).get();
}
return m_Sema.ActOnInitList(noLoc, {}, noLoc).get();
}

std::pair<const clang::Expr*, llvm::SmallVector<const clang::Expr*, 4>>
Expand Down
Loading