[PATCH] D19668: [ubsan] Minimize size of data for type_mismatch
Filipe Cabecinhas via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 28 09:41:34 PDT 2016
filcab created this revision.
filcab added reviewers: kcc, samsonov, rsmith.
filcab added a subscriber: llvm-commits.
Herald added a subscriber: kubabrecka.
This is the compiler-rt side of D19667.
http://reviews.llvm.org/D19668
Files:
lib/ubsan/ubsan_handlers.cc
lib/ubsan/ubsan_handlers.h
Index: lib/ubsan/ubsan_handlers.h
===================================================================
--- lib/ubsan/ubsan_handlers.h
+++ lib/ubsan/ubsan_handlers.h
@@ -20,7 +20,7 @@
struct TypeMismatchData {
SourceLocation Loc;
const TypeDescriptor &Type;
- uptr Alignment;
+ unsigned char Alignment;
unsigned char TypeCheckKind;
};
Index: lib/ubsan/ubsan_handlers.cc
===================================================================
--- lib/ubsan/ubsan_handlers.cc
+++ lib/ubsan/ubsan_handlers.cc
@@ -46,9 +46,10 @@
Location Loc = Data->Loc.acquire();
ErrorType ET;
+ uptr Alignment = (uptr)1 << Data->Alignment;
if (!Pointer)
ET = ErrorType::NullPointerUse;
- else if (Data->Alignment && (Pointer & (Data->Alignment - 1)))
+ else if (Alignment && (Pointer & (Alignment - 1)))
ET = ErrorType::MisalignedPointerUse;
else
ET = ErrorType::InsufficientObjectSize;
@@ -75,7 +76,7 @@
Diag(Loc, DL_Error, "%0 misaligned address %1 for type %3, "
"which requires %2 byte alignment")
<< TypeCheckKinds[Data->TypeCheckKind] << (void *)Pointer
- << Data->Alignment << Data->Type;
+ << Alignment << Data->Type;
break;
case ErrorType::InsufficientObjectSize:
Diag(Loc, DL_Error, "%0 address %1 with insufficient space "
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19668.55429.patch
Type: text/x-patch
Size: 1323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160428/00baaf2e/attachment.bin>
More information about the llvm-commits
mailing list