[compiler-rt] 9f73a9e - [NFC][sanitizer] Clarify nullability of Symbolizer::Demangle result

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 9 13:59:36 PDT 2023


Author: Vitaly Buka
Date: 2023-09-09T13:59:01-07:00
New Revision: 9f73a9ef6e4da73f22e1ca81b22ef53851d4d19a

URL: https://github.com/llvm/llvm-project/commit/9f73a9ef6e4da73f22e1ca81b22ef53851d4d19a
DIFF: https://github.com/llvm/llvm-project/commit/9f73a9ef6e4da73f22e1ca81b22ef53851d4d19a.diff

LOG: [NFC][sanitizer] Clarify nullability of Symbolizer::Demangle result

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
    compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
index df24aaca3abf645..d0b0f827200e950 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
@@ -136,7 +136,7 @@ class Symbolizer final {
 
   // Release internal caches (if any).
   void Flush();
-  // Attempts to demangle the provided C++ mangled name.
+  // Attempts to demangle the provided C++ mangled name. Never returns nullptr.
   const char *Demangle(const char *name);
 
   // Allow user to install hooks that would be called before/after Symbolizer

diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
index a6f82ced2036731..d910aef3f741627 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_libcdep.cpp
@@ -159,13 +159,16 @@ void Symbolizer::Flush() {
 }
 
 const char *Symbolizer::Demangle(const char *name) {
+  CHECK(name);
   Lock l(&mu_);
   for (auto &tool : tools_) {
     SymbolizerScope sym_scope(this);
     if (const char *demangled = tool.Demangle(name))
       return demangled;
   }
-  return PlatformDemangle(name);
+  if (const char *demangled = PlatformDemangle(name))
+    return demangled;
+  return name;
 }
 
 bool Symbolizer::FindModuleNameAndOffsetForAddress(uptr address,


        


More information about the llvm-commits mailing list