aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libcxxabi/src/demangle/ItaniumDemangle.h27
-rw-r--r--libcxxabi/src/demangle/ItaniumNodes.def1
-rw-r--r--libcxxabi/test/test_demangle.pass.cpp9
-rw-r--r--llvm/include/llvm/Demangle/ItaniumDemangle.h27
-rw-r--r--llvm/include/llvm/Demangle/ItaniumNodes.def1
5 files changed, 63 insertions, 2 deletions
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 6fdfe38..2336b84 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -534,6 +534,23 @@ public:
}
};
+class TransformedType : public Node {
+ std::string_view Transform;
+ Node *BaseType;
+public:
+ TransformedType(std::string_view Transform_, Node *BaseType_)
+ : Node(KTransformedType), Transform(Transform_), BaseType(BaseType_) {}
+
+ template<typename Fn> void match(Fn F) const { F(Transform, BaseType); }
+
+ void printLeft(OutputBuffer &OB) const override {
+ OB += Transform;
+ OB += '(';
+ BaseType->print(OB);
+ OB += ')';
+ }
+};
+
struct AbiTagAttr : Node {
Node *Base;
std::string_view Tag;
@@ -4125,7 +4142,15 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
// Typically, <builtin-type>s are not considered substitution candidates,
// but the exception to that exception is vendor extended types (Itanium C++
// ABI 5.9.1).
- Result = make<NameType>(Res);
+ if (consumeIf('I')) {
+ Node *BaseType = parseType();
+ if (BaseType == nullptr)
+ return nullptr;
+ if (!consumeIf('E'))
+ return nullptr;
+ Result = make<TransformedType>(Res, BaseType);
+ } else
+ Result = make<NameType>(Res);
break;
}
case 'D':
diff --git a/libcxxabi/src/demangle/ItaniumNodes.def b/libcxxabi/src/demangle/ItaniumNodes.def
index 74dc709..e27c111 100644
--- a/libcxxabi/src/demangle/ItaniumNodes.def
+++ b/libcxxabi/src/demangle/ItaniumNodes.def
@@ -19,6 +19,7 @@ NODE(QualType)
NODE(ConversionOperatorType)
NODE(PostfixQualifiedType)
NODE(ElaboratedTypeSpefType)
+NODE(TransformedType)
NODE(NameType)
NODE(AbiTagAttr)
NODE(EnableIfAttr)
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index 47cc29b..df7bedc 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30161,6 +30161,15 @@ const char* cases[][2] =
" std::allocator<char>>::basic_string()"},
{"_ZN1SB8ctor_tagC2Ev", "S[abi:ctor_tag]::S()"},
{"_ZN1SB8ctor_tagD2Ev", "S[abi:ctor_tag]::~S()"},
+
+ // clang builtin type transform
+ {"_Z2f5IiEvu22__add_lvalue_referenceIT_E", "void f5<int>(__add_lvalue_reference(int))"},
+ {"_Z2f5IiEvu13__add_pointerIT_E", "void f5<int>(__add_pointer(int))"},
+ {"_Z2f5IiEvu7__decayIT_E", "void f5<int>(__decay(int))"},
+ {"_Z2f5IjEvu13__make_signedIT_E", "void f5<unsigned int>(__make_signed(unsigned int))"},
+ {"_Z2f5IKiEvu14__remove_constIT_E", "void f5<int const>(__remove_const(int const))"},
+ {"_Z2f5IPiEvu16__remove_pointerIT_E", "void f5<int*>(__remove_pointer(int*))"},
+ {"_Z2f5IiEvu14__remove_cvrefIT_E", "void f5<int>(__remove_cvref(int))"},
};
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 52105bf..f68c372 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -533,6 +533,23 @@ public:
}
};
+class TransformedType : public Node {
+ std::string_view Transform;
+ Node *BaseType;
+public:
+ TransformedType(std::string_view Transform_, Node *BaseType_)
+ : Node(KTransformedType), Transform(Transform_), BaseType(BaseType_) {}
+
+ template<typename Fn> void match(Fn F) const { F(Transform, BaseType); }
+
+ void printLeft(OutputBuffer &OB) const override {
+ OB += Transform;
+ OB += '(';
+ BaseType->print(OB);
+ OB += ')';
+ }
+};
+
struct AbiTagAttr : Node {
Node *Base;
std::string_view Tag;
@@ -4124,7 +4141,15 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
// Typically, <builtin-type>s are not considered substitution candidates,
// but the exception to that exception is vendor extended types (Itanium C++
// ABI 5.9.1).
- Result = make<NameType>(Res);
+ if (consumeIf('I')) {
+ Node *BaseType = parseType();
+ if (BaseType == nullptr)
+ return nullptr;
+ if (!consumeIf('E'))
+ return nullptr;
+ Result = make<TransformedType>(Res, BaseType);
+ } else
+ Result = make<NameType>(Res);
break;
}
case 'D':
diff --git a/llvm/include/llvm/Demangle/ItaniumNodes.def b/llvm/include/llvm/Demangle/ItaniumNodes.def
index 12cfa70f..30a93ec 100644
--- a/llvm/include/llvm/Demangle/ItaniumNodes.def
+++ b/llvm/include/llvm/Demangle/ItaniumNodes.def
@@ -19,6 +19,7 @@ NODE(QualType)
NODE(ConversionOperatorType)
NODE(PostfixQualifiedType)
NODE(ElaboratedTypeSpefType)
+NODE(TransformedType)
NODE(NameType)
NODE(AbiTagAttr)
NODE(EnableIfAttr)