Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Commit

Permalink
[demangle] Special case clang's creative mangling of __uuidof express…
Browse files Browse the repository at this point in the history
…ions.

git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@363752 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
epilk committed Jun 18, 2019
1 parent c793cc6 commit c9a6d09
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
X(InitListExpr) \
X(FoldExpr) \
X(ThrowExpr) \
X(UUIDOfExpr) \
X(BoolExpr) \
X(IntegerCastExpr) \
X(IntegerLiteral) \
Expand Down Expand Up @@ -1873,6 +1874,21 @@ class ThrowExpr : public Node {
}
};

// MSVC __uuidof extension, generated by clang in -fms-extensions mode.
class UUIDOfExpr : public Node {
Node *Operand;
public:
UUIDOfExpr(Node *Operand_) : Node(KUUIDOfExpr), Operand(Operand_) {}

template<typename Fn> void match(Fn F) const { F(Operand); }

void printLeft(OutputStream &S) const override {
S << "__uuidof(";
Operand->print(S);
S << ")";
}
};

class BoolExpr : public Node {
bool Value;

Expand Down Expand Up @@ -4649,6 +4665,21 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
case '9':
return getDerived().parseUnresolvedName();
}

if (consumeIf("u8__uuidoft")) {
Node *Ty = getDerived().parseType();
if (!Ty)
return nullptr;
return make<UUIDOfExpr>(Ty);
}

if (consumeIf("u8__uuidofz")) {
Node *Ex = getDerived().parseExpr();
if (!Ex)
return nullptr;
return make<UUIDOfExpr>(Ex);
}

return nullptr;
}

Expand Down
3 changes: 3 additions & 0 deletions test/test_demangle.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29769,6 +29769,9 @@ const char* cases[][2] =

// Vendor extension types are substitution candidates.
{"_Z1fu3fooS_", "f(foo, foo)"},

{"_ZN3FooIXu8__uuidofzdeL_Z3sucEEEC1Ev", "Foo<__uuidof(*(suc))>::Foo()"},
{"_ZN3FooIXu8__uuidoft13SomeUUIDClassEEC1Ev", "Foo<__uuidof(SomeUUIDClass)>::Foo()"},
};

const unsigned N = sizeof(cases) / sizeof(cases[0]);
Expand Down

0 comments on commit c9a6d09

Please sign in to comment.