[libcxx-commits] [libcxxabi] 876435c - * Fix demangling of optional template-args for vendor extended type qualifier.
Alex Orlov via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 23 23:21:50 PDT 2021
Author: Alex Orlov
Date: 2021-03-24T10:21:32+04:00
New Revision: 876435c487cf7635c641aef7860f5b71641a4431
URL: https://github.com/llvm/llvm-project/commit/876435c487cf7635c641aef7860f5b71641a4431
DIFF: https://github.com/llvm/llvm-project/commit/876435c487cf7635c641aef7860f5b71641a4431.diff
LOG: * Fix demangling of optional template-args for vendor extended type qualifier.
This fixes https://bugs.llvm.org/show_bug.cgi?id=48009 bug.
Reviewed By: erik.pilkington, krisb
Differential Revision: https://reviews.llvm.org/D98687
Added:
Modified:
libcxxabi/src/demangle/ItaniumDemangle.h
libcxxabi/test/test_demangle.pass.cpp
llvm/include/llvm/Demangle/ItaniumDemangle.h
llvm/unittests/Demangle/DemangleTest.cpp
Removed:
################################################################################
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index e5fca98f92717..202c959d40d20 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -280,17 +280,20 @@ class DotSuffix final : public Node {
class VendorExtQualType final : public Node {
const Node *Ty;
StringView Ext;
+ const Node *TA;
public:
- VendorExtQualType(const Node *Ty_, StringView Ext_)
- : Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_) {}
+ VendorExtQualType(const Node *Ty_, StringView Ext_, const Node *TA_)
+ : Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_), TA(TA_) {}
- template<typename Fn> void match(Fn F) const { F(Ty, Ext); }
+ template <typename Fn> void match(Fn F) const { F(Ty, Ext, TA); }
void printLeft(OutputStream &S) const override {
Ty->print(S);
S += " ";
S += Ext;
+ if (TA != nullptr)
+ TA->print(S);
}
};
@@ -3680,8 +3683,6 @@ Node *AbstractManglingParser<Derived, Alloc>::parseQualifiedType() {
if (Qual.empty())
return nullptr;
- // FIXME parse the optional <template-args> here!
-
// extension ::= U <objc-name> <objc-type> # objc-type<identifier>
if (Qual.startsWith("objcproto")) {
StringView ProtoSourceName = Qual.dropFront(std::strlen("objcproto"));
@@ -3699,10 +3700,17 @@ Node *AbstractManglingParser<Derived, Alloc>::parseQualifiedType() {
return make<ObjCProtoName>(Child, Proto);
}
+ Node *TA = nullptr;
+ if (look() == 'I') {
+ TA = getDerived().parseTemplateArgs();
+ if (TA == nullptr)
+ return nullptr;
+ }
+
Node *Child = getDerived().parseQualifiedType();
if (Child == nullptr)
return nullptr;
- return make<VendorExtQualType>(Child, Qual);
+ return make<VendorExtQualType>(Child, Qual, TA);
}
Qualifiers Quals = parseCVQualifiers();
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 1d7b10706e439..4f19dafd9e826 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -29843,6 +29843,10 @@ const char* cases[][2] =
{"_Z1fIL4Enumn1EEvv", "void f<(Enum)-1>()"},
{"_ZN1A1gIiEEDTcldtptfpT1b1fIT_EEEv", "decltype(this->b.f<int>()) A::g<int>()"},
+
+ // Optional template-args for vendor extended type qualifier.
+ // See https://bugs.llvm.org/show_bug.cgi?id=48009.
+ {"_Z3fooILi79EEbU7_ExtIntIXT_EEi", "bool foo<79>(int _ExtInt<79>)"},
};
const unsigned N = sizeof(cases) / sizeof(cases[0]);
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 112d5a489e56f..4e3af0cb26490 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -280,17 +280,20 @@ class DotSuffix final : public Node {
class VendorExtQualType final : public Node {
const Node *Ty;
StringView Ext;
+ const Node *TA;
public:
- VendorExtQualType(const Node *Ty_, StringView Ext_)
- : Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_) {}
+ VendorExtQualType(const Node *Ty_, StringView Ext_, const Node *TA_)
+ : Node(KVendorExtQualType), Ty(Ty_), Ext(Ext_), TA(TA_) {}
- template<typename Fn> void match(Fn F) const { F(Ty, Ext); }
+ template <typename Fn> void match(Fn F) const { F(Ty, Ext, TA); }
void printLeft(OutputStream &S) const override {
Ty->print(S);
S += " ";
S += Ext;
+ if (TA != nullptr)
+ TA->print(S);
}
};
@@ -3680,8 +3683,6 @@ Node *AbstractManglingParser<Derived, Alloc>::parseQualifiedType() {
if (Qual.empty())
return nullptr;
- // FIXME parse the optional <template-args> here!
-
// extension ::= U <objc-name> <objc-type> # objc-type<identifier>
if (Qual.startsWith("objcproto")) {
StringView ProtoSourceName = Qual.dropFront(std::strlen("objcproto"));
@@ -3699,10 +3700,17 @@ Node *AbstractManglingParser<Derived, Alloc>::parseQualifiedType() {
return make<ObjCProtoName>(Child, Proto);
}
+ Node *TA = nullptr;
+ if (look() == 'I') {
+ TA = getDerived().parseTemplateArgs();
+ if (TA == nullptr)
+ return nullptr;
+ }
+
Node *Child = getDerived().parseQualifiedType();
if (Child == nullptr)
return nullptr;
- return make<VendorExtQualType>(Child, Qual);
+ return make<VendorExtQualType>(Child, Qual, TA);
}
Qualifiers Quals = parseCVQualifiers();
diff --git a/llvm/unittests/Demangle/DemangleTest.cpp b/llvm/unittests/Demangle/DemangleTest.cpp
index cb70a720cad9d..1216d2c88537f 100644
--- a/llvm/unittests/Demangle/DemangleTest.cpp
+++ b/llvm/unittests/Demangle/DemangleTest.cpp
@@ -21,4 +21,9 @@ TEST(Demangle, demangleTest) {
"invocation function for block in foo(int)");
EXPECT_EQ(demangle("?foo@@YAXH at Z"), "void __cdecl foo(int)");
EXPECT_EQ(demangle("foo"), "foo");
+
+ // Regression test for demangling of optional template-args for vendor
+ // extended type qualifier (https://bugs.llvm.org/show_bug.cgi?id=48009)
+ EXPECT_EQ(demangle("_Z3fooILi79EEbU7_ExtIntIXT_EEi"),
+ "bool foo<79>(int _ExtInt<79>)");
}
More information about the libcxx-commits
mailing list