Skip to content

Add llvm 19 #312

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

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
70 changes: 69 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ jobs:
fail-fast: false
matrix:
include:
- name: ubu22-x86-gcc12-clang-repl-19
os: ubuntu-22.04
compiler: gcc-12
clang-runtime: '19'
cling: Off
cppyy: On
coverage: true
- name: ubu22-x86-gcc12-clang-repl-18
os: ubuntu-22.04
compiler: gcc-12
Expand Down Expand Up @@ -50,6 +57,12 @@ jobs:
cling-version: '1.0'
cppyy: On
coverage: true
- name: win2022-msvc-clang-repl-19
os: windows-2022
compiler: msvc
clang-runtime: '19'
cling: Off
cppyy: Off
- name: win2022-msvc-clang-repl-18
os: windows-2022
compiler: msvc
Expand All @@ -75,6 +88,12 @@ jobs:
cling: On
cling-version: '1.0'
cppyy: Off
- name: osx14-arm-clang-clang-repl-19
os: macos-14
compiler: clang
clang-runtime: '19'
cling: Off
cppyy: On
- name: osx14-arm-clang-clang-repl-18
os: macos-14
compiler: clang
Expand All @@ -100,6 +119,12 @@ jobs:
cling: On
cling-version: '1.0'
cppyy: On
- name: osx13-x86-clang-clang-repl-19
os: macos-13
compiler: clang
clang-runtime: '19'
cling: Off
cppyy: On
- name: osx13-x86-clang-clang-repl-18
os: macos-13
compiler: clang
Expand Down Expand Up @@ -350,7 +375,7 @@ jobs:
else
# Apply patches
llvm_vers=$(echo "${{ matrix.clang-runtime }}" | tr '[:lower:]' '[:upper:]')
if [[ "${llvm_vers}" != "18" ]]; then
if [[ "${llvm_vers}" == "16" ]]||[[ "${llvm_vers}" == "17" ]]; then
git apply -v ../patches/llvm/clang${{ matrix.clang-runtime }}-*.patch
echo "Apply clang${{ matrix.clang-runtime }}-*.patch patches:"
fi
Expand Down Expand Up @@ -470,6 +495,13 @@ jobs:
fail-fast: false
matrix:
include:
- name: ubu22-x86-gcc12-clang-repl-19-cppyy
os: ubuntu-22.04
compiler: gcc-12
clang-runtime: '19'
cling: Off
cppyy: On
coverage: true
- name: ubu22-x86-gcc12-clang-repl-18-cppyy
os: ubuntu-22.04
compiler: gcc-12
Expand Down Expand Up @@ -498,6 +530,12 @@ jobs:
cppyy: On
#FIXME: Windows CppInterOp tests expected to fail
#until https://github.com/compiler-research/CppInterOp/issues/188 is solved
- name: win2022-msvc-clang-repl-19
os: windows-2022
compiler: msvc
clang-runtime: '19'
cling: Off
cppyy: Off
- name: win2022-msvc-clang-repl-18
os: windows-2022
compiler: msvc
Expand Down Expand Up @@ -542,6 +580,12 @@ jobs:
# cling: On
# cling-version: '1.0'
# cppyy: On
- name: osx14-arm-clang-clang-repl-19-cppyy
os: macos-14
compiler: clang
clang-runtime: '19'
cling: Off
cppyy: On
- name: osx14-arm-clang-clang-repl-18-cppyy
os: macos-14
compiler: clang
Expand All @@ -567,6 +611,12 @@ jobs:
cling: On
cling-version: '1.0'
cppyy: On
- name: osx13-x86-clang-clang-repl-19-cppyy
os: macos-13
compiler: clang
clang-runtime: '19'
cling: Off
cppyy: On
- name: osx13-x86-clang-clang-repl-18-cppyy
os: macos-13
compiler: clang
Expand Down Expand Up @@ -1076,6 +1126,12 @@ jobs:
fail-fast: false
matrix:
include:
- name: ubu22-x86-gcc12-clang-repl-19-emscripten_wasm
os: ubuntu-22.04
compiler: gcc-12
clang-runtime: '19'
cling: Off
micromamba_shell_init: bash
- name: ubu22-x86-gcc12-clang-repl-18-emscripten_wasm
os: ubuntu-22.04
compiler: gcc-12
Expand All @@ -1101,6 +1157,12 @@ jobs:
cling: On
cling-version: '1.0'
micromamba_shell_init: bash
- name: osx14-arm-clang-clang-repl-19-emscripten_wasm
os: macos-14
compiler: clang
clang-runtime: '19'
cling: Off
micromamba_shell_init: bash
- name: osx14-arm-clang-clang-repl-18-emscripten_wasm
os: macos-14
compiler: clang
Expand All @@ -1126,6 +1188,12 @@ jobs:
cling: On
cling-version: '1.0'
micromamba_shell_init: bash
- name: osx13-x86-clang-clang-repl-19-emscripten_wasm
os: macos-13
compiler: clang
clang-runtime: '19'
cling: Off
micromamba_shell_init: bash
- name: osx13-x86-clang-clang-repl-18-emscripten_wasm
os: macos-13
compiler: clang
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
## Define supported version of clang and llvm

