Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add old, still supported versions in CI matrix #692

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,19 @@ jobs:
os: ubuntu-22.04
compiler: clang-16
clang-runtime: '17'

# Оld, still supported versions

- name: ubu20-gcc9-runtime7
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's indeed good that we still support these versions. However, should we spend efforts in maintaining such old versions of Clad?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should support 10 versions back only. The support generally has meant to compile with that version and not much else since we are using high-level clang API that produce consistent results.

min fact this pull request restricts the versions we support because so far we claim we support clang5 ;)

Copy link
Collaborator Author

@alexander-penev alexander-penev Dec 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if the support comes down to only having the corresponding fix in Compatibility.h, then 10 versions back is fine. However, if at some point this starts to interfere with us and take more time, then more versions may be dropped.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vgvassilev @alexander-penev Thank you for the explanation.

os: ubuntu-20.04
compiler: gcc-9
clang-runtime: '7'

- name: ubu20-gcc9-runtime8
os: ubuntu-20.04
compiler: gcc-9
clang-runtime: '8'

steps:
- uses: actions/checkout@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
45 changes: 4 additions & 41 deletions include/clad/Differentiator/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stmt *> 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) /**/
Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion lib/Differentiator/CladUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
21 changes: 6 additions & 15 deletions lib/Differentiator/VisitorBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<NamespaceDecl>(CladR.getFoundDecl());
Expand All @@ -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<TemplateDecl>(TapeR.getFoundDecl()) &&
"cannot find clad::tape");
Expand Down
2 changes: 1 addition & 1 deletion tools/ClangPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading