Skip to content

Commit f14a9ba

Browse files
committed
[interop] Update CppInterOp to latest
This version bump pulls in fixes to the CMake, upstreamed in compiler-research/CppInterOp#517
1 parent 381db28 commit f14a9ba

File tree

10 files changed

+570
-112
lines changed

10 files changed

+570
-112
lines changed

Diff for: .github/workflows/cppinterop-diff.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v4
1717
with:
1818
repository: compiler-research/CppInterOp
19-
ref: b0c3e360bdbea9618dd2744836671667c108bf97
19+
ref: 33bfa391c9322bd7cb79f954e54eedef486c999a
2020
path: CppInterOp
2121
- name: Drop directories that are not added to ROOT
2222
working-directory: CppInterOp

Diff for: interpreter/CppInterOp/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
6161
endif()
6262
if (NOT DEFINED Clang_DIR)
6363
set(Clang_DIR ${Cling_DIR})
64+
endif()
6465
endif()
65-
endif()
6666

6767
include(GNUInstallDirs)
6868
## Define supported version of clang and llvm

Diff for: interpreter/CppInterOp/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.6.0;dev
1+
1.7.0;dev

Diff for: interpreter/CppInterOp/docs/ReleaseNotes.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Introduction
22

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

19-
## What's New in CppInterOp 1.6.0?
19+
## What's New in CppInterOp 1.7.0?
2020

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

5050
<!---Get release bugs
51-
git log v1.5.0..main | grep 'Fixes|Closes'
51+
git log v1.6.0..main | grep 'Fixes|Closes'
5252
--->
5353

5454
## Special Kudos
@@ -61,6 +61,6 @@ FirstName LastName (#commits)
6161
A B (N)
6262

6363
<!---Find contributor list for this release
64-
git log --pretty=format:"%an" v1.5.0...main | sort | uniq -c | sort -rn |\
64+
git log --pretty=format:"%an" v1.6.0...main | sort | uniq -c | sort -rn |\
6565
sed -E 's,^ *([0-9]+) (.*)$,\2 \(\1\),'
6666
--->

Diff for: interpreter/CppInterOp/include/clang-c/CXCppInterOp.h

+46-39
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ typedef struct CXInterpreterImpl* CXInterpreter;
3434
*
3535
* \returns a \c CXInterpreter.
3636
*/
37-
CXInterpreter clang_createInterpreter(const char* const* argv, int argc);
37+
CINDEX_LINKAGE CXInterpreter clang_createInterpreter(const char* const* argv,
38+
int argc);
3839

3940
typedef void* TInterp_t;
4041

@@ -43,27 +44,29 @@ typedef void* TInterp_t;
4344
*
4445
* \returns a \c CXInterpreter.
4546
*/
46-
CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I);
47+
CINDEX_LINKAGE CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I);
4748

4849
/**
4950
* Returns a pointer to the underlying interpreter.
5051
*/
51-
void* clang_Interpreter_getClangInterpreter(CXInterpreter I);
52+
CINDEX_LINKAGE void* clang_Interpreter_getClangInterpreter(CXInterpreter I);
5253

5354
/**
5455
* Returns a \c TInterp_t and takes the ownership.
5556
*/
56-
TInterp_t clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I);
57+
CINDEX_LINKAGE TInterp_t
58+
clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I);
5759

5860
/**
5961
* Undo N previous incremental inputs.
6062
*/
61-
enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, unsigned int N);
63+
CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_undo(CXInterpreter I,
64+
unsigned int N);
6265

6366
/**
6467
* Dispose of the given interpreter context.
6568
*/
66-
void clang_Interpreter_dispose(CXInterpreter I);
69+
CINDEX_LINKAGE void clang_Interpreter_dispose(CXInterpreter I);
6770

