[PATCH] D24455: [asan] Move tid to ErrorBase

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 12 06:46:37 PDT 2016


filcab created this revision.
filcab added reviewers: vitalybuka, kcc, eugenis.
filcab added a subscriber: llvm-commits.
Herald added a subscriber: kubabrecka.

As mentioned in D24394, I'm moving tid to ErrorBase, since basically all errors need it.

https://reviews.llvm.org/D24455

Files:
  lib/asan/asan_errors.h

Index: lib/asan/asan_errors.h
===================================================================
--- lib/asan/asan_errors.h
+++ lib/asan/asan_errors.h
@@ -21,19 +21,21 @@
 namespace __asan {
 
 struct ErrorBase {
+  ErrorBase() = default;
+  explicit ErrorBase(u32 tid_) : tid(tid_) {}
   ScarinessScoreBase scariness;
+  u32 tid;
 };
 
 struct ErrorStackOverflow : ErrorBase {
-  u32 tid;
   uptr addr, pc, bp, sp;
   // ErrorStackOverflow never owns the context.
   void *context;
   // VS2013 doesn't implement unrestricted unions, so we need a trivial default
   // constructor
   ErrorStackOverflow() = default;
-  ErrorStackOverflow(const SignalContext &sig, u32 tid_)
-      : tid(tid_),
+  ErrorStackOverflow(const SignalContext &sig, u32 tid)
+      : ErrorBase(tid),
         addr(sig.addr),
         pc(sig.pc),
         bp(sig.bp),
@@ -46,7 +48,6 @@
 };
 
 struct ErrorDeadlySignal : ErrorBase {
-  u32 tid;
   uptr addr, pc, bp, sp;
   int signo;
   SignalContext::WriteFlag write_flag;
@@ -56,8 +57,8 @@
   // VS2013 doesn't implement unrestricted unions, so we need a trivial default
   // constructor
   ErrorDeadlySignal() = default;
-  ErrorDeadlySignal(int signo_, const SignalContext &sig, u32 tid_)
-      : tid(tid_),
+  ErrorDeadlySignal(int signo_, const SignalContext &sig, u32 tid)
+      : ErrorBase(tid),
         addr(sig.addr),
         pc(sig.pc),
         bp(sig.bp),
@@ -87,15 +88,14 @@
 };
 
 struct ErrorDoubleFree : ErrorBase {
-  u32 tid;
   HeapAddressDescription addr_description;
   // ErrorDoubleFree doesn't own the stack trace.
   BufferedStackTrace *second_free_stack;
   // VS2013 doesn't implement unrestricted unions, so we need a trivial default
   // constructor
   ErrorDoubleFree() = default;
-  ErrorDoubleFree(uptr addr, u32 tid_, BufferedStackTrace *stack)
-      : tid(tid_), second_free_stack(stack) {
+  ErrorDoubleFree(uptr addr, u32 tid, BufferedStackTrace *stack)
+      : ErrorBase(tid), second_free_stack(stack) {
     CHECK_GT(second_free_stack->size, 0);
     GetHeapAddressInformation(addr, 1, &addr_description);
     scariness.Clear();
@@ -105,17 +105,16 @@
 };
 
 struct ErrorNewDeleteSizeMismatch : ErrorBase {
-  u32 tid;
   HeapAddressDescription addr_description;
   uptr delete_size;
   // ErrorNewDeleteSizeMismatch doesn't own the stack trace.
   BufferedStackTrace *free_stack;
   // VS2013 doesn't implement unrestricted unions, so we need a trivial default
   // constructor
   ErrorNewDeleteSizeMismatch() = default;
-  ErrorNewDeleteSizeMismatch(uptr addr, u32 tid_, uptr delete_size_,
+  ErrorNewDeleteSizeMismatch(uptr addr, u32 tid, uptr delete_size_,
                              BufferedStackTrace *stack)
-      : tid(tid_), delete_size(delete_size_), free_stack(stack) {
+      : ErrorBase(tid), delete_size(delete_size_), free_stack(stack) {
     GetHeapAddressInformation(addr, 1, &addr_description);
     scariness.Clear();
     scariness.Scare(10, "new-delete-type-mismatch");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24455.71004.patch
Type: text/x-patch
Size: 2970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160912/658646c7/attachment.bin>


More information about the llvm-commits mailing list