diff --git a/README.md b/README.md index bd13047f4..4b05524a2 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ Clad also provides certain flags to save and print the generated derivative code - To print the Clad generated derivative: `-Xclang -plugin-arg-clad -Xclang -fdump-derived-fn` ## How to install -At the moment, LLVM/Clang 5.0.x - 17.0.x are supported. +At the moment, LLVM/Clang 7.0.x - 17.0.x are supported. ### Conda Installation diff --git a/include/clad/Differentiator/Compatibility.h b/include/clad/Differentiator/Compatibility.h index 0ac2dcbdc..62d71641c 100644 --- a/include/clad/Differentiator/Compatibility.h +++ b/include/clad/Differentiator/Compatibility.h @@ -21,33 +21,17 @@ namespace clad_compat { using namespace clang; using namespace llvm; -// Compatibility helper function for creation CompoundStmt. Clang 6 and above use Create. -// Clang 15 +// Compatibility helper function for creation CompoundStmt. // Clang 15 and above use a extra param FPFeatures in CompoundStmt::Create. static inline bool SourceManager_isPointWithin(const SourceManager& SM, SourceLocation Loc, SourceLocation B, SourceLocation E) { -#if CLANG_VERSION_MAJOR == 5 - return Loc == B || Loc == E || (SM.isBeforeInTranslationUnit(B, Loc) && - SM.isBeforeInTranslationUnit(Loc, E)); -#elif CLANG_VERSION_MAJOR >= 6 return SM.isPointWithin(Loc, B, E); -#endif } -#if CLANG_VERSION_MAJOR == 5 -#define CLAD_COMPAT_CLANG15_CompoundStmt_Create_ExtraParam(Node) /**/ -#define CLAD_COMPAT_CLANG15_CompoundStmt_Create_ExtraParam1(CS) /**/ -#define CLAD_COMPAT_CLANG15_CompoundStmt_Create_ExtraParam2(FP) /**/ -static inline CompoundStmt* CompoundStmt_Create( - const ASTContext &Ctx, ArrayRef Stmts, - SourceLocation LB, SourceLocation RB) -{ - return new (Ctx) CompoundStmt(Ctx, Stmts, LB, RB); -} -#elif CLANG_VERSION_MAJOR < 15 +#if CLANG_VERSION_MAJOR < 15 #define CLAD_COMPAT_CLANG15_CompoundStmt_Create_ExtraParam(Node) /**/ #define CLAD_COMPAT_CLANG15_CompoundStmt_Create_ExtraParam1(CS) /**/ #define CLAD_COMPAT_CLANG15_CompoundStmt_Create_ExtraParam2(FP) /**/ @@ -87,31 +71,10 @@ NamespaceDecl_Create(ASTContext& C, DeclContext* DC, bool Inline, } #endif -// Clang 6 rename Sema::ForRedeclaration to Sema::ForVisibleRedeclaration - -#if CLANG_VERSION_MAJOR == 5 - const auto Sema_ForVisibleRedeclaration = Sema::ForRedeclaration; -#elif CLANG_VERSION_MAJOR >= 6 - const auto Sema_ForVisibleRedeclaration = Sema::ForVisibleRedeclaration; -#endif - - -// Clang 6 rename Declarator to DeclaratorContext, but Declarator is used -// as name for another class. - -#if CLANG_VERSION_MAJOR == 5 - using DeclaratorContext = Declarator; -#elif CLANG_VERSION_MAJOR >= 6 - using DeclaratorContext = DeclaratorContext; -#endif - - // Clang 7 add one extra param in UnaryOperator constructor. -#if CLANG_VERSION_MAJOR < 7 - #define CLAD_COMPAT_CLANG7_UnaryOperator_ExtraParams /**/ -#elif CLANG_VERSION_MAJOR >= 7 - #define CLAD_COMPAT_CLANG7_UnaryOperator_ExtraParams ,Node->canOverflow() +#if CLANG_VERSION_MAJOR >= 7 +#define CLAD_COMPAT_CLANG7_UnaryOperator_ExtraParams , Node->canOverflow() #endif diff --git a/lib/Differentiator/CladUtils.cpp b/lib/Differentiator/CladUtils.cpp index 164f5ddda..16da9e5cf 100644 --- a/lib/Differentiator/CladUtils.cpp +++ b/lib/Differentiator/CladUtils.cpp @@ -243,7 +243,7 @@ namespace clad { // Find the builtin derivatives/numerical diff namespace DeclarationName Name = &C.Idents.get(namespc); LookupResult R(S, Name, SourceLocation(), Sema::LookupNamespaceName, - clad_compat::Sema_ForVisibleRedeclaration); + Sema::ForVisibleRedeclaration); S.LookupQualifiedName(R, DC, /*allowBuiltinCreation*/ false); if (!shouldExist && R.empty()) diff --git a/lib/Differentiator/VisitorBase.cpp b/lib/Differentiator/VisitorBase.cpp index 5b0cf2507..fc0857fb8 100644 --- a/lib/Differentiator/VisitorBase.cpp +++ b/lib/Differentiator/VisitorBase.cpp @@ -168,11 +168,8 @@ namespace clad { NamespaceDecl* PrevNS = nullptr; // From Sema::ActOnStartNamespaceDef: if (II) { - LookupResult R(m_Sema, - II, - noLoc, - Sema::LookupOrdinaryName, - clad_compat::Sema_ForVisibleRedeclaration); + LookupResult R(m_Sema, II, noLoc, Sema::LookupOrdinaryName, + Sema::ForVisibleRedeclaration); m_Sema.LookupQualifiedName(R, m_Sema.CurContext->getRedeclContext()); NamedDecl* FoundDecl = R.isSingleResult() ? R.getRepresentativeDecl() : nullptr; @@ -423,11 +420,8 @@ namespace clad { if (Result) return Result; DeclarationName CladName = &m_Context.Idents.get("clad"); - LookupResult CladR(m_Sema, - CladName, - noLoc, - Sema::LookupNamespaceName, - clad_compat::Sema_ForVisibleRedeclaration); + LookupResult CladR(m_Sema, CladName, noLoc, Sema::LookupNamespaceName, + Sema::ForVisibleRedeclaration); m_Sema.LookupQualifiedName(CladR, m_Context.getTranslationUnitDecl()); assert(!CladR.empty() && "cannot find clad namespace"); Result = cast(CladR.getFoundDecl()); @@ -440,11 +434,8 @@ namespace clad { CXXScopeSpec CSS; CSS.Extend(m_Context, CladNS, noLoc, noLoc); DeclarationName TapeName = &m_Context.Idents.get(ClassName); - LookupResult TapeR(m_Sema, - TapeName, - noLoc, - Sema::LookupUsingDeclName, - clad_compat::Sema_ForVisibleRedeclaration); + LookupResult TapeR(m_Sema, TapeName, noLoc, Sema::LookupUsingDeclName, + Sema::ForVisibleRedeclaration); m_Sema.LookupQualifiedName(TapeR, CladNS, CSS); assert(!TapeR.empty() && isa(TapeR.getFoundDecl()) && "cannot find clad::tape"); diff --git a/tools/ClangPlugin.cpp b/tools/ClangPlugin.cpp index 70e39aa1b..c4ab7039a 100644 --- a/tools/ClangPlugin.cpp +++ b/tools/ClangPlugin.cpp @@ -330,7 +330,7 @@ namespace clad { DeclarationName Name = &C.Idents.get("clad"); Sema &SemaR = m_CI.getSema(); LookupResult R(SemaR, Name, SourceLocation(), Sema::LookupNamespaceName, - clad_compat::Sema_ForVisibleRedeclaration); + Sema::ForVisibleRedeclaration); SemaR.LookupQualifiedName(R, C.getTranslationUnitDecl(), /*allowBuiltinCreation*/ false); m_HasRuntime = !R.empty();