Skip to content

Commit

Permalink
Attempt to resolve #824 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbarton authored Mar 26, 2024
1 parent 35ec9b2 commit 10ce4fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 10 additions & 0 deletions include/clad/Differentiator/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ namespace clad_compat {
using namespace clang;
using namespace llvm;

//Clang 18 ActOnLambdaExpr lost argument
static inline Stmt* ActOnLambdaExpr_Create(clang::sema* S,SourceLocation StartLoc, Stmt *Body)
{
#if LLVM_VERSION_MAJOR < 18
return S.ActOnLambdaExpr(StartLoc, Body, V.getCurrentScope()).get();
#else
return S.ActOnLambdaExpr(StartLoc, Body).get();
#endif
}

//Clang 18 ArrayType::Normal -> ArraySizeModifier::Normal

#if LLVM_VERSION_MAJOR < 18
Expand Down
8 changes: 1 addition & 7 deletions include/clad/Differentiator/VisitorBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,7 @@ namespace clad {
V.beginBlock();
func();
clang::CompoundStmt* body = V.endBlock();
#if CLANG_VERSION_MAJOR > 17
clang::Expr* lambda =
S.ActOnLambdaExpr(noLoc, body).get();
#else
clang::Expr* lambda =
S.ActOnLambdaExpr(noLoc, body, V.getCurrentScope()).get();
#endif // CLANG_VERSION_MAJOR > 17
clang::Expr* lambda = ActOnLambdaExpr_Create(S,SourceLocation StartLoc, Stmt *Body);
V.endScope();
return S.ActOnCallExpr(V.getCurrentScope(), lambda, noLoc, {}, noLoc)
.get();
Expand Down

0 comments on commit 10ce4fc

Please sign in to comment.