[Lldb-commits] [PATCH] D133259: [lldb] Don't assume name of libc++ inline namespace in LibCxxUnorderedMap

Dave Lee via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sat Sep 3 11:36:25 PDT 2022


kastiglione created this revision.
kastiglione added a reviewer: rsmith.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Follow up to D117383 <https://reviews.llvm.org/D117383>, fixing the assumption that libc++ always uses `__1` as
its inline namespace name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133259

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
===================================================================
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp
@@ -69,9 +69,17 @@
 
 static bool isStdTemplate(ConstString type_name, llvm::StringRef type) {
   llvm::StringRef name = type_name.GetStringRef();
-  // The type name may or may not be prefixed with `std::` or `std::__1::`.
-  if (name.consume_front("std::"))
-    name.consume_front("__1::");
+  // The type name may be prefixed with `std::<inline-namespace>::`.
+  if (name.consume_front("std::")) {
+    // Delete past the inline namespace: [a-zA-Z0-9_]+::
+    auto ident_end =
+        name.find_if_not([](char c) { return std::isalnum(c) || c == '_'; });
+    if (ident_end != llvm::StringRef::npos && ident_end >= 1) {
+      auto temp = name.drop_front(ident_end);
+      if (temp.consume_front("::"))
+        name = temp;
+    }
+  }
   return name.consume_front(type) && name.startswith("<");
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133259.457810.patch
Type: text/x-patch
Size: 1078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220903/ca31122e/attachment.bin>


More information about the lldb-commits mailing list