set(CLANG_MIN_SUPPORTED 13.0)
set(CLANG_MAX_SUPPORTED "18.1.x")
set(CLANG_VERSION_UPPER_BOUND 19.0.0)
set(CLANG_MAX_SUPPORTED "19.1.x")
set(CLANG_VERSION_UPPER_BOUND 20.0.0)
set(LLVM_MIN_SUPPORTED 13.0)
set(LLVM_MAX_SUPPORTED "18.1.x")
set(LLVM_VERSION_UPPER_BOUND 19.0.0)
set(LLVM_MAX_SUPPORTED "19.1.x")
set(LLVM_VERSION_UPPER_BOUND 20.0.0)

## Set Cmake packages search order

Expand Down
29 changes: 29 additions & 0 deletions lib/Interpreter/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,35 @@
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"

#if CLANG_VERSION_MAJOR < 19
#define Template_Deduction_Result Sema::TemplateDeductionResult
#else
#define Template_Deduction_Result TemplateDeductionResult
#endif

#if CLANG_VERSION_MAJOR < 19
#define For_Visible_Redeclaration Sema::ForVisibleRedeclaration
#define Clang_For_Visible_Redeclaration clang::Sema::ForVisibleRedeclaration
#else
#define For_Visible_Redeclaration RedeclarationKind::ForVisibleRedeclaration
#define Clang_For_Visible_Redeclaration \
RedeclarationKind::ForVisibleRedeclaration
#endif

#if CLANG_VERSION_MAJOR < 19
#define CXXSpecialMemberKindDefaultConstructor \
clang::Sema::CXXDefaultConstructor
#define CXXSpecialMemberKindCopyConstructor clang::Sema::CXXCopyConstructor
#define CXXSpecialMemberKindMoveConstructor clang::Sema::CXXMoveConstructor
#else
#define CXXSpecialMemberKindDefaultConstructor \
CXXSpecialMemberKind::DefaultConstructor
#define CXXSpecialMemberKindCopyConstructor \
CXXSpecialMemberKind::CopyConstructor
#define CXXSpecialMemberKindMoveConstructor \
CXXSpecialMemberKind::MoveConstructor
#endif

#if LLVM_VERSION_MAJOR < 18
#define starts_with startswith
#define ends_with endswith
Expand Down
62 changes: 37 additions & 25 deletions lib/Interpreter/CppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
#include "clang/Frontend/CompilerInstance.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Sema.h"
#if CLANG_VERSION_MAJOR >= 19
#include "clang/Sema/Redeclaration.h"
#endif
#include "clang/Sema/TemplateDeduction.h"

#include "llvm/ADT/StringRef.h"
Expand All @@ -49,6 +52,8 @@
#include <unistd.h>
#endif // WIN32

#include <stack>

