Hi Stefanus,
Thanks for your response?
> 0. why in a C++ code, the C free function is used?
Because it's calling into a C API (cxxabi). demangled_name comes from a
call to abi::__cxa_demangle(), which presumably calls malloc to allocate
its return value.
OK. Got that.
> 1. Why when using it, the #include <cstdlib> is nowhere in the source?
Mangled.cpp:25 is:
#include <stdlib.h>
No. This is incorrect. With lldb 3.3 official release tar ball, the #include
that you mentioned is not there.
zackp@nb1:~/Downloads/clang3.3/lldb-3.3.src/source/Core$ grep stdlib.h
Mangled.cpp
zackp@nb1:~/Downloads/clang3.3/lldb-3.3.src/source/Core$
I patched it as follows:
11 #if defined(__APPLE__)
12 #define USE_BUILTIN_LIBCXXABI_DEMANGLER 1
13 #endif
14
15 #if defined(USE_BUILTIN_LIBCXXABI_DEMANGLER)
16 #include "lldb/Core/cxa_demangle.h"
17 #else
18 // FreeBSD9-STABLE requires this to know about size_t in cxxabi.h
19 #include <cstddef>
20 #include <cxxabi.h>
21 #endif
22
23 #include <cstdlib>
24 #include "llvm/ADT/DenseMap.h"
My personal style is that if I code in C++, I use as much as possible C++
coding convention.
Regards,
-- Zack[...]
_______________________________________________
lldb-dev mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-dev