[libcxx-commits] [libcxxabi] r363752 - [demangle] Special case clang's creative mangling of __uuidof expressions.

Erik Pilkington via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 24 10:03:40 PDT 2019


There was some discussion about it here: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20140922/115222.html

I’m not really familiar with this extension, but I don’t think too much thought went into this choice, as it doesn’t really fit into the grammar (‘u’ prefixes are for types, not expressions). Do you think it's fundamentally broken? If so maybe we should consider updating it behind a -fclang-abi-compat flag.

> On Jun 22, 2019, at 9:20 AM, Nico Weber <thakis at chromium.org> wrote:
> 
> Do you know where this mangling got added? The mangling looks a bit surprising in that if for some reason you have two different type names with the same uuid, then I would've expected that Foo<__uuidof(T1)> and Foo<__uuidof(T2)> would produce the same symbol name, like they do in the MS abi.
> 
> On Wed, Jun 19, 2019 at 1:30 AM Erik Pilkington via libcxx-commits <libcxx-commits at lists.llvm.org <mailto:libcxx-commits at lists.llvm.org>> wrote:
> Author: epilk
> Date: Tue Jun 18 16:34:09 2019
> New Revision: 363752
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=363752&view=rev <http://llvm.org/viewvc/llvm-project?rev=363752&view=rev>
> Log:
> [demangle] Special case clang's creative mangling of __uuidof expressions.
> 
> Modified:
>     libcxxabi/trunk/src/demangle/ItaniumDemangle.h
>     libcxxabi/trunk/test/test_demangle.pass.cpp
> 
> Modified: libcxxabi/trunk/src/demangle/ItaniumDemangle.h
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/demangle/ItaniumDemangle.h?rev=363752&r1=363751&r2=363752&view=diff <http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/demangle/ItaniumDemangle.h?rev=363752&r1=363751&r2=363752&view=diff>
> ==============================================================================
> --- libcxxabi/trunk/src/demangle/ItaniumDemangle.h (original)
> +++ libcxxabi/trunk/src/demangle/ItaniumDemangle.h Tue Jun 18 16:34:09 2019
> @@ -89,6 +89,7 @@
>      X(InitListExpr) \
>      X(FoldExpr) \
>      X(ThrowExpr) \
> +    X(UUIDOfExpr) \
>      X(BoolExpr) \
>      X(IntegerCastExpr) \
>      X(IntegerLiteral) \
> @@ -1873,6 +1874,21 @@ public:
>    }
>  };
> 
> +// 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;
> 
> @@ -4649,6 +4665,21 @@ Node *AbstractManglingParser<Derived, Al
>    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;
>  }
> 
> 
> Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
> URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=363752&r1=363751&r2=363752&view=diff <http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=363752&r1=363751&r2=363752&view=diff>
> ==============================================================================
> --- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
> +++ libcxxabi/trunk/test/test_demangle.pass.cpp Tue Jun 18 16:34:09 2019
> @@ -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]);
> 
> 
> _______________________________________________
> libcxx-commits mailing list
> libcxx-commits at lists.llvm.org <mailto:libcxx-commits at lists.llvm.org>
> https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-commits <https://lists.llvm.org/cgi-bin/mailman/listinfo/libcxx-commits>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20190624/8a60aab6/attachment-0001.html>


More information about the libcxx-commits mailing list