[compiler-rt] r361304 - [asan] Replace assignments with internal_memcpy ErrorDescription

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Tue May 21 13:23:10 PDT 2019


Author: vitalybuka
Date: Tue May 21 13:23:10 2019
New Revision: 361304

URL: http://llvm.org/viewvc/llvm-project?rev=361304&view=rev
Log:
[asan] Replace assignments with internal_memcpy ErrorDescription

For consistency with nearby code and to avoid interceptors during reports.

Modified:
    compiler-rt/trunk/lib/asan/asan_errors.h
    compiler-rt/trunk/lib/asan/asan_report.cc

Modified: compiler-rt/trunk/lib/asan/asan_errors.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_errors.h?rev=361304&r1=361303&r2=361304&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_errors.h (original)
+++ compiler-rt/trunk/lib/asan/asan_errors.h Tue May 21 13:23:10 2019
@@ -404,8 +404,10 @@ struct ErrorGeneric : ErrorBase {
 
 #define ASAN_DEFINE_ERROR_KIND(name) kErrorKind##name,
 #define ASAN_ERROR_DESCRIPTION_MEMBER(name) Error##name name;
-#define ASAN_ERROR_DESCRIPTION_CONSTRUCTOR(name) \
-  ErrorDescription(Error##name const &e) : kind(kErrorKind##name), name(e) {}
+#define ASAN_ERROR_DESCRIPTION_CONSTRUCTOR(name)                               \
+  ErrorDescription(Error##name const &e) : kind(kErrorKind##name) {            \
+    internal_memcpy(&name, &e, sizeof(name));                                  \
+  }
 #define ASAN_ERROR_DESCRIPTION_PRINT(name) \
   case kErrorKind##name:                   \
     return name.Print();

Modified: compiler-rt/trunk/lib/asan/asan_report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/asan_report.cc?rev=361304&r1=361303&r2=361304&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/asan_report.cc (original)
+++ compiler-rt/trunk/lib/asan/asan_report.cc Tue May 21 13:23:10 2019
@@ -190,7 +190,7 @@ class ScopedInErrorReport {
   void ReportError(const ErrorDescription &description) {
     // Can only report one error per ScopedInErrorReport.
     CHECK_EQ(current_error_.kind, kErrorKindInvalid);
-    current_error_ = description;
+    internal_memcpy(&current_error_, &description, sizeof(current_error_));
   }
 
   static ErrorDescription &CurrentError() {




More information about the llvm-commits mailing list