diff options
-rw-r--r-- | clang/include/clang-c/BuildSystem.h | 12 | ||||
-rw-r--r-- | clang/tools/libclang/BuildSystem.cpp | 4 | ||||
-rw-r--r-- | clang/tools/libclang/libclang.exports | 1 | ||||
-rw-r--r-- | clang/unittests/libclang/LibclangTest.cpp | 4 |
4 files changed, 17 insertions, 4 deletions
diff --git a/clang/include/clang-c/BuildSystem.h b/clang/include/clang-c/BuildSystem.h index 7aa0191..8d323a4 100644 --- a/clang/include/clang-c/BuildSystem.h +++ b/clang/include/clang-c/BuildSystem.h @@ -73,7 +73,7 @@ clang_VirtualFileOverlay_setCaseSensitivity(CXVirtualFileOverlay, * * \param options is reserved, always pass 0. * \param out_buffer_ptr pointer to receive the buffer pointer, which should be - * disposed using \c free(). + * disposed using \c clang_free(). * \param out_buffer_size pointer to receive the buffer size. * \returns 0 for success, non-zero to indicate an error. */ @@ -83,6 +83,14 @@ clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay, unsigned options, unsigned *out_buffer_size); /** + * \brief free memory allocated by libclang, such as the buffer returned by + * \c CXVirtualFileOverlay() or \c clang_ModuleMapDescriptor_writeToBuffer(). + * + * \param buffer memory pointer to free. + */ +CINDEX_LINKAGE void clang_free(void *buffer); + +/** * \brief Dispose a \c CXVirtualFileOverlay object. */ CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay); @@ -122,7 +130,7 @@ clang_ModuleMapDescriptor_setUmbrellaHeader(CXModuleMapDescriptor, * * \param options is reserved, always pass 0. * \param out_buffer_ptr pointer to receive the buffer pointer, which should be - * disposed using \c free(). + * disposed using \c clang_free(). * \param out_buffer_size pointer to receive the buffer size. * \returns 0 for success, non-zero to indicate an error. */ diff --git a/clang/tools/libclang/BuildSystem.cpp b/clang/tools/libclang/BuildSystem.cpp index e9423c3..fe3db75 100644 --- a/clang/tools/libclang/BuildSystem.cpp +++ b/clang/tools/libclang/BuildSystem.cpp @@ -84,6 +84,10 @@ clang_VirtualFileOverlay_writeToBuffer(CXVirtualFileOverlay VFO, unsigned, return CXError_Success; } +void clang_free(void *buffer) { + free(buffer); +} + void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay VFO) { delete unwrap(VFO); } diff --git a/clang/tools/libclang/libclang.exports b/clang/tools/libclang/libclang.exports index f78f998..f6a7175 100644 --- a/clang/tools/libclang/libclang.exports +++ b/clang/tools/libclang/libclang.exports @@ -132,6 +132,7 @@ clang_findIncludesInFileWithBlock clang_findReferencesInFile clang_findReferencesInFileWithBlock clang_formatDiagnostic +clang_free clang_getArgType clang_getArrayElementType clang_getArraySize diff --git a/clang/unittests/libclang/LibclangTest.cpp b/clang/unittests/libclang/LibclangTest.cpp index e827ebc..becebf0 100644 --- a/clang/unittests/libclang/LibclangTest.cpp +++ b/clang/unittests/libclang/LibclangTest.cpp @@ -63,7 +63,7 @@ struct TestVFO { clang_VirtualFileOverlay_writeToBuffer(VFO, 0, &BufPtr, &BufSize); std::string BufStr(BufPtr, BufSize); EXPECT_STREQ(Contents, BufStr.c_str()); - free(BufPtr); + clang_free(BufPtr); } clang_VirtualFileOverlay_dispose(VFO); } @@ -345,7 +345,7 @@ TEST(libclang, ModuleMapDescriptor) { clang_ModuleMapDescriptor_writeToBuffer(MMD, 0, &BufPtr, &BufSize); std::string BufStr(BufPtr, BufSize); EXPECT_STREQ(Contents, BufStr.c_str()); - free(BufPtr); + clang_free(BufPtr); clang_ModuleMapDescriptor_dispose(MMD); } |