[PATCH] D10949: A step towards getting libclang tests working on Windows
Yaron Keren
yaron.keren at gmail.com
Sun Jul 5 13:21:26 PDT 2015
yaron.keren created this revision.
yaron.keren added subscribers: cfe-commits, rnk, chapuni.
One of the problems libclang tests has running under Windows is memory malloced in libclang.dll being but freed in the test executable, possibly by a different memory manager. This patch exposes a new export function, clang_free(), used to free this malloced memory with the same libclang.dll memory manager that malloced the memory.
Repository:
rL LLVM
http://reviews.llvm.org/D10949
Files:
tools/clang/include/clang-c/BuildSystem.h
tools/clang/tools/libclang/BuildSystem.cpp
tools/clang/tools/libclang/libclang.exports
tools/clang/unittests/libclang/LibclangTest.cpp
Index: tools/clang/tools/libclang/libclang.exports
===================================================================
--- tools/clang/tools/libclang/libclang.exports
+++ tools/clang/tools/libclang/libclang.exports
@@ -132,6 +132,7 @@
clang_findReferencesInFile
clang_findReferencesInFileWithBlock
clang_formatDiagnostic
+clang_free
clang_getArgType
clang_getArrayElementType
clang_getArraySize
Index: tools/clang/unittests/libclang/LibclangTest.cpp
===================================================================
--- tools/clang/unittests/libclang/LibclangTest.cpp
+++ tools/clang/unittests/libclang/LibclangTest.cpp
@@ -63,7 +63,7 @@
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 @@
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);
}
Index: tools/clang/tools/libclang/BuildSystem.cpp
===================================================================
--- tools/clang/tools/libclang/BuildSystem.cpp
+++ tools/clang/tools/libclang/BuildSystem.cpp
@@ -84,6 +84,10 @@
return CXError_Success;
}
+void clang_free(char *out_buffer_ptr) {
+ free(out_buffer_ptr);
+}
+
void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay VFO) {
delete unwrap(VFO);
}
Index: tools/clang/include/clang-c/BuildSystem.h
===================================================================
--- tools/clang/include/clang-c/BuildSystem.h
+++ tools/clang/include/clang-c/BuildSystem.h
@@ -73,7 +73,7 @@
*
* \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,15 @@
unsigned *out_buffer_size);
/**
+ * \brief free the char buffer allocated by \c CXVirtualFileOverlay()
+ * or \c clang_ModuleMapDescriptor_writeToBuffer().
+ *
+ * \param out_buffer_ptr pointer received from
+ * \c clang_VirtualFileOverlay_writeToBuffer().
+ */
+CINDEX_LINKAGE void clang_free(char *out_buffer_ptr);
+
+/**
* \brief Dispose a \c CXVirtualFileOverlay object.
*/
CINDEX_LINKAGE void clang_VirtualFileOverlay_dispose(CXVirtualFileOverlay);
@@ -122,7 +131,7 @@
*
* \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.
*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10949.29056.patch
Type: text/x-patch
Size: 3087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150705/f0303a38/attachment.bin>
More information about the cfe-commits
mailing list