|
1 | 1 | From 21805e1bdbdda55f36f8e7d76a99032e86b0c750 Mon Sep 17 00:00:00 2001 |
2 | 2 | |
3 | 3 | Date: Sat, 11 Jan 2025 20:56:57 +0900 |
4 | | -Subject: [PATCH] Restrict the use of `_s` (Annex K) functions to MSVC |
| 4 | +Subject: [PATCH 1/2] Restrict the use of `_s` (Annex K) functions to MSVC |
5 | 5 |
|
6 | 6 | These `_s` secure functions are introduced in C11 as optional bounds-checking interfaces, there is no guarantee that they are implemented/enabled by other compilers. |
7 | 7 | --- |
@@ -47,3 +47,286 @@ index e25ee9a..6064952 100644 |
47 | 47 | -- |
48 | 48 | 2.39.5 (Apple Git-154) |
49 | 49 |
|
| 50 | + |
| 51 | +From ce769c6e91730c753e30dfd072a3d991d87e4688 Mon Sep 17 00:00:00 2001 |
| 52 | + |
| 53 | +Date: Sun, 12 Jan 2025 19:01:50 +0900 |
| 54 | +Subject: [PATCH 2/2] Fix symbol visibility issues for C API |
| 55 | + |
| 56 | +--- |
| 57 | + include/clang-c/CXCppInterOp.h | 85 ++++++++++++++++++---------------- |
| 58 | + 1 file changed, 46 insertions(+), 39 deletions(-) |
| 59 | + |
| 60 | +diff --git a/include/clang-c/CXCppInterOp.h b/include/clang-c/CXCppInterOp.h |
| 61 | +index e5b057d..f885e19 100644 |
| 62 | +--- a/include/clang-c/CXCppInterOp.h |
| 63 | ++++ b/include/clang-c/CXCppInterOp.h |
| 64 | +@@ -34,7 +34,8 @@ typedef struct CXInterpreterImpl* CXInterpreter; |
| 65 | + * |
| 66 | + * \returns a \c CXInterpreter. |
| 67 | + */ |
| 68 | +-CXInterpreter clang_createInterpreter(const char* const* argv, int argc); |
| 69 | ++CINDEX_LINKAGE CXInterpreter clang_createInterpreter(const char* const* argv, |
| 70 | ++ int argc); |
| 71 | + |
| 72 | + typedef void* TInterp_t; |
| 73 | + |
| 74 | +@@ -43,27 +44,29 @@ typedef void* TInterp_t; |
| 75 | + * |
| 76 | + * \returns a \c CXInterpreter. |
| 77 | + */ |
| 78 | +-CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I); |
| 79 | ++CINDEX_LINKAGE CXInterpreter clang_createInterpreterFromRawPtr(TInterp_t I); |
| 80 | + |
| 81 | + /** |
| 82 | + * Returns a pointer to the underlying interpreter. |
| 83 | + */ |
| 84 | +-void* clang_Interpreter_getClangInterpreter(CXInterpreter I); |
| 85 | ++CINDEX_LINKAGE void* clang_Interpreter_getClangInterpreter(CXInterpreter I); |
| 86 | + |
| 87 | + /** |
| 88 | + * Returns a \c TInterp_t and takes the ownership. |
| 89 | + */ |
| 90 | +-TInterp_t clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I); |
| 91 | ++CINDEX_LINKAGE TInterp_t |
| 92 | ++clang_Interpreter_takeInterpreterAsPtr(CXInterpreter I); |
| 93 | + |
| 94 | + /** |
| 95 | + * Undo N previous incremental inputs. |
| 96 | + */ |
| 97 | +-enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, unsigned int N); |
| 98 | ++CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_undo(CXInterpreter I, |
| 99 | ++ unsigned int N); |
| 100 | + |
| 101 | + /** |
| 102 | + * Dispose of the given interpreter context. |
| 103 | + */ |
| 104 | +-void clang_Interpreter_dispose(CXInterpreter I); |
| 105 | ++CINDEX_LINKAGE void clang_Interpreter_dispose(CXInterpreter I); |
| 106 | + |
| 107 | + /** |
| 108 | + * Describes the return result of the different routines that do the incremental |
| 109 | +@@ -95,8 +98,9 @@ typedef enum { |
| 110 | + * |
| 111 | + * \param prepend Whether to prepend the directory to the search path. |
| 112 | + */ |
| 113 | +-void clang_Interpreter_addSearchPath(CXInterpreter I, const char* dir, |
| 114 | +- bool isUser, bool prepend); |
| 115 | ++CINDEX_LINKAGE void clang_Interpreter_addSearchPath(CXInterpreter I, |
| 116 | ++ const char* dir, |
| 117 | ++ bool isUser, bool prepend); |
| 118 | + |
| 119 | + /** |
| 120 | + * Add an include path. |
| 121 | +@@ -105,7 +109,8 @@ void clang_Interpreter_addSearchPath(CXInterpreter I, const char* dir, |
| 122 | + * |
| 123 | + * \param dir The directory to add. |
| 124 | + */ |
| 125 | +-void clang_Interpreter_addIncludePath(CXInterpreter I, const char* dir); |
| 126 | ++CINDEX_LINKAGE void clang_Interpreter_addIncludePath(CXInterpreter I, |
| 127 | ++ const char* dir); |
| 128 | + |
| 129 | + /** |
| 130 | + * Declares a code snippet in \c code and does not execute it. |
| 131 | +@@ -118,8 +123,8 @@ void clang_Interpreter_addIncludePath(CXInterpreter I, const char* dir); |
| 132 | + * |
| 133 | + * \returns a \c CXErrorCode. |
| 134 | + */ |
| 135 | +-enum CXErrorCode clang_Interpreter_declare(CXInterpreter I, const char* code, |
| 136 | +- bool silent); |
| 137 | ++CINDEX_LINKAGE enum CXErrorCode |
| 138 | ++clang_Interpreter_declare(CXInterpreter I, const char* code, bool silent); |
| 139 | + |
| 140 | + /** |
| 141 | + * Declares and executes a code snippet in \c code. |
| 142 | +@@ -130,7 +135,8 @@ enum CXErrorCode clang_Interpreter_declare(CXInterpreter I, const char* code, |
| 143 | + * |
| 144 | + * \returns a \c CXErrorCode. |
| 145 | + */ |
| 146 | +-enum CXErrorCode clang_Interpreter_process(CXInterpreter I, const char* code); |
| 147 | ++CINDEX_LINKAGE enum CXErrorCode clang_Interpreter_process(CXInterpreter I, |
| 148 | ++ const char* code); |
| 149 | + |
| 150 | + /** |
| 151 | + * An opaque pointer representing a lightweight struct that is used for carrying |
| 152 | +@@ -143,14 +149,14 @@ typedef void* CXValue; |
| 153 | + * |
| 154 | + * \returns a \c CXValue. |
| 155 | + */ |
| 156 | +-CXValue clang_createValue(void); |
| 157 | ++CINDEX_LINKAGE CXValue clang_createValue(void); |
| 158 | + |
| 159 | + /** |
| 160 | + * Dispose of the given CXValue. |
| 161 | + * |
| 162 | + * \param V The CXValue to dispose. |
| 163 | + */ |
| 164 | +-void clang_Value_dispose(CXValue V); |
| 165 | ++CINDEX_LINKAGE void clang_Value_dispose(CXValue V); |
| 166 | + |
| 167 | + /** |
| 168 | + * Declares, executes and stores the execution result to \c V. |
| 169 | +@@ -163,8 +169,8 @@ void clang_Value_dispose(CXValue V); |
| 170 | + * |
| 171 | + * \returns a \c CXErrorCode. |
| 172 | + */ |
| 173 | +-enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code, |
| 174 | +- CXValue V); |
| 175 | ++CINDEX_LINKAGE enum CXErrorCode |
| 176 | ++clang_Interpreter_evaluate(CXInterpreter I, const char* code, CXValue V); |
| 177 | + |
| 178 | + /** |
| 179 | + * Looks up the library if access is enabled. |
| 180 | +@@ -175,7 +181,8 @@ enum CXErrorCode clang_Interpreter_evaluate(CXInterpreter I, const char* code, |
| 181 | + * |
| 182 | + * \returns the path to the library. |
| 183 | + */ |
| 184 | +-CXString clang_Interpreter_lookupLibrary(CXInterpreter I, const char* lib_name); |
| 185 | ++CINDEX_LINKAGE CXString clang_Interpreter_lookupLibrary(CXInterpreter I, |
| 186 | ++ const char* lib_name); |
| 187 | + |
| 188 | + /** |
| 189 | + * Finds \c lib_stem considering the list of search paths and loads it by |
| 190 | +@@ -189,9 +196,8 @@ CXString clang_Interpreter_lookupLibrary(CXInterpreter I, const char* lib_name); |
| 191 | + * |
| 192 | + * \returns a \c CXInterpreter_CompilationResult. |
| 193 | + */ |
| 194 | +-CXInterpreter_CompilationResult |
| 195 | +-clang_Interpreter_loadLibrary(CXInterpreter I, const char* lib_stem, |
| 196 | +- bool lookup); |
| 197 | ++CINDEX_LINKAGE CXInterpreter_CompilationResult clang_Interpreter_loadLibrary( |
| 198 | ++ CXInterpreter I, const char* lib_stem, bool lookup); |
| 199 | + |
| 200 | + /** |
| 201 | + * Finds \c lib_stem considering the list of search paths and unloads it by |
| 202 | +@@ -201,7 +207,8 @@ clang_Interpreter_loadLibrary(CXInterpreter I, const char* lib_stem, |
| 203 | + * |
| 204 | + * \param lib_stem The stem of the library to unload. |
| 205 | + */ |
| 206 | +-void clang_Interpreter_unloadLibrary(CXInterpreter I, const char* lib_stem); |
| 207 | ++CINDEX_LINKAGE void clang_Interpreter_unloadLibrary(CXInterpreter I, |
| 208 | ++ const char* lib_stem); |
| 209 | + |
| 210 | + /** |
| 211 | + * @} |
| 212 | +@@ -226,40 +233,41 @@ typedef struct { |
| 213 | + } CXScope; |
| 214 | + |
| 215 | + // for debugging purposes |
| 216 | +-void clang_scope_dump(CXScope S); |
| 217 | ++CINDEX_LINKAGE void clang_scope_dump(CXScope S); |
| 218 | + |
| 219 | + /** |
| 220 | + * Checks if a class has a default constructor. |
| 221 | + */ |
| 222 | +-bool clang_hasDefaultConstructor(CXScope S); |
| 223 | ++CINDEX_LINKAGE bool clang_hasDefaultConstructor(CXScope S); |
| 224 | + |
| 225 | + /** |
| 226 | + * Returns the default constructor of a class, if any. |
| 227 | + */ |
| 228 | +-CXScope clang_getDefaultConstructor(CXScope S); |
| 229 | ++CINDEX_LINKAGE CXScope clang_getDefaultConstructor(CXScope S); |
| 230 | + |
| 231 | + /** |
| 232 | + * Returns the class destructor, if any. |
| 233 | + */ |
| 234 | +-CXScope clang_getDestructor(CXScope S); |
| 235 | ++CINDEX_LINKAGE CXScope clang_getDestructor(CXScope S); |
| 236 | + |
| 237 | + /** |
| 238 | + * Returns a stringified version of a given function signature in the form: |
| 239 | + * void N::f(int i, double d, long l = 0, char ch = 'a'). |
| 240 | + */ |
| 241 | +-CXString clang_getFunctionSignature(CXScope func); |
| 242 | ++CINDEX_LINKAGE CXString clang_getFunctionSignature(CXScope func); |
| 243 | + |
| 244 | + /** |
| 245 | + * Checks if a function is a templated function. |
| 246 | + */ |
| 247 | +-bool clang_isTemplatedFunction(CXScope func); |
| 248 | ++CINDEX_LINKAGE bool clang_isTemplatedFunction(CXScope func); |
| 249 | + |
| 250 | + /** |
| 251 | + * This function performs a lookup to check if there is a templated function of |
| 252 | + * that type. \c parent is mandatory, the global scope should be used as the |
| 253 | + * default value. |
| 254 | + */ |
| 255 | +-bool clang_existsFunctionTemplate(const char* name, CXScope parent); |
| 256 | ++CINDEX_LINKAGE bool clang_existsFunctionTemplate(const char* name, |
| 257 | ++ CXScope parent); |
| 258 | + |
| 259 | + typedef struct { |
| 260 | + void* Type; |
| 261 | +@@ -282,9 +290,8 @@ typedef struct { |
| 262 | + * \returns a \c CXScope representing the instantiated templated |
| 263 | + * class/function/variable. |
| 264 | + */ |
| 265 | +-CXScope clang_instantiateTemplate(CXScope tmpl, |
| 266 | +- CXTemplateArgInfo* template_args, |
| 267 | +- size_t template_args_size); |
| 268 | ++CINDEX_LINKAGE CXScope clang_instantiateTemplate( |
| 269 | ++ CXScope tmpl, CXTemplateArgInfo* template_args, size_t template_args_size); |
| 270 | + |
| 271 | + /** |
| 272 | + * A fake CXType for working with the interpreter. |
| 273 | +@@ -299,12 +306,12 @@ typedef struct { |
| 274 | + /** |
| 275 | + * Gets the string of the type that is passed as a parameter. |
| 276 | + */ |
| 277 | +-CXString clang_getTypeAsString(CXQualType type); |
| 278 | ++CINDEX_LINKAGE CXString clang_getTypeAsString(CXQualType type); |
| 279 | + |
| 280 | + /** |
| 281 | + * Returns the complex of the provided type. |
| 282 | + */ |
| 283 | +-CXQualType clang_getComplexType(CXQualType eltype); |
| 284 | ++CINDEX_LINKAGE CXQualType clang_getComplexType(CXQualType eltype); |
| 285 | + |
| 286 | + /** |
| 287 | + * An opaque pointer representing the object of a given type (\c CXScope). |
| 288 | +@@ -314,18 +321,18 @@ typedef void* CXObject; |
| 289 | + /** |
| 290 | + * Allocates memory for the given type. |
| 291 | + */ |
| 292 | +-CXObject clang_allocate(unsigned int n); |
| 293 | ++CINDEX_LINKAGE CXObject clang_allocate(unsigned int n); |
| 294 | + |
| 295 | + /** |
| 296 | + * Deallocates memory for a given class. |
| 297 | + */ |
| 298 | +-void clang_deallocate(CXObject address); |
| 299 | ++CINDEX_LINKAGE void clang_deallocate(CXObject address); |
| 300 | + |
| 301 | + /** |
| 302 | + * Creates an object of class \c scope and calls its default constructor. If \c |
| 303 | + * arena is set it uses placement new. |
| 304 | + */ |
| 305 | +-CXObject clang_construct(CXScope scope, void* arena); |
| 306 | ++CINDEX_LINKAGE CXObject clang_construct(CXScope scope, void* arena); |
| 307 | + |
| 308 | + /** |
| 309 | + * Creates a trampoline function and makes a call to a generic function or |
| 310 | +@@ -341,8 +348,8 @@ CXObject clang_construct(CXScope scope, void* arena); |
| 311 | + * |
| 312 | + * \param self The 'this pointer' of the object. |
| 313 | + */ |
| 314 | +-void clang_invoke(CXScope func, void* result, void** args, size_t n, |
| 315 | +- void* self); |
| 316 | ++CINDEX_LINKAGE void clang_invoke(CXScope func, void* result, void** args, |
| 317 | ++ size_t n, void* self); |
| 318 | + |
| 319 | + /** |
| 320 | + * Calls the destructor of object of type \c type. When withFree is true it |
| 321 | +@@ -354,7 +361,7 @@ void clang_invoke(CXScope func, void* result, void** args, size_t n, |
| 322 | + * |
| 323 | + * \param withFree Whether to call operator delete/free or not. |
| 324 | + */ |
| 325 | +-void clang_destruct(CXObject This, CXScope S, bool withFree); |
| 326 | ++CINDEX_LINKAGE void clang_destruct(CXObject This, CXScope S, bool withFree); |
| 327 | + |
| 328 | + /** |
| 329 | + * @} |
| 330 | +-- |
| 331 | +2.39.5 (Apple Git-154) |
| 332 | + |
0 commit comments