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("<");
 }
 


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("<");
 }
 
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to