[llvm-commits] [compiler-rt] r170423 - in /compiler-rt/trunk/lib/ubsan: lit_tests/TypeCheck/vptr.cpp ubsan_diag.cc ubsan_diag.h ubsan_handlers_cxx.cc ubsan_type_hash.cc ubsan_type_hash.h
Richard Smith
richard at metafoo.co.uk
Tue Dec 18 18:08:31 PST 2012
On Tue, Dec 18, 2012 at 2:31 AM, Alexey Samsonov <samsonov at google.com> wrote:
> On Tue, Dec 18, 2012 at 1:30 PM, Richard Smith <richard-llvm at metafoo.co.uk>
> wrote:
>>
>> Author: rsmith
>> Date: Tue Dec 18 03:30:21 2012
>> New Revision: 170423
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=170423&view=rev
>> Log:
>> ubsan: Demangle class names, and be more informative when a
>> reinterpret_cast
>> has got us to the wrong offset within an object.
>>
>> Modified:
>> compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp
>> compiler-rt/trunk/lib/ubsan/ubsan_diag.cc
>> compiler-rt/trunk/lib/ubsan/ubsan_diag.h
>> compiler-rt/trunk/lib/ubsan/ubsan_handlers_cxx.cc
>> compiler-rt/trunk/lib/ubsan/ubsan_type_hash.cc
>> compiler-rt/trunk/lib/ubsan/ubsan_type_hash.h
>>
>> Modified: compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp?rev=170423&r1=170422&r2=170423&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp (original)
>> +++ compiler-rt/trunk/lib/ubsan/lit_tests/TypeCheck/vptr.cpp Tue Dec 18
>> 03:30:21 2012
>> @@ -75,7 +75,7 @@
>>
>> case 'm':
>> // CHECK-MEMBER: vptr.cpp:[[@LINE+5]]:15: runtime error: member
>> access within address [[PTR:0x[0-9a-f]*]] which does not point to an object
>> of type 'T'
>> - // CHECK-MEMBER-NEXT: [[PTR]]: note: object is of type
>> [[DYN_TYPE:1S|1U]]
>> + // CHECK-MEMBER-NEXT: [[PTR]]: note: object is of type
>> [[DYN_TYPE:'S'|'U']]
>> // CHECK-MEMBER-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }}
>> // CHECK-MEMBER-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)?
>> *$}}
>> // CHECK-MEMBER-NEXT: {{^ vptr for}} [[DYN_TYPE]]
>> @@ -89,7 +89,7 @@
>>
>> case 'f':
>> // CHECK-MEMFUN: vptr.cpp:[[@LINE+5]]:12: runtime error: member call
>> on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'T'
>> - // CHECK-MEMFUN-NEXT: [[PTR]]: note: object is of type
>> [[DYN_TYPE:1S|1U]]
>> + // CHECK-MEMFUN-NEXT: [[PTR]]: note: object is of type
>> [[DYN_TYPE:'S'|'U']]
>> // CHECK-MEMFUN-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. }}
>> // CHECK-MEMFUN-NEXT: {{^ \^~~~~~~~~~~(~~~~~~~~~~~~)?
>> *$}}
>> // CHECK-MEMFUN-NEXT: {{^ vptr for}} [[DYN_TYPE]]
>> @@ -97,10 +97,10 @@
>>
>> case 'o':
>> // CHECK-OFFSET: vptr.cpp:[[@LINE+5]]:12: runtime error: member call
>> on address [[PTR:0x[0-9a-f]*]] which does not point to an object of type 'U'
>> - // CHECK-OFFSET-NEXT: 0x{{[0-9a-f]*}}: note: object is base class
>> subobject at offset {{8|16}} within object of type [[DYN_TYPE:1U]]
>> + // CHECK-OFFSET-NEXT: 0x{{[0-9a-f]*}}: note: object is base class
>> subobject at offset {{8|16}} within object of type [[DYN_TYPE:'U']]
>> // CHECK-OFFSET-NEXT: {{^ .. .. .. .. .. .. .. .. .. .. .. .. .. ..
>> .. .. .. .. .. .. .. .. .. .. .. .. .. .. }}
>> // CHECK-OFFSET-NEXT: {{^ \^ (
>> ~~~~~~~~~~~~)~~~~~~~~~~~ *$}}
>> - // CHECK-OFFSET-NEXT: {{^ (
>> )?vptr for}} [[DYN_TYPE]]
>> + // CHECK-OFFSET-NEXT: {{^ (
>> )?vptr for}} 'T' base class of [[DYN_TYPE]]
>> return reinterpret_cast<U*>(p)->v() - 2;
>> }
>> }
>>
>> Modified: compiler-rt/trunk/lib/ubsan/ubsan_diag.cc
>> URL:
>> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/ubsan/ubsan_diag.cc?rev=170423&r1=170422&r2=170423&view=diff
>>
>> ==============================================================================
>> --- compiler-rt/trunk/lib/ubsan/ubsan_diag.cc (original)
>> +++ compiler-rt/trunk/lib/ubsan/ubsan_diag.cc Tue Dec 18 03:30:21 2012
>> @@ -54,7 +54,7 @@
>> return *this;
>> }
>>
>> -/// Hexadecimal printing for numbers too large for fprintf to handle
>> directly.
>> +/// Hexadecimal printing for numbers too large for Printf to handle
>> directly.
>> static void PrintHex(UIntMax Val) {
>> #if HAVE_INT128_T
>> Printf("0x%08x%08x%08x%08x",
>> @@ -93,6 +93,15 @@
>> }
>> }
>>
>> +// C++ demangling function, as required by Itanium C++ ABI. This is weak,
>> +// because we do not require a C++ ABI library to be linked to a program
>> +// using UBSan; if it's not present, we'll just print the string mangled.
>> +namespace __cxxabiv1 {
>> + extern "C" char *__cxa_demangle(const char *mangled, char *buffer,
>> + size_t *length, int *status)
>> + __attribute__((weak));
>> +}
>
>
> Do you think we should hoist (optional) demangling to sanitizer_common
> and make it more portable (e.g. declare __cxa_demangle on Linux only,
> use WEAK macro instead of attribute etc.)?
Sounds good to me, patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sanitizer-common-demangle.diff
Type: application/octet-stream
Size: 5051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20121218/895b2e3e/attachment.obj>
More information about the llvm-commits
mailing list