<div style="font-family: arial, helvetica, sans-serif; font-size: 10pt">LGTM<div><br></div><div><div>+#if defined(__APPLE__) || defined(__linux__)</div><div>+</div><div>+#include "sanitizer_symbolizer.h"</div><div>
+</div><div>+#include <stdlib.h></div><div>Do you really need this header?</div><br><div class="gmail_quote">On Wed, Dec 19, 2012 at 6:08 AM, Richard Smith <span dir="ltr"><<a href="mailto:richard@metafoo.co.uk" target="_blank">richard@metafoo.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, Dec 18, 2012 at 2:31 AM, Alexey Samsonov <<a href="mailto:samsonov@google.com">samsonov@google.com</a>> wrote:<br>
> On Tue, Dec 18, 2012 at 1:30 PM, Richard Smith <<a href="mailto:richard-llvm@metafoo.co.uk">richard-llvm@metafoo.co.uk</a>><br>
> wrote:<br>
>><br>
>> Author: rsmith<br>
>> Date: Tue Dec 18 03:30:21 2012<br>
>> New Revision: 170423<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=170423&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=170423&view=rev</a><br>
>> Log:<br>
>> ubsan: Demangle class names, and be more informative when a<br>
>> reinterpret_cast<br>
>> has got us to the wrong offset within an object.<br>
>><br>
>> Modified:<br>
>> compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp<br>
>> compiler-rt/trunk/lib/ubsan/ubsan_diag.cc<br>
>> compiler-rt/trunk/lib/ubsan/ubsan_diag.h<br>
>> compiler-rt/trunk/lib/ubsan/ubsan_handlers_cxx.cc<br>
>> compiler-rt/trunk/lib/ubsan/ubsan_type_hash.cc<br>
>> compiler-rt/trunk/lib/ubsan/ubsan_type_hash.h<br>
>><br>
>> Modified: compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp?rev=170423&r1=170422&r2=170423&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp?rev=170423&r1=170422&r2=170423&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp (original)<br>
>> +++ compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp Tue Dec 18<br>
>> 03:30:21 2012<br>
>> @@ -75,7 +75,7 @@<br>
>><br>
>> case 'm':<br>
>> // CHECK-MEMBER: vptr.cpp:[[@LINE+5]]:15: runtime error: member<br>
>> access within address [[PTR:0x[0-9a-f]*]] which does not point to an object<br>
>> of type 'T'<br>
>> - // CHECK-MEMBER-NEXT: [[PTR]]: note: object is of type<br>
>> [[DYN_TYPE:1S|1U]]<br>
>> + // CHECK-MEMBER-NEXT: [[PTR]]: note: object is of type<br>
>> [[DYN_TYPE:'S'|'U']]<br>
>> // CHECK-MEMBER-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }}<br>
>> // CHECK-MEMBER-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)?<br>
>> *$}}<br>
>> // CHECK-MEMBER-NEXT: {{^ vptr for}} [[DYN_TYPE]]<br>
>> @@ -89,7 +89,7 @@<br>
>><br>
>> case 'f':<br>
>> // CHECK-MEMFUN: vptr.cpp:[[@LINE+5]]:12: runtime error: member call<br>
>> on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'<br>
>> - // CHECK-MEMFUN-NEXT: [[PTR]]: note: object is of type<br>
>> [[DYN_TYPE:1S|1U]]<br>
>> + // CHECK-MEMFUN-NEXT: [[PTR]]: note: object is of type<br>
>> [[DYN_TYPE:'S'|'U']]<br>
>> // CHECK-MEMFUN-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }}<br>
>> // CHECK-MEMFUN-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)?<br>
>> *$}}<br>
>> // CHECK-MEMFUN-NEXT: {{^ vptr for}} [[DYN_TYPE]]<br>
>> @@ -97,10 +97,10 @@<br>
>><br>
>> case 'o':<br>
>> // CHECK-OFFSET: vptr.cpp:[[@LINE+5]]:12: runtime error: member call<br>
>> on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'U'<br>
>> - // CHECK-OFFSET-NEXT: 0x{{[0-9a-f]*}}: note: object is base class<br>
>> subobject at offset {{8|16}} within object of type [[DYN_TYPE:1U]]<br>
>> + // CHECK-OFFSET-NEXT: 0x{{[0-9a-f]*}}: note: object is base class<br>
>> subobject at offset {{8|16}} within object of type [[DYN_TYPE:'U']]<br>
>> // CHECK-OFFSET-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. .. ..<br>
>> .. .. .. .. .. .. .. .. .. .. .. .. .. .. }}<br>
>> // CHECK-OFFSET-NEXT: {{^ \^ (<br>
>> ~~~~~~~~~~~~)~~~~~~~~~~~ *$}}<br>
>> - // CHECK-OFFSET-NEXT: {{^ (<br>
>> )?vptr for}} [[DYN_TYPE]]<br>
>> + // CHECK-OFFSET-NEXT: {{^ (<br>
>> )?vptr for}} 'T' base class of [[DYN_TYPE]]<br>
>> return reinterpret_cast<U*>(p)->v() - 2;<br>
>> }<br>
>> }<br>
>><br>
>> Modified: compiler-rt/trunk/lib/ubsan/ubsan_diag.cc<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_diag.cc?rev=170423&r1=170422&r2=170423&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_diag.cc?rev=170423&r1=170422&r2=170423&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- compiler-rt/trunk/lib/ubsan/ubsan_diag.cc (original)<br>
>> +++ compiler-rt/trunk/lib/ubsan/ubsan_diag.cc Tue Dec 18 03:30:21 2012<br>
>> @@ -54,7 +54,7 @@<br>
>> return *this;<br>
>> }<br>
>><br>
>> -/// Hexadecimal printing for numbers too large for fprintf to handle<br>
>> directly.<br>
>> +/// Hexadecimal printing for numbers too large for Printf to handle<br>
>> directly.<br>
>> static void PrintHex(UIntMax Val) {<br>
>> #if HAVE_INT128_T<br>
>> Printf("0x%08x%08x%08x%08x",<br>
>> @@ -93,6 +93,15 @@<br>
>> }<br>
>> }<br>
>><br>
>> +// C++ demangling function, as required by Itanium C++ ABI. This is weak,<br>
>> +// because we do not require a C++ ABI library to be linked to a program<br>
>> +// using UBSan; if it's not present, we'll just print the string mangled.<br>
>> +namespace __cxxabiv1 {<br>
>> + extern "C" char *__cxa_demangle(const char *mangled, char *buffer,<br>
>> + size_t *length, int *status)<br>
>> + __attribute__((weak));<br>
>> +}<br>
><br>
><br>
> Do you think we should hoist (optional) demangling to sanitizer_common<br>
> and make it more portable (e.g. declare __cxa_demangle on Linux only,<br>
> use WEAK macro instead of attribute etc.)?<br>
<br>
</div></div>Sounds good to me, patch attached.<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div><br>
</div></div>