namespace Cpp {

using namespace clang;
Expand Down Expand Up @@ -805,11 +810,8 @@
llvm::StringRef Name(name);
auto &S = getSema();
DeclarationName DName = &getASTContext().Idents.get(name);
clang::LookupResult R(S,
DName,
SourceLocation(),
Sema::LookupOrdinaryName,
Sema::ForVisibleRedeclaration);
clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName,
For_Visible_Redeclaration);

Cpp_utils::Lookup::Named(&S, R, Decl::castToDeclContext(D));

Expand Down Expand Up @@ -962,7 +964,7 @@
auto& S = getSema();
DeclarationName DName = &getASTContext().Idents.get(name);
clang::LookupResult R(S, DName, SourceLocation(), Sema::LookupOrdinaryName,
Sema::ForVisibleRedeclaration);
For_Visible_Redeclaration);

Check warning on line 967 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L967

Added line #L967 was not covered by tests

Cpp_utils::Lookup::Named(&S, R, Decl::castToDeclContext(D));

Expand Down Expand Up @@ -1348,36 +1350,43 @@
isunsigned = true;
typeName = StringRef(typeName.data()+9, typeName.size()-9);
}
if (typeName.equals("char")) {
if (typeName == "char") {
if (isunsigned) return Context.UnsignedCharTy;
return Context.SignedCharTy;
}
if (typeName.equals("short")) {
if (typeName == "short") {
if (isunsigned) return Context.UnsignedShortTy;
return Context.ShortTy;
}
if (typeName.equals("int")) {
if (typeName == "int") {
if (isunsigned) return Context.UnsignedIntTy;
return Context.IntTy;
}
if (typeName.equals("long")) {
if (typeName == "long") {
if (isunsigned) return Context.UnsignedLongTy;
return Context.LongTy;
}
if (typeName.equals("long long")) {
if (typeName == "long long") {
if (isunsigned)
return Context.UnsignedLongLongTy;
return Context.LongLongTy;
}
if (!issigned && !isunsigned) {
if (typeName.equals("bool")) return Context.BoolTy;
if (typeName.equals("float")) return Context.FloatTy;
if (typeName.equals("double")) return Context.DoubleTy;
if (typeName.equals("long double")) return Context.LongDoubleTy;

if (typeName.equals("wchar_t")) return Context.WCharTy;
if (typeName.equals("char16_t")) return Context.Char16Ty;
if (typeName.equals("char32_t")) return Context.Char32Ty;
if (typeName == "bool")
return Context.BoolTy;

Check warning on line 1376 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L1376

Added line #L1376 was not covered by tests
if (typeName == "float")
return Context.FloatTy;
if (typeName == "double")
return Context.DoubleTy;
if (typeName == "long double")
return Context.LongDoubleTy;

Check warning on line 1382 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L1382

Added line #L1382 was not covered by tests

if (typeName == "wchar_t")
return Context.WCharTy;

Check warning on line 1385 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L1385

Added line #L1385 was not covered by tests
if (typeName == "char16_t")
return Context.Char16Ty;

Check warning on line 1387 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L1387

Added line #L1387 was not covered by tests
if (typeName == "char32_t")
return Context.Char32Ty;

Check warning on line 1389 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L1389

Added line #L1389 was not covered by tests
}
/* Missing
CanQualType WideCharTy; // Same as WCharTy in C++, integer type in C99.
Expand Down Expand Up @@ -1747,9 +1756,11 @@
if (const CXXConstructorDecl* CD = dyn_cast<CXXConstructorDecl>(FD)) {
if (N <= 1 && llvm::isa<UsingShadowDecl>(FD)) {
auto SpecMemKind = I.getCI()->getSema().getSpecialMember(CD);
if ((N == 0 && SpecMemKind == clang::Sema::CXXDefaultConstructor) ||
(N == 1 && (SpecMemKind == clang::Sema::CXXCopyConstructor ||
SpecMemKind == clang::Sema::CXXMoveConstructor))) {
if ((N == 0 &&
SpecMemKind == CXXSpecialMemberKindDefaultConstructor) ||
(N == 1 &&
(SpecMemKind == CXXSpecialMemberKindCopyConstructor ||

Check warning on line 1762 in lib/Interpreter/CppInterOp.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/CppInterOp.cpp#L1759-L1762

Added lines #L1759 - L1762 were not covered by tests
SpecMemKind == CXXSpecialMemberKindMoveConstructor))) {
// Using declarations cannot inject special members; do not call
// them as such. This might happen by using `Base(Base&, int = 12)`,
// which is fine to be called as `Derived d(someBase, 42)` but not
Expand Down Expand Up @@ -2866,9 +2877,10 @@
if (auto* FunctionTemplate = dyn_cast<FunctionTemplateDecl>(TemplateD)) {
FunctionDecl* Specialization = nullptr;
clang::sema::TemplateDeductionInfo Info(fakeLoc);
if (Sema::TemplateDeductionResult Result = S.DeduceTemplateArguments(
FunctionTemplate, &TLI, Specialization, Info,
/*IsAddressOfFunction*/ true)) {
Template_Deduction_Result Result = S.DeduceTemplateArguments(
FunctionTemplate, &TLI, Specialization, Info,
/*IsAddressOfFunction*/ true);
if (static_cast<int>(Result)) {
// FIXME: Diagnose what happened.
(void)Result;
}
Expand Down
5 changes: 4 additions & 1 deletion lib/Interpreter/CppInterOpInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Sema.h"
#if CLANG_VERSION_MAJOR >= 19
#include "clang/Sema/Redeclaration.h"
#endif

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallSet.h"
Expand Down Expand Up @@ -105,7 +108,7 @@ inline clang::NamedDecl* Named(clang::Sema* S,
const clang::DeclContext* Within = nullptr) {
clang::LookupResult R(*S, Name, clang::SourceLocation(),
clang::Sema::LookupOrdinaryName,
clang::Sema::ForVisibleRedeclaration);
Clang_For_Visible_Redeclaration);
Named(S, R, Within);
return LookupResult2Decl<clang::NamedDecl>(R);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Interpreter/DynamicLibraryManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class DynamicLibraryManager {
bool prepend = false) {
if (!dir.empty()) {
for (auto& item : m_SearchPaths)
if (dir.equals(item.Path))
if (dir == item.Path)
return;
auto pos = prepend ? m_SearchPaths.begin() : m_SearchPaths.end();
m_SearchPaths.insert(pos, SearchPathInfo{dir.str(), isUser});
Expand Down
4 changes: 2 additions & 2 deletions lib/Interpreter/Paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@
return true;
}
// Don't write same same log entry twice when FilePath == Path
if (FileType && !FilePath.str().equals(Path))
if (FileType && FilePath.str() != Path)

Check warning on line 315 in lib/Interpreter/Paths.cpp

View check run for this annotation

Codecov / codecov/patch

lib/Interpreter/Paths.cpp#L315

Added line #L315 was not covered by tests
LogFileStatus("Ignoring", FileType, FilePath);
}
else if (llvm::sys::path::is_absolute(Path))
Expand Down Expand Up @@ -354,7 +354,7 @@

#if defined(_WIN32)
// Support using a ':' delimiter on Windows.
const bool WindowsColon = Delim.equals(":");
const bool WindowsColon = (Delim == ":");
#endif

bool AllExisted = true;
Expand Down
4 changes: 4 additions & 0 deletions unittests/CppInterOp/ScopeReflectionTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,11 @@ template<class T> constexpr T pi = T(3.1415926535897932385L);
VarTemplateDecl* VDTD1 = VD->getSpecializedTemplate();
EXPECT_TRUE(VDTD1->isThisDeclarationADefinition());
#if CLANG_VERSION_MAJOR > 13
#if CLANG_VERSION_MAJOR > 18
TemplateArgument TA1 = (*VD->getTemplateArgsAsWritten())[0].getArgument();
#else
TemplateArgument TA1 = (*VD->getTemplateArgsInfo())[0].getArgument();
#endif // CLANG_VERSION_MAJOR
#else
TemplateArgument TA1 = VD->getTemplateArgsInfo()[0].getArgument();
#endif // CLANG_VERSION_MAJOR
Expand Down
Loading