[PATCH] D44614: Demangle: Support GNU ABI tag attributes
Christopher James Halse Rogers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 18 17:21:47 PDT 2018
RAOF created this revision.
RAOF added a reviewer: lattner.
Herald added a subscriber: llvm-commits.
The demangler currently bails when encountering a mangled abi_tag.
Fixes: https://bugs.llvm.org/show_bug.cgi?id=36777
Relevant spec: http://itanium-cxx-abi.github.io/cxx-abi/abi.html#mangle.abi-tags
Repository:
rL LLVM
https://reviews.llvm.org/D44614
Files:
lib/Demangle/ItaniumDemangle.cpp
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.138871.patch
Type: text/x-patch
Size: 1539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180319/a6a5c12a/attachment.bin>
More information about the llvm-commits
mailing list