Skip to content
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
2 changes: 2 additions & 0 deletions interpreter/CppInterOp/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ Checks: >
-readability-implicit-bool-conversion,
-readability-magic-numbers,
-readability-named-parameter,
-modernize-concat-nested-namespaces,
-readability-avoid-return-with-void-value,
-readability-function-cognitive-complexity,
-readability-redundant-access-specifiers,
-cppcoreguidelines-avoid-magic-numbers,
Expand Down
31 changes: 22 additions & 9 deletions interpreter/CppInterOp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
include(GNUInstallDirs)
## Define supported version of clang and llvm

set(CLANG_MIN_SUPPORTED 19.0)
set(CLANG_MAX_SUPPORTED "21.1.x")
set(CLANG_VERSION_UPPER_BOUND 22.0.0)
set(LLD_MIN_SUPPORTED 19.0)
set(LLD_MAX_SUPPORTED "21.1.x")
set(LLD_VERSION_UPPER_BOUND 22.0.0)
set(LLVM_MIN_SUPPORTED 19.0)
set(LLVM_MAX_SUPPORTED "21.1.x")
set(LLVM_VERSION_UPPER_BOUND 22.0.0)
set(CLANG_MIN_SUPPORTED 20.0)
set(CLANG_MAX_SUPPORTED "22.1.x")
set(CLANG_VERSION_UPPER_BOUND 23.0.0)
set(LLD_MIN_SUPPORTED 20.0)
set(LLD_MAX_SUPPORTED "22.1.x")
set(LLD_VERSION_UPPER_BOUND 23.0.0)
set(LLVM_MIN_SUPPORTED 20.0)
set(LLVM_MAX_SUPPORTED "22.1.x")
set(LLVM_VERSION_UPPER_BOUND 23.0.0)

## Set Cmake packages search order

Expand Down Expand Up @@ -285,6 +285,19 @@ endif()

set( CPPINTEROP_BUILT_STANDALONE 1 )

# LLVM_USE_SANITIZER is not exported via LLVMConfig.cmake. When building
# against an LLVM build tree (not an installed package), import the setting
# so that HandleLLVMOptions applies matching -fsanitize= flags.
if (NOT DEFINED LLVM_USE_SANITIZER
AND EXISTS "${LLVM_BINARY_DIR}/CMakeCache.txt")
load_cache("${LLVM_BINARY_DIR}" READ_WITH_PREFIX _LLVM_
LLVM_USE_SANITIZER)
if (_LLVM_LLVM_USE_SANITIZER)
set(LLVM_USE_SANITIZER "${_LLVM_LLVM_USE_SANITIZER}")
message(STATUS "Matching LLVM sanitizer: LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER}")
endif ()
endif ()

include(AddLLVM)
include(HandleLLVMOptions)
endif()
Expand Down
8 changes: 4 additions & 4 deletions interpreter/CppInterOp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git

#### Setup Clang-REPL

Clone the 21.x release of the LLVM project repository.
Clone the 22.x release of the LLVM project repository.

```bash
git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git
git clone --depth=1 --branch release/22.x https://github.com/llvm/llvm-project.git
cd llvm-project
```

Expand Down Expand Up @@ -452,10 +452,10 @@ git clone --depth=1 https://github.com/compiler-research/cppyy-backend.git

#### Setup Clang-REPL

Clone the 21.x release of the LLVM project repository.
Clone the 22.x release of the LLVM project repository.

```bash
git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git
git clone --depth=1 --branch release/22.x https://github.com/llvm/llvm-project.git
cd llvm-project
```

Expand Down
2 changes: 1 addition & 1 deletion interpreter/CppInterOp/cppinterop-version.tag
Original file line number Diff line number Diff line change
@@ -1 +1 @@
039bf0423284b1139674525d097e656cb0feb783
2e0183b8035c2fd737bb3f6ba2fe4f412e148447
4 changes: 2 additions & 2 deletions interpreter/CppInterOp/docs/DevelopersDocumentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ library
Setup Clang-REPL
******************

Clone the 21.x release of the LLVM project repository.
Clone the 22.x release of the LLVM project repository.

