[PATCH] D44614: Demangle: Support GNU ABI tag attributes

Christopher James Halse Rogers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 20 20:45:05 PDT 2018


RAOF updated this revision to Diff 139248.
RAOF added a comment.

Added a llvm-cxxfilt test for the demanger changes.


Repository:
  rL LLVM

https://reviews.llvm.org/D44614

Files:
  lib/Demangle/ItaniumDemangle.cpp
  test/tools/llvm-cxxfilt/abitag.test


Index: test/tools/llvm-cxxfilt/abitag.test
===================================================================
--- /dev/null
+++ test/tools/llvm-cxxfilt/abitag.test
@@ -0,0 +1,6 @@
+RUN: llvm-cxxfilt _Z14returns_stringB5cxx11v _Z6globalB5cxx11 _Z6globalB12a_longer_tag | FileCheck %s
+
+CHECK: returns_string[abi:cxx11]()
+CHECK-NEXT: global[abi:cxx11]
+CHECK-NEXT: global[abi:a_longer_tag]
+
Index: lib/Demangle/ItaniumDemangle.cpp
===================================================================
--- lib/Demangle/ItaniumDemangle.cpp
+++ lib/Demangle/ItaniumDemangle.cpp
@@ -2688,9 +2688,34 @@
   return first;
 }
 
+// <abi-tags>  ::= <abi-tag> [<abi-tag>]
+// <abi-tag>   ::= B <source-name>
+
+template <class C>
+static const char *parse_abitags(const char *first, const char *last,
+                                 C &db) {
+  const char *t;
+  while (last != first && first[0] == 'B') {
+    auto entry = db.names.back().move_full();
+    db.names.pop_back();
+
+    t = parse_source_name(first + 1, last, db);
+    if (t != first + 1) {
+      db.names.back() = entry + "[abi:" + db.names.back().move_full() + "]";
+      first = t;
+    } else {
+      // Should never get here for a correctly-mangled name, but if we do,
+      // leave as consistent a state as possible.
+      db.names.push_back(std::move(entry));
+      return first;
+    }
+  }
+  return first;
+}
+
 // <unqualified-name> ::= <operator-name>
 //                    ::= <ctor-dtor-name>
-//                    ::= <source-name>
+//                    ::= <source-name> [<abi-tags>]
 //                    ::= <unnamed-type-name>
 
 template <class C>
@@ -2720,8 +2745,10 @@
     case '8':
     case '9':
       t = parse_source_name(first, last, db);
-      if (t != first)
+      if (t != first) {
+        t = parse_abitags(t, last, db);
         first = t;
+      }
       break;
     default:
       t = parse_operator_name(first, last, db);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44614.139248.patch
Type: text/x-patch
Size: 1932 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180321/df489a72/attachment-0001.bin>


More information about the llvm-commits mailing list