[libcxxabi] r327226 - [demangler] Support for structured bindings.

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 10 14:37:16 PST 2018



On 2018-03-10 4:40 PM, Richard Smith wrote:
> On 10 Mar 2018 13:33, "Erik Pilkington via cfe-commits" 
> <cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>> wrote:
>
>     Author: epilk
>     Date: Sat Mar 10 13:31:15 2018
>     New Revision: 327226
>
>     URL: http://llvm.org/viewvc/llvm-project?rev=327226&view=rev
>     <http://llvm.org/viewvc/llvm-project?rev=327226&view=rev>
>     Log:
>     [demangler] Support for structured bindings.
>
>     Modified:
>         libcxxabi/trunk/src/cxa_demangle.cpp
>         libcxxabi/trunk/test/test_demangle.pass.cpp
>
>     Modified: libcxxabi/trunk/src/cxa_demangle.cpp
>     URL:
>     http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=327226&r1=327225&r2=327226&view=diff
>     <http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_demangle.cpp?rev=327226&r1=327225&r2=327226&view=diff>
>     ==============================================================================
>     --- libcxxabi/trunk/src/cxa_demangle.cpp (original)
>     +++ libcxxabi/trunk/src/cxa_demangle.cpp Sat Mar 10 13:31:15 2018
>     @@ -197,6 +197,7 @@ public:
>          KDtorName,
>          KUnnamedTypeName,
>          KClosureTypeName,
>     +    KStructuredBindingName,
>          KExpr,
>          KBracedExpr,
>          KBracedRangeExpr,
>     @@ -1337,6 +1338,19 @@ public:
>        }
>      };
>
>     +class StructuredBindingName : public Node {
>     +  NodeArray Bindings;
>     +public:
>     +  StructuredBindingName(NodeArray Bindings_)
>     +      : Node(KStructuredBindingName), Bindings(Bindings_) {}
>     +
>     +  void printLeft(OutputStream &S) const override {
>     +    S += "'structured-binding'[";
>     +    Bindings.printWithComma(S);
>     +    S += ']';
>     +  }
>     +};
>     +
>      // -- Expression Nodes --
>
>      struct Expr : public Node {
>     @@ -2217,7 +2231,7 @@ Node *Db::parseUnscopedName(NameState *S
>      //                    ::= <ctor-dtor-name>
>      //                    ::= <source-name>
>      //                    ::= <unnamed-type-name>
>     -// FIXME:             ::= DC <source-name>+ E   # structured
>     binding declaration
>     +//                    ::= DC <source-name>+ E   # structured
>     binding declaration
>      Node *Db::parseUnqualifiedName(NameState *State) {
>       // <ctor-dtor-name>s are special-cased in parseNestedName().
>       Node *Result;
>     @@ -2225,7 +2239,16 @@ Node *Db::parseUnqualifiedName(NameState
>         Result = parseUnnamedTypeName(State);
>       else if (look() >= '1' && look() <= '9')
>         Result = parseSourceName(State);
>     - else
>     + else if (consumeIf("DC")) {
>     +   size_t BindingsBegin = Names.size();
>     +   do {
>     +     Node *Binding = parseSourceName(State);
>     +     if (Binding == nullptr)
>     +       return nullptr;
>     +     Names.push_back(Binding);
>     +   } while (!consumeIf('E'));
>     +   Result =
>     make<StructuredBindingName>(popTrailingNodeArray(BindingsBegin));
>     + } else
>         Result = parseOperatorName(State);
>       if (Result != nullptr)
>         Result = parseAbiTags(Result);
>     @@ -2689,7 +2712,7 @@ Node *Db::parseNestedName(NameState *Sta
>          }
>
>          // Parse an <unqualified-name> thats actually a <ctor-dtor-name>.
>     -    if (look() == 'C' || look() == 'D') {
>     +    if (look() == 'C' || (look() == 'D' && look(1) != 'C')) {
>            if (SoFar == nullptr)
>              return nullptr;
>            Node *CtorDtor = parseCtorDtorName(SoFar, State);
>
>     Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
>     URL:
>     http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=327226&r1=327225&r2=327226&view=diff
>     <http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=327226&r1=327225&r2=327226&view=diff>
>     ==============================================================================
>     --- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
>     +++ libcxxabi/trunk/test/test_demangle.pass.cpp Sat Mar 10
>     13:31:15 2018
>     @@ -29718,6 +29718,10 @@ const char* cases[][2] =
>          {"_Z1fSsB1XS_", "f(std::string[abi:X], std::string[abi:X])"},
>
>          {"___Z10blocksNRVOv_block_invoke", "invocation function for
>     block in blocksNRVO()"},
>     +
>     +    // Structured bindings:
>     +    {"_ZDC2a12a2E", "'structured-binding'[a1, a2]"},
>     +    {"_ZN2NSDC1x1yEE", "NS::'structured-binding'[x, y]"},
>
>
> Do we really need the prefix here? In the front-end we just use 
> "NS::[x,y]" for this.
I suppose not, that printing is just as informative and less verbose. 
Fixed this in r327228, thanks for the review!
>
>      };
>
>      const unsigned N = sizeof(cases) / sizeof(cases[0]);
>     @@ -29848,7 +29852,6 @@ void test_invalid_cases()
>
>      const char *xfail_cases[] = {
>          "_Z1fUa9enable_ifIXLi1EEEv", // enable_if attribute
>     -    "_ZDC2a12a2E", // decomposition decl
>          "_ZW6FooBarE2f3v", // C++ modules TS
>
>          // FIXME: Why does clang generate the "cp" expr?
>
>
>     _______________________________________________
>     cfe-commits mailing list
>     cfe-commits at lists.llvm.org <mailto:cfe-commits at lists.llvm.org>
>     http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>     <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180310/2737ef0e/attachment.html>


More information about the cfe-commits mailing list