.. code:: bash
git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git
git clone --depth=1 --branch release/22.x https://github.com/llvm/llvm-project.git
cd llvm-project
If you want to have out-of-process JIT execution enabled in CppInterOp, then apply this patch on Linux-x86_64 and MacOS arm64 environment.
Expand Down
4 changes: 2 additions & 2 deletions interpreter/CppInterOp/docs/InstallationAndUsage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ library
Setup Clang-REPL
******************

Clone the 21.x release of the LLVM project repository.
Clone the 22.x release of the LLVM project repository.

.. code:: bash

git clone --depth=1 --branch release/21.x https://github.com/llvm/llvm-project.git
git clone --depth=1 --branch release/22.x https://github.com/llvm/llvm-project.git
cd llvm-project

If you want to have out-of-process JIT execution enabled in CppInterOp, then apply this patch on Linux-x86_64 and MacOS arm64 environment.
Expand Down
21 changes: 19 additions & 2 deletions interpreter/CppInterOp/include/CppInterOp/CppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ using TCppIndex_t = size_t;
using TCppScope_t = void*;
using TCppConstScope_t = const void*;
using TCppType_t = void*;
using TCppConstType_t = const void*;
using TCppFunction_t = void*;
using TCppConstFunction_t = const void*;
using TCppFuncAddr_t = void*;
Expand Down Expand Up @@ -94,12 +95,14 @@ enum Operator : unsigned char {
};

enum OperatorArity : unsigned char { kUnary = 1, kBinary, kBoth };
enum Signedness : unsigned char { kSigned = 1, kUnsigned };

/// Enum modelling CVR qualifiers.
enum QualKind : unsigned char {
Const = 1 << 0,
Volatile = 1 << 1,
Restrict = 1 << 2
Restrict = 1 << 2,
All = Const | Volatile | Restrict
};

/// Enum modelling programming languages.
Expand Down Expand Up @@ -368,7 +371,7 @@ CPPINTEROP_API bool IsComplete(TCppScope_t scope);
CPPINTEROP_API size_t SizeOf(TCppScope_t scope);

/// Checks if it is a "built-in" or a "complex" type.
CPPINTEROP_API bool IsBuiltin(TCppType_t type);
CPPINTEROP_API bool IsBuiltin(TCppConstType_t type);

/// Checks if it is a templated class.
CPPINTEROP_API bool IsTemplate(TCppScope_t handle);
Expand Down Expand Up @@ -686,6 +689,20 @@ CPPINTEROP_API bool IsRecordType(TCppType_t type);
/// Checks if the provided parameter is a Plain Old Data Type (POD).
CPPINTEROP_API bool IsPODType(TCppType_t type);

/// Checks if type has an integer representation.
/// If \p s is non-null, it is set to the signedness of the type.
CPPINTEROP_API bool IsIntegerType(TCppType_t type, Signedness* s = nullptr);

/// Checks if type has a floating representation
CPPINTEROP_API bool IsFloatingType(TCppType_t type);

/// Checks if two types are the equivalent
/// i.e. have the same canonical type
CPPINTEROP_API bool IsSameType(TCppType_t type_a, TCppType_t type_b);

/// Checks if type is a void pointer
CPPINTEROP_API bool IsVoidPointerType(TCppType_t type);

/// Checks if type is a pointer
CPPINTEROP_API bool IsPointerType(TCppType_t type);