6871
/**
6972
* Describes the return result of the different routines that do the incremental
@@ -95,8 +98,9 @@ typedef enum {
9598
*
9699
* \param prepend Whether to prepend the directory to the search path.
97100
*/
98-
void clang_Interpreter_addSearchPath(CXInterpreter I, const char* dir,
99-
bool isUser, bool prepend);
101+
CINDEX_LINKAGE void clang_Interpreter_addSearchPath(CXInterpreter I,
102+
const char* dir,
103+
bool isUser, bool prepend);
100104

101105
/**
102106
* Add an include path.
@@ -105,7 +109,8 @@ void clang_Interpreter_addSearchPath(CXInterpreter I, const char* dir,
105109
*
106110
* \param dir The directory to add.
107111
*/
108-
void clang_Interpreter_addIncludePath(CXInterpreter I, const char* dir);
112+
CINDEX_LINKAGE void clang_Interpreter_addIncludePath(CXInterpreter I,
113+
const char* dir);
109114

110115
/**
111116
* Declares a code snippet in \c code and does not execute it.
@@ -118,8 +123,8 @@ void clang_Interpreter_addIncludePath(CXInterpreter I, const char* dir);
118123
*
119124
* \returns a \c CXErrorCode.
120125
*/
121-
enum CXErrorCode clang_Interpreter_declare(CXInterpreter I, const char* code,
122-
bool silent);
126+
CINDEX_LINKAGE enum CXErrorCode
127+
clang_Interpreter_declare(CXInterpreter I, const char* code, bool silent);
123128

124129
/**
125130
* Declares and executes a code snippet in \c code.
@@ -130,7 +135,8 @@ enum CXErrorCode clang_Interpreter_declare(CXInterpreter I, const char* code,
130135
*
131136
* \returns a \c CXErrorCode.
132137
*/
133-
enum CXErrorCode clang_Interpreter_process(CXInterpreter I, const char* code);
138+
CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_process(CXInterpreter I,
139+
const char* code);
134140

135141
/**
136142
* An opaque pointer representing a lightweight struct that is used for carrying
@@ -143,14 +149,14 @@ typedef void* CXValue;
143149
*
144150
* \returns a \c CXValue.
145151
*/
146-
CXValue clang_createValue(void);
152+
CINDEX_LINKAGE CXValue clang_createValue(void);
147153

148154
/**
149155
* Dispose of the given CXValue.
150156
*
151157
* \param V The CXValue to dispose.
152158
*/
153-
void clang_Value_dispose(CXValue V);
159+
CINDEX_LINKAGE void clang_Value_dispose(CXValue V);
154160

155161
/**
156162
* Declares, executes and stores the execution result to \c V.
@@ -163,8 +169,8 @@ void clang_Value_dispose(CXValue V);
163169
*
164170
* \returns a \c CXErrorCode.
165171
*/
166-
enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code,
167-
CXValue V);
172+
CINDEX_LINKAGE enum CXErrorCode
173+
clang_Interpreter_evaluate(CXInterpreter I, const char* code, CXValue V);
168174

169175
/**
170176
* Looks up the library if access is enabled.
@@ -175,7 +181,8 @@ enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code,
175181
*
176182
* \returns the path to the library.
177183
*/
178-
CXString clang_Interpreter_lookupLibrary(CXInterpreter I, const char* lib_name);
184+
CINDEX_LINKAGE CXString clang_Interpreter_lookupLibrary(CXInterpreter I,
185+
const char* lib_name);
179186

180187
/**
181188
* Finds \c lib_stem considering the list of search paths and loads it by
@@ -189,9 +196,8 @@ CXString clang_Interpreter_lookupLibrary(CXInterpreter I, const char* lib_name);
189196
*
190197
* \returns a \c CXInterpreter_CompilationResult.
191198
*/
192-
CXInterpreter_CompilationResult
193-
clang_Interpreter_loadLibrary(CXInterpreter I, const char* lib_stem,
194-
bool lookup);
199+
CINDEX_LINKAGE CXInterpreter_CompilationResult clang_Interpreter_loadLibrary(
200+
CXInterpreter I, const char* lib_stem, bool lookup);
195201

