Skip to content

[interop] Update CppInterOp to latest #17952

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 1 commit into from
Mar 11, 2025
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: 1 addition & 1 deletion .github/workflows/cppinterop-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: compiler-research/CppInterOp
ref: b0c3e360bdbea9618dd2744836671667c108bf97
ref: 33bfa391c9322bd7cb79f954e54eedef486c999a
path: CppInterOp
- name: Drop directories that are not added to ROOT
working-directory: CppInterOp
Expand Down
2 changes: 1 addition & 1 deletion interpreter/CppInterOp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
endif()
if (NOT DEFINED Clang_DIR)
set(Clang_DIR ${Cling_DIR})
endif()
endif()
endif()

include(GNUInstallDirs)
## Define supported version of clang and llvm
Expand Down
2 changes: 1 addition & 1 deletion interpreter/CppInterOp/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.6.0;dev
1.7.0;dev
8 changes: 4 additions & 4 deletions interpreter/CppInterOp/docs/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Introduction

This document contains the release notes for the language interoperability
library CppInterOp, release 1.6.0. CppInterOp is built on top of
library CppInterOp, release 1.7.0. CppInterOp is built on top of
[Clang](http://clang.llvm.org) and [LLVM](http://llvm.org%3E) compiler
infrastructure. Here we describe the status of CppInterOp in some detail,
including major improvements from the previous release and new feature work.
Expand All @@ -16,7 +16,7 @@ interoperability on the fly. In such scenarios CppInterOp can be used to provide
the necessary introspection information to the other side helping the language
cross talk.

## What's New in CppInterOp 1.6.0?
## What's New in CppInterOp 1.7.0?

Some of the major new features and improvements to CppInterOp are listed here.
Generic improvements to CppInterOp as a whole or to its underlying
Expand Down Expand Up @@ -48,7 +48,7 @@ infrastructure are described first.
[XXX](https://github.com/compiler-research/CppInterOp/issues/XXX)

<!---Get release bugs
git log v1.5.0..main | grep 'Fixes|Closes'
git log v1.6.0..main | grep 'Fixes|Closes'
--->

## Special Kudos
Expand All @@ -61,6 +61,6 @@ FirstName LastName (#commits)
A B (N)

<!---Find contributor list for this release
git log --pretty=format:"%an" v1.5.0...main | sort | uniq -c | sort -rn |\
git log --pretty=format:"%an" v1.6.0...main | sort | uniq -c | sort -rn |\
sed -E 's,^ *([0-9]+) (.*)$,\2 \(\1\),'
--->
85 changes: 46 additions & 39 deletions interpreter/CppInterOp/include/clang-c/CXCppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ typedef struct CXInterpreterImpl* CXInterpreter;
*
* \returns a \c CXInterpreter.
*/
CXInterpreter clang_createInterpreter(const char* const* argv, int argc);
CINDEX_LINKAGE CXInterpreter clang_createInterpreter(const char* const* argv,
int argc);

typedef void* TInterp_t;

Expand All @@ -43,27 +44,29 @@ typedef void* TInterp_t;
*
* \returns a \c CXInterpreter.
*/
CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I);
CINDEX_LINKAGE CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I);

/**
* Returns a pointer to the underlying interpreter.
*/
void* clang_Interpreter_getClangInterpreter(CXInterpreter I);
CINDEX_LINKAGE void* clang_Interpreter_getClangInterpreter(CXInterpreter I);

/**
* Returns a \c TInterp_t and takes the ownership.
*/
TInterp_t clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I);
CINDEX_LINKAGE TInterp_t
clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I);

/**
* Undo N previous incremental inputs.
*/
enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, unsigned int N);
CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_undo(CXInterpreter I,
unsigned int N);

/**
* Dispose of the given interpreter context.
*/
void clang_Interpreter_dispose(CXInterpreter I);
CINDEX_LINKAGE void clang_Interpreter_dispose(CXInterpreter I);

/**
* Describes the return result of the different routines that do the incremental
Expand Down Expand Up @@ -95,8 +98,9 @@ typedef enum {
*
* \param prepend Whether to prepend the directory to the search path.
*/
void clang_Interpreter_addSearchPath(CXInterpreter I, const char* dir,
bool isUser, bool prepend);
CINDEX_LINKAGE void clang_Interpreter_addSearchPath(CXInterpreter I,
const char* dir,
bool isUser, bool prepend);

/**
* Add an include path.
Expand All @@ -105,7 +109,8 @@ void clang_Interpreter_addSearchPath(CXInterpreter I, const char* dir,
*
* \param dir The directory to add.
*/
void clang_Interpreter_addIncludePath(CXInterpreter I, const char* dir);
CINDEX_LINKAGE void clang_Interpreter_addIncludePath(CXInterpreter I,
const char* dir);

