Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion libcxxabi/src/demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,23 @@ class ElaboratedTypeSpefType : public Node {
}
};

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;
Expand Down Expand Up @@ -3894,7 +3911,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':
Expand Down
1 change: 1 addition & 0 deletions libcxxabi/src/demangle/ItaniumNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NODE(QualType)
NODE(ConversionOperatorType)
NODE(PostfixQualifiedType)
NODE(ElaboratedTypeSpefType)
NODE(TransformedType)
NODE(NameType)
NODE(AbiTagAttr)
NODE(EnableIfAttr)
Expand Down
3 changes: 3 additions & 0 deletions libcxxabi/test/test_demangle.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30114,6 +30114,9 @@ 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
{"_Z2f5IiEvu7__decayIT_E", "void f5<int>(__decay(int))"},
};

const unsigned N = sizeof(cases) / sizeof(cases[0]);
Expand Down
27 changes: 26 additions & 1 deletion llvm/include/llvm/Demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,23 @@ class ElaboratedTypeSpefType : public Node {
}
};

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;
Expand Down Expand Up @@ -3889,7 +3906,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':
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Demangle/ItaniumNodes.def
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NODE(QualType)
NODE(ConversionOperatorType)
NODE(PostfixQualifiedType)
NODE(ElaboratedTypeSpefType)
NODE(TransformedType)
NODE(NameType)
NODE(AbiTagAttr)
NODE(EnableIfAttr)
Expand Down