[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
Tue Sep 6 19:34:52 PDT 2022


kastiglione updated this revision to Diff 458347.
kastiglione added a comment.

Expect inline namespace to be __[[:alnum:]]+::


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D133259/new/

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
@@ -67,11 +67,23 @@
   return m_num_elements;
 }
 
+static void consumeNamespace(llvm::StringRef &name) {
+  // Delete past an inline namespace, if any: __[a-zA-Z0-9_]+::
+  auto scratch = name;
+  if (scratch.consume_front("__") && std::isalnum(scratch[0])) {
+    scratch = scratch.drop_while([](char c) { return std::isalnum(c); });
+    if (scratch.consume_front("::")) {
+      // Successfully consumed a namespace.
+      name = scratch;
+    }
+  }
+}
+
 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::`.
+  // The type name may be prefixed with `std::__<inline-namespace>::`.
   if (name.consume_front("std::"))
-    name.consume_front("__1::");
+    consumeNamespace(name);
   return name.consume_front(type) && name.startswith("<");
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133259.458347.patch
Type: text/x-patch
Size: 1169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220907/49eb7227/attachment.bin>


More information about the lldb-commits mailing list