/**
* Declares a code snippet in \c code and does not execute it.
Expand All @@ -118,8 +123,8 @@ void clang_Interpreter_addIncludePath(CXInterpreter I, const char* dir);
*
* \returns a \c CXErrorCode.
*/
enum CXErrorCode clang_Interpreter_declare(CXInterpreter I, const char* code,
bool silent);
CINDEX_LINKAGE enum CXErrorCode
clang_Interpreter_declare(CXInterpreter I, const char* code, bool silent);

/**
* Declares and executes a code snippet in \c code.
Expand All @@ -130,7 +135,8 @@ enum CXErrorCode clang_Interpreter_declare(CXInterpreter I, const char* code,
*
* \returns a \c CXErrorCode.
*/
enum CXErrorCode clang_Interpreter_process(CXInterpreter I, const char* code);
CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_process(CXInterpreter I,
const char* code);

/**
* An opaque pointer representing a lightweight struct that is used for carrying
Expand All @@ -143,14 +149,14 @@ typedef void* CXValue;
*
* \returns a \c CXValue.
*/
CXValue clang_createValue(void);
CINDEX_LINKAGE CXValue clang_createValue(void);

/**
* Dispose of the given CXValue.
*
* \param V The CXValue to dispose.
*/
void clang_Value_dispose(CXValue V);
CINDEX_LINKAGE void clang_Value_dispose(CXValue V);

/**
* Declares, executes and stores the execution result to \c V.
Expand All @@ -163,8 +169,8 @@ void clang_Value_dispose(CXValue V);
*
* \returns a \c CXErrorCode.
*/
enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code,
CXValue V);
CINDEX_LINKAGE enum CXErrorCode
clang_Interpreter_evaluate(CXInterpreter I, const char* code, CXValue V);

/**
* Looks up the library if access is enabled.
Expand All @@ -175,7 +181,8 @@ enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code,
*
* \returns the path to the library.
*/
CXString clang_Interpreter_lookupLibrary(CXInterpreter I, const char* lib_name);
CINDEX_LINKAGE CXString clang_Interpreter_lookupLibrary(CXInterpreter I,
const char* lib_name);

/**
* Finds \c lib_stem considering the list of search paths and loads it by
Expand All @@ -189,9 +196,8 @@ CXString clang_Interpreter_lookupLibrary(CXInterpreter I, const char* lib_name);
*
* \returns a \c CXInterpreter_CompilationResult.
*/
CXInterpreter_CompilationResult
clang_Interpreter_loadLibrary(CXInterpreter I, const char* lib_stem,
bool lookup);
CINDEX_LINKAGE CXInterpreter_CompilationResult clang_Interpreter_loadLibrary(
CXInterpreter I, const char* lib_stem, bool lookup);

/**
* Finds \c lib_stem considering the list of search paths and unloads it by
Expand All @@ -201,7 +207,8 @@ clang_Interpreter_loadLibrary(CXInterpreter I, const char* lib_stem,
*
* \param lib_stem The stem of the library to unload.
*/
void clang_Interpreter_unloadLibrary(CXInterpreter I, const char* lib_stem);
CINDEX_LINKAGE void clang_Interpreter_unloadLibrary(CXInterpreter I,
const char* lib_stem);

/**
* @}
Expand All @@ -226,40 +233,41 @@ typedef struct {
} CXScope;

// for debugging purposes
void clang_scope_dump(CXScope S);
CINDEX_LINKAGE void clang_scope_dump(CXScope S);

/**
* Checks if a class has a default constructor.
*/
bool clang_hasDefaultConstructor(CXScope S);
CINDEX_LINKAGE bool clang_hasDefaultConstructor(CXScope S);

/**
* Returns the default constructor of a class, if any.
*/
CXScope clang_getDefaultConstructor(CXScope S);
CINDEX_LINKAGE CXScope clang_getDefaultConstructor(CXScope S);

/**
* Returns the class destructor, if any.
*/
CXScope clang_getDestructor(CXScope S);
CINDEX_LINKAGE CXScope clang_getDestructor(CXScope S);

/**
* Returns a stringified version of a given function signature in the form:
* void N::f(int i, double d, long l = 0, char ch = 'a').
*/
CXString clang_getFunctionSignature(CXScope func);
CINDEX_LINKAGE CXString clang_getFunctionSignature(CXScope func);

/**
* Checks if a function is a templated function.
*/
bool clang_isTemplatedFunction(CXScope func);
CINDEX_LINKAGE bool clang_isTemplatedFunction(CXScope func);

/**
* This function performs a lookup to check if there is a templated function of
* that type. \c parent is mandatory, the global scope should be used as the
* default value.
*/
bool clang_existsFunctionTemplate(const char* name, CXScope parent);
CINDEX_LINKAGE bool clang_existsFunctionTemplate(const char* name,
CXScope parent);

