Skip to content

Commit

Permalink
Provide a fake source locations to avoid asserts in template instanti…
Browse files Browse the repository at this point in the history
…ation.
  • Loading branch information
vgvassilev committed Feb 1, 2024
1 parent 2776e59 commit 03efa6b
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,16 @@ namespace clad {
Expr* VisitorBase::BuildArraySubscript(
Expr* Base, llvm::SmallVectorImpl<clang::Expr*>& Indices) {
Expr* result = Base;
SourceLocation fakeLoc = utils::GetValidSLoc(m_Sema);
if (utils::isArrayOrPointerType(Base->getType()))
for (Expr* I : Indices)
result = m_Sema.CreateBuiltinArraySubscriptExpr(result, noLoc, I, noLoc)
.get();
result =
m_Sema.CreateBuiltinArraySubscriptExpr(result, fakeLoc, I, fakeLoc)
.get();
else
result = m_Sema
.ActOnArraySubscriptExpr(getCurrentScope(), Base, noLoc,
Indices.back(), noLoc)
.ActOnArraySubscriptExpr(getCurrentScope(), Base, fakeLoc,
Indices.back(), fakeLoc)
.get();
return result;
}
Expand Down

0 comments on commit 03efa6b

Please sign in to comment.