196202
/**
197203
* Finds \c lib_stem considering the list of search paths and unloads it by
@@ -201,7 +207,8 @@ clang_Interpreter_loadLibrary(CXInterpreter I, const char* lib_stem,
201207
*
202208
* \param lib_stem The stem of the library to unload.
203209
*/
204-
void clang_Interpreter_unloadLibrary(CXInterpreter I, const char* lib_stem);
210+
CINDEX_LINKAGE void clang_Interpreter_unloadLibrary(CXInterpreter I,
211+
const char* lib_stem);
205212

206213
/**
207214
* @}
@@ -226,40 +233,41 @@ typedef struct {
226233
} CXScope;
227234

228235
// for debugging purposes
229-
void clang_scope_dump(CXScope S);
236+
CINDEX_LINKAGE void clang_scope_dump(CXScope S);
230237

231238
/**
232239
* Checks if a class has a default constructor.
233240
*/
234-
bool clang_hasDefaultConstructor(CXScope S);
241+
CINDEX_LINKAGE bool clang_hasDefaultConstructor(CXScope S);
235242

236243
/**
237244
* Returns the default constructor of a class, if any.
238245
*/
239-
CXScope clang_getDefaultConstructor(CXScope S);
246+
CINDEX_LINKAGE CXScope clang_getDefaultConstructor(CXScope S);
240247

241248
/**
242249
* Returns the class destructor, if any.
243250
*/
244-
CXScope clang_getDestructor(CXScope S);
251+
CINDEX_LINKAGE CXScope clang_getDestructor(CXScope S);
245252

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

252259
/**
253260
* Checks if a function is a templated function.
254261
*/
255-
bool clang_isTemplatedFunction(CXScope func);
262+
CINDEX_LINKAGE bool clang_isTemplatedFunction(CXScope func);
256263

257264
/**
258265
* This function performs a lookup to check if there is a templated function of
259266
* that type. \c parent is mandatory, the global scope should be used as the
260267
* default value.
261268
*/
262-
bool clang_existsFunctionTemplate(const char* name, CXScope parent);
269+
CINDEX_LINKAGE bool clang_existsFunctionTemplate(const char* name,
270+
CXScope parent);
263271