typedef struct {
void* Type;
Expand All @@ -282,9 +290,8 @@ typedef struct {
* \returns a \c CXScope representing the instantiated templated
* class/function/variable.
*/
CXScope clang_instantiateTemplate(CXScope tmpl,
CXTemplateArgInfo* template_args,
size_t template_args_size);
CINDEX_LINKAGE CXScope clang_instantiateTemplate(
CXScope tmpl, CXTemplateArgInfo* template_args, size_t template_args_size);

/**
* A fake CXType for working with the interpreter.
Expand All @@ -299,12 +306,12 @@ typedef struct {
/**
* Gets the string of the type that is passed as a parameter.
*/
CXString clang_getTypeAsString(CXQualType type);
CINDEX_LINKAGE CXString clang_getTypeAsString(CXQualType type);

/**
* Returns the complex of the provided type.
*/
CXQualType clang_getComplexType(CXQualType eltype);
CINDEX_LINKAGE CXQualType clang_getComplexType(CXQualType eltype);

/**
* An opaque pointer representing the object of a given type (\c CXScope).
Expand All @@ -314,18 +321,18 @@ typedef void* CXObject;
/**
* Allocates memory for the given type.
*/
CXObject clang_allocate(unsigned int n);
CINDEX_LINKAGE CXObject clang_allocate(unsigned int n);

/**
* Deallocates memory for a given class.
*/
void clang_deallocate(CXObject address);
CINDEX_LINKAGE void clang_deallocate(CXObject address);

/**
* Creates an object of class \c scope and calls its default constructor. If \c
* arena is set it uses placement new.
*/
CXObject clang_construct(CXScope scope, void* arena);
CINDEX_LINKAGE CXObject clang_construct(CXScope scope, void* arena);

/**
* Creates a trampoline function and makes a call to a generic function or
Expand All @@ -341,8 +348,8 @@ CXObject clang_construct(CXScope scope, void* arena);
*
* \param self The 'this pointer' of the object.
*/
void clang_invoke(CXScope func, void* result, void** args, size_t n,
void* self);
CINDEX_LINKAGE void clang_invoke(CXScope func, void* result, void** args,
size_t n, void* self);

/**
* Calls the destructor of object of type \c type. When withFree is true it
Expand All @@ -354,7 +361,7 @@ void clang_invoke(CXScope func, void* result, void** args, size_t n,
*
* \param withFree Whether to call operator delete/free or not.
*/
void clang_destruct(CXObject This, CXScope S, bool withFree);
CINDEX_LINKAGE void clang_destruct(CXObject This, CXScope S, bool withFree);

/**
* @}
Expand Down
26 changes: 20 additions & 6 deletions interpreter/CppInterOp/include/clang/Interpreter/CppInterOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ namespace Cpp {
/// Checks if the scope is a class or not.
CPPINTEROP_API bool IsClass(TCppScope_t scope);

/// Checks if the scope is a function.
CPPINTEROP_API bool IsFunction(TCppScope_t scope);

/// Checks if the type is a function pointer.
CPPINTEROP_API bool IsFunctionPointerType(TCppType_t type);

Expand Down Expand Up @@ -504,6 +507,18 @@ namespace Cpp {
/// Checks if the provided parameter is a Plain Old Data Type (POD).
CPPINTEROP_API bool IsPODType(TCppType_t type);

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

/// Get the underlying pointee type
CPPINTEROP_API TCppType_t GetPointeeType(TCppType_t type);

/// Checks if type is a reference
CPPINTEROP_API bool IsReferenceType(TCppType_t type);

/// Get the type that the reference refers to
CPPINTEROP_API TCppType_t GetNonReferenceType(TCppType_t type);

/// Gets the pure, Underlying Type (as opposed to the Using Type).
CPPINTEROP_API TCppType_t GetUnderlyingType(TCppType_t type);

Expand Down Expand Up @@ -694,17 +709,16 @@ namespace Cpp {
CPPINTEROP_API TCppFunction_t
InstantiateTemplateFunctionFromString(const char* function_template);

/// Finds best template match based on explicit template parameters and
/// argument types
/// Finds best overload match based on explicit template parameters (if any)
/// and argument types.
///
///\param[in] candidates - Vector of suitable candidates that come under the
/// parent scope and have the same name (obtained using
/// GetClassTemplatedMethods)
///\param[in] candidates - vector of overloads that come under the
/// parent scope and have the same name
///\param[in] explicit_types - set of expicitly instantiated template types
///\param[in] arg_types - set of argument types
///\returns Instantiated function pointer
CPPINTEROP_API TCppFunction_t
BestTemplateFunctionMatch(const std::vector<TCppFunction_t>& candidates,
BestOverloadFunctionMatch(const std::vector<TCppFunction_t>& candidates,
const std::vector<TemplateArgInfo>& explicit_types,
const std::vector<TemplateArgInfo>& arg_types);

Expand Down
2 changes: 2 additions & 0 deletions interpreter/CppInterOp/lib/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ else()
LINK_LIBS
${link_libs}
)

target_compile_definitions(clangCppInterOp PUBLIC "_CINDEX_LIB_") # workaround for the use of `CINDEX_LINKAGE`
endif()

string(REPLACE ";" "\;" _VER CPPINTEROP_VERSION)
Expand Down
Loading
Loading