[compiler-rt] r269302 - [sanitizer] Allow nullptr in Swift demangler

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 08:54:33 PDT 2016


Author: kuba.brecka
Date: Thu May 12 10:54:33 2016
New Revision: 269302

URL: http://llvm.org/viewvc/llvm-project?rev=269302&view=rev
Log:
[sanitizer] Allow nullptr in Swift demangler

The introduction of the Swift demangler now causes an assertion failure when we
try to demangle nullptr, but we used to allow that (and return nullptr back).
This situation is rare, but it can still happen.  Let's allow nullptr.


Modified:
    compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc?rev=269302&r1=269301&r2=269302&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc Thu May 12 10:54:33 2016
@@ -81,6 +81,8 @@ static void InitializeSwiftDemangler() {
 // Attempts to demangle a Swift name. The demangler will return nullptr if a
 // non-Swift name is passed in.
 const char *DemangleSwift(const char *name) {
+  if (!name) return nullptr;
+
   // Check if we are dealing with a Swift mangled name first.
   if (name[0] != '_' || name[1] != 'T') {
     return nullptr;
@@ -93,7 +95,7 @@ const char *DemangleSwift(const char *na
 }
 
 const char *DemangleSwiftAndCXX(const char *name) {
-  CHECK(name);
+  if (!name) return nullptr;
   if (const char *swift_demangled_name = DemangleSwift(name))
     return swift_demangled_name;
   return DemangleCXXABI(name);




More information about the llvm-commits mailing list