264272
typedef struct {
265273
void* Type;
@@ -282,9 +290,8 @@ typedef struct {
282290
* \returns a \c CXScope representing the instantiated templated
283291
* class/function/variable.
284292
*/
285-
CXScope clang_instantiateTemplate(CXScope tmpl,
286-
CXTemplateArgInfo* template_args,
287-
size_t template_args_size);
293+
CINDEX_LINKAGE CXScope clang_instantiateTemplate(
294+
CXScope tmpl, CXTemplateArgInfo* template_args, size_t template_args_size);
288295

289296
/**
290297
* A fake CXType for working with the interpreter.
@@ -299,12 +306,12 @@ typedef struct {
299306
/**
300307
* Gets the string of the type that is passed as a parameter.
301308
*/
302-
CXString clang_getTypeAsString(CXQualType type);
309+
CINDEX_LINKAGE CXString clang_getTypeAsString(CXQualType type);
303310

304311
/**
305312
* Returns the complex of the provided type.
306313
*/
307-
CXQualType clang_getComplexType(CXQualType eltype);
314+
CINDEX_LINKAGE CXQualType clang_getComplexType(CXQualType eltype);
308315

309316
/**
310317
* An opaque pointer representing the object of a given type (\c CXScope).
@@ -314,18 +321,18 @@ typedef void* CXObject;
314321
/**
315322
* Allocates memory for the given type.
316323
*/
317-
CXObject clang_allocate(unsigned int n);
324+
CINDEX_LINKAGE CXObject clang_allocate(unsigned int n);
318325

319326
/**
320327
* Deallocates memory for a given class.
321328
*/
322-
void clang_deallocate(CXObject address);
329+
CINDEX_LINKAGE void clang_deallocate(CXObject address);
323330

324331
/**
325332
* Creates an object of class \c scope and calls its default constructor. If \c
326333
* arena is set it uses placement new.
327334
*/
328-
CXObject clang_construct(CXScope scope, void* arena);
335+
CINDEX_LINKAGE CXObject clang_construct(CXScope scope, void* arena);
329336

330337
/**
331338
* Creates a trampoline function and makes a call to a generic function or
@@ -341,8 +348,8 @@ CXObject clang_construct(CXScope scope, void* arena);
341348
*
342349
* \param self The 'this pointer' of the object.
343350
*/
344-
void clang_invoke(CXScope func, void* result, void** args, size_t n,
345-
void* self);
351+
CINDEX_LINKAGE void clang_invoke(CXScope func, void* result, void** args,
352+
size_t n, void* self);
346353

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

359366
/**
360367
* @}

Diff for: interpreter/CppInterOp/include/clang/Interpreter/CppInterOp.h

+20-6
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,9 @@ namespace Cpp {
210210
/// Checks if the scope is a class or not.
211211
CPPINTEROP_API bool IsClass(TCppScope_t scope);
212212

213+
/// Checks if the scope is a function.
214+
CPPINTEROP_API bool IsFunction(TCppScope_t scope);
215+
213216
/// Checks if the type is a function pointer.
214217
CPPINTEROP_API bool IsFunctionPointerType(TCppType_t type);
215218

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

510+
/// Checks if type is a pointer
511+
CPPINTEROP_API bool IsPointerType(TCppType_t type);
512+
513+
/// Get the underlying pointee type
514+
CPPINTEROP_API TCppType_t GetPointeeType(TCppType_t type);
515+
516+
/// Checks if type is a reference
517+
CPPINTEROP_API bool IsReferenceType(TCppType_t type);
518+
519+
/// Get the type that the reference refers to
520+
CPPINTEROP_API TCppType_t GetNonReferenceType(TCppType_t type);
521+
507522
/// Gets the pure, Underlying Type (as opposed to the Using Type).
508523
CPPINTEROP_API TCppType_t GetUnderlyingType(TCppType_t type);
509524

@@ -694,17 +709,16 @@ namespace Cpp {
694709
CPPINTEROP_API TCppFunction_t
695710
InstantiateTemplateFunctionFromString(const char* function_template);
696711

697-
/// Finds best template match based on explicit template parameters and
698-
/// argument types
712+
/// Finds best overload match based on explicit template parameters (if any)
713+
/// and argument types.
699714
///
700-
///\param[in] candidates - Vector of suitable candidates that come under the
701-
/// parent scope and have the same name (obtained using
702-
/// GetClassTemplatedMethods)
715+
///\param[in] candidates - vector of overloads that come under the
716+
/// parent scope and have the same name
703717
///\param[in] explicit_types - set of expicitly instantiated template types
704718
///\param[in] arg_types - set of argument types
705719
///\returns Instantiated function pointer
706720
CPPINTEROP_API TCppFunction_t
707-
BestTemplateFunctionMatch(const std::vector<TCppFunction_t>& candidates,
721+
BestOverloadFunctionMatch(const std::vector<TCppFunction_t>& candidates,
708722
const std::vector<TemplateArgInfo>& explicit_types,
709723
const std::vector<TemplateArgInfo>& arg_types);
710724

Diff for: interpreter/CppInterOp/lib/Interpreter/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,8 @@ else()
133133
LINK_LIBS
134134
${link_libs}
135135
)
136+
137+
target_compile_definitions(clangCppInterOp PUBLIC "_CINDEX_LIB_") # workaround for the use of `CINDEX_LINKAGE`
136138
endif()
137139

138140
string(REPLACE ";" "\;" _VER CPPINTEROP_VERSION)

0 commit comments

Comments
 (0)