Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mcbarton authored Mar 26, 2024
1 parent 4a60371 commit d0b7cb6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
10 changes: 9 additions & 1 deletion include/clad/Differentiator/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ namespace clad_compat {
using namespace clang;
using namespace llvm;

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

#if LLVM_VERSION_MAJOR < 18
#define ArrayType_Normal ArrayType::Normal
#else
#define ArrayType_Normal ArraySizeModifier::Normal
#endif

// Compatibility helper function for creation UnresolvedLookupExpr.
// Clang-18 extra argument knowndependent.
//FIXME: Knowndependent set to false temporarily until known value found for initialisation.
Expand Down Expand Up @@ -63,7 +71,7 @@ static inline Stmt* UnresolvedLookupExpr_Create(const ASTContext &Ctx,
// OverloadExpr, so we are safe.
Args,
Begin,
End
End,
KnownDependent
);
#endif
Expand Down
11 changes: 1 addition & 10 deletions lib/Differentiator/CladUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,21 +269,12 @@ namespace clad {
// Copied and adapted from clang::Sema::ActOnStringLiteral.
QualType CharTyConst = C.CharTy.withConst();
QualType
#if CLANG_VERSION_MAJOR < 18
StrTy = clad_compat::getConstantArrayType(C, CharTyConst,
llvm::APInt(/*numBits=*/32,
str.size() + 1),
/*SizeExpr=*/nullptr,
/*ASM=*/ArrayType::Normal,
/*ASM=*/ArrayType_Normal,
/*IndexTypeQuals*/ 0);
#else
StrTy = clad_compat::getConstantArrayType(C, CharTyConst,
llvm::APInt(/*numBits=*/32,
str.size() + 1),
/*SizeExpr=*/nullptr,
/*ASM=*/ArraySizeModifier::Normal,
/*IndexTypeQuals*/ 0);
#endif
StringLiteral* SL = StringLiteral::Create(C, str,
/*Kind=*/clad_compat::StringKind_Ordinary,
/*Pascal=*/false, StrTy, noLoc);
Expand Down
16 changes: 3 additions & 13 deletions lib/Differentiator/HessianModeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,13 @@ namespace clad {
static const StringLiteral* CreateStringLiteral(ASTContext& C,
std::string str) {
QualType CharTyConst = C.CharTy.withConst();
#if CLANG_VERSION_MAJOR < 18
QualType StrTy =
clad_compat::getConstantArrayType(C, CharTyConst,
QualType StrTy =
clad_compat::getConstantArrayType(C, CharTyConst,
llvm::APInt(/*numBits=*/32,
str.size() + 1),
/*SizeExpr=*/nullptr,
/*ASM=*/ArrayType::Normal,
/*ASM=*/ArrayType_Normal,
/*IndexTypeQuals*/ 0);
#else
QualType StrTy =
clad_compat::getConstantArrayType(C, CharTyConst,
llvm::APInt(/*numBits=*/32,
str.size() + 1),
/*SizeExpr=*/nullptr,
/*ASM=*/ArraySizeModifier::Normal,
/*IndexTypeQuals*/ 0);
#endif
const StringLiteral* SL =
StringLiteral::Create(C, str, /*Kind=*/clad_compat::StringKind_Ordinary,
/*Pascal=*/false, StrTy, noLoc);
Expand Down

0 comments on commit d0b7cb6

Please sign in to comment.