Files
sx/clang_shim.h
2026-02-22 17:24:04 +02:00

58 lines
1.1 KiB
C

#ifndef SX_CLANG_SHIM_H
#define SX_CLANG_SHIM_H
#include <llvm-c/Core.h>
#ifdef __cplusplus
extern "C" {
#endif
/* --- Header parsing --- */
typedef struct {
const char *name;
const char *type_spelling;
} SxCParamInfo;
typedef struct {
const char *name;
const char *return_type;
SxCParamInfo *params;
int num_params;
const char *source_file;
unsigned source_line;
} SxCFunctionInfo;
typedef struct {
SxCFunctionInfo *functions;
int num_functions;
} SxCHeaderInfo;
SxCHeaderInfo *sx_clang_parse_header(
const char *filename,
const char **args, int num_args,
char **out_error);
void sx_clang_free_header_info(SxCHeaderInfo *info);
/* --- C source compilation to LLVM module --- */
LLVMModuleRef sx_clang_compile_to_module(
LLVMContextRef ctx,
const char *filename,
const char **args, int num_args,
char **out_error);
/* --- C source compilation to native object code --- */
LLVMMemoryBufferRef sx_clang_compile_to_object(
const char *filename,
const char **args, int num_args,
char **out_error);
#ifdef __cplusplus
}
#endif
#endif /* SX_CLANG_SHIM_H */