Expand Down
1 change: 1 addition & 0 deletions interpreter/CppInterOp/include/CppInterOp/Dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ extern "C" CPPINTEROP_API CppFnPtrTy CppGetProcAddress(const char* procname);
DISPATCH_API(GetClassTemplateInstantiationArgs, \
decltype(&CppImpl::GetClassTemplateInstantiationArgs)) \
DISPATCH_API(IsClass, decltype(&CppImpl::IsClass)) \
DISPATCH_API(IsIntegerType, decltype(&CppImpl::IsIntegerType)) \
DISPATCH_API(GetType, decltype(&CppImpl::GetType)) \
DISPATCH_API(GetTypeFromScope, decltype(&CppImpl::GetTypeFromScope)) \
DISPATCH_API(GetComplexType, decltype(&CppImpl::GetComplexType)) \
Expand Down
1 change: 1 addition & 0 deletions interpreter/CppInterOp/lib/CppInterOp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ add_llvm_library(clangCppInterOp BUILDTREE_ONLY
CppInterOp.cpp
Dispatch.cpp
CXCppInterOp.cpp
Tracing.cpp
${DLM}
LINK_LIBS
${link_libs}
Expand Down
2 changes: 2 additions & 0 deletions interpreter/CppInterOp/lib/CppInterOp/CXCppInterOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ CXTypeKind cxtype_GetTypeKind(QualType T) {
TKCASE(ExtVector);
TKCASE(MemberPointer);
TKCASE(Auto);
#if CLANG_VERSION_MAJOR < 22
TKCASE(Elaborated);
#endif
TKCASE(Pipe);
TKCASE(Attributed);
TKCASE(BTFTagAttributed);
Expand Down
44 changes: 35 additions & 9 deletions interpreter/CppInterOp/lib/CppInterOp/Compatibility.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
#include "clang/Config/config.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#if CLANG_VERSION_MAJOR < 22
#include "clang/Driver/Options.h"
#else
#include "clang/Options/Options.h"
#endif
#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Sema/Sema.h"

Expand All @@ -33,6 +37,24 @@
#include <memory>
#include <string>

#if CLANG_VERSION_MAJOR < 22
#define clang_driver_options clang::driver::options
#else
#define clang_driver_options clang::options
#endif

#if CLANG_VERSION_MAJOR < 22
#define Suppress_Elab SuppressElaboration
#else
#define Suppress_Elab FullyQualifiedName
#endif

#if CLANG_VERSION_MAJOR < 22
#define Get_Tag_Type getTagDeclType
#else
#define Get_Tag_Type getCanonicalTagType
#endif

#ifdef _MSC_VER
#define dup _dup
#define dup2 _dup2
Expand Down Expand Up @@ -266,7 +288,7 @@ inline bool detectCudaInstallPath(const std::vector<const char*>& args,

// --cuda-path was explicitly provided in user args
if (auto* A =
C->getArgs().getLastArg(clang::driver::options::OPT_cuda_path_EQ)) {
C->getArgs().getLastArg(clang_driver_options::OPT_cuda_path_EQ)) {
std::string Candidate = A->getValue();
if (llvm::sys::fs::is_directory(Candidate + "/include")) {
CudaPath = Candidate;
Expand Down Expand Up @@ -502,8 +524,20 @@ inline void maybeMangleDeclName(const clang::GlobalDecl& GD,
// Clang 18 - Add new Interpreter methods: CodeComplete

inline llvm::orc::LLJIT* getExecutionEngine(clang::Interpreter& I) {
#if CLANG_VERSION_MAJOR < 22
auto* engine = &llvm::cantFail(I.getExecutionEngine());
return const_cast<llvm::orc::LLJIT*>(engine);
#else
// FIXME: Remove the need of exposing the low-level execution engine and kill
// this horrible hack.
struct OrcIncrementalExecutor : public clang::IncrementalExecutor {
std::unique_ptr<llvm::orc::LLJIT> Jit;
};

auto& engine = static_cast<OrcIncrementalExecutor&>(
llvm::cantFail(I.getExecutionEngine()));
return engine.Jit.get();
#endif
}

inline llvm::Expected<llvm::JITTargetAddress>
Expand Down Expand Up @@ -612,19 +646,11 @@ inline void InstantiateClassTemplateSpecialization(
#ifdef CPPINTEROP_USE_CLING
cling::Interpreter::PushTransactionRAII RAII(&interp);
#endif
#if CLANG_VERSION_MAJOR < 20
interp.getSema().InstantiateClassTemplateSpecialization(
clang::SourceLocation::getFromRawEncoding(1), CTSD,

clang::TemplateSpecializationKind::TSK_ExplicitInstantiationDefinition,
/*Complain=*/true);
#else
interp.getSema().InstantiateClassTemplateSpecialization(
clang::SourceLocation::getFromRawEncoding(1), CTSD,
clang::TemplateSpecializationKind::TSK_ExplicitInstantiationDefinition,
/*Complain=*/true,
/*PrimaryHasMatchedPackOnParmToNonPackOnArg=*/false);
#endif
}
} // namespace compat

Expand Down
Loading
Loading