Skip to content

Commit

Permalink
Make Indices in BuildArraySubscript const again.
Browse files Browse the repository at this point in the history
  • Loading branch information
PetroZarytskyi committed Feb 5, 2024
1 parent deddb61 commit ce70387
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/clad/Differentiator/VisitorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ namespace clad {
/// a sequence of indices.
clang::Expr*
BuildArraySubscript(clang::Expr* Base,
llvm::SmallVectorImpl<clang::Expr*>& IS);
const llvm::SmallVectorImpl<clang::Expr*>& IS);
/// Find namespace clad declaration.
clang::NamespaceDecl* GetCladNamespace();
/// Find declaration of clad::class templated type
Expand Down
12 changes: 7 additions & 5 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,19 +418,21 @@ namespace clad {
}

Expr* VisitorBase::BuildArraySubscript(
Expr* Base, llvm::SmallVectorImpl<clang::Expr*>& Indices) {
Expr* Base, const llvm::SmallVectorImpl<clang::Expr*>& Indices) {
Expr* result = Base;
SourceLocation fakeLoc = utils::GetValidSLoc(m_Sema);
if (utils::isArrayOrPointerType(Base->getType()))
if (utils::isArrayOrPointerType(Base->getType())) {
for (Expr* I : Indices)
result =
m_Sema.CreateBuiltinArraySubscriptExpr(result, fakeLoc, I, fakeLoc)
.get();
else
} else {
Expr* idx = Indices.back();
result = m_Sema
.ActOnArraySubscriptExpr(getCurrentScope(), Base, fakeLoc,
Indices.back(), fakeLoc)
.ActOnArraySubscriptExpr(getCurrentScope(), Base, fakeLoc, idx,
fakeLoc)
.get();
}
return result;
}

Expand Down

0 comments on commit ce70387

Please sign in to comment.