Skip to content

Commit

Permalink
Try compatibility differentiation for VK_R enum
Browse files Browse the repository at this point in the history
  • Loading branch information
kchristin22 committed Oct 8, 2024
1 parent bede7c8 commit 2d624ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/clad/Differentiator/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -730,5 +730,11 @@ template <typename X, typename Y> bool isa_and_nonnull(const Y* Val) {
}
#endif

#if CLANG_VERSION_MAJOR < 13
const auto VK_R = ExprValueKind::VK_RValue;
#else
const auto VK_R = ExprValueKind::VK_PRValue;
#endif

} // namespace clad_compat
#endif //CLAD_COMPATIBILITY
3 changes: 2 additions & 1 deletion lib/Differentiator/ConstantFolder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//----------------------------------------------------------------------------//

#include "ConstantFolder.h"
#include "clad/Differentiator/Compatibility.h"

#include "clang/AST/ASTContext.h"

Expand Down Expand Up @@ -148,7 +149,7 @@ namespace clad {
dyn_cast<EnumType>(QT)->getDecl()->getIntegerType(), C, APVal);
Expr* cast = ImplicitCastExpr::Create(
C, QT, clang::CastKind::CK_IntegralCast, Result, nullptr,
clang::ExprValueKind::VK_PRValue, FPOptionsOverride());
clad_compat::VK_R, FPOptionsOverride());
Result = cast;
} else if (QT->isPointerType()) {
Result = clad::synthesizeLiteral(QT, C);
Expand Down

0 comments on commit 2d624ca

Please sign in to comment.