[libcxxabi] r327690 - [demangler] Support for <template-param>s in generic lambdas.

Erik Pilkington via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 15 20:06:31 PDT 2018


Author: epilk
Date: Thu Mar 15 20:06:30 2018
New Revision: 327690

URL: http://llvm.org/viewvc/llvm-project?rev=327690&view=rev
Log:
[demangler] Support for <template-param>s in generic lambdas.

These <template-param>s refer to "artifical" <template-arg>s that don't appear
in the mangled name, so we just print them as "auto".

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=327690&r1=327689&r2=327690&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_demangle.cpp (original)
+++ libcxxabi/trunk/src/cxa_demangle.cpp Thu Mar 15 20:06:30 2018
@@ -2013,6 +2013,7 @@ struct Db {
   bool TagTemplates = true;
   bool FixForwardReferences = false;
   bool TryToParseTemplateArgs = true;
+  bool ParsingLambdaParams = false;
 
   BumpPointerAllocator ASTAllocator;
 
@@ -2270,6 +2271,7 @@ Node *Db::parseUnnamedTypeName(NameState
   }
   if (consumeIf("Ul")) {
     NodeArray Params;
+    SwapAndRestore<bool> SwapParams(ParsingLambdaParams, true);
     if (!consumeIf("vE")) {
       size_t ParamsBegin = Names.size();
       do {
@@ -4658,20 +4660,20 @@ Node *Db::parseTemplateParam() {
   if (!consumeIf('T'))
     return nullptr;
 
-  if (consumeIf('_')) {
-    if (TemplateParams.empty()) {
-      FixForwardReferences = true;
-      return make<NameType>("FORWARD_REFERENCE");
-    }
-    return TemplateParams[0];
+  size_t Index = 0;
+  if (!consumeIf('_')) {
+    if (parsePositiveInteger(&Index))
+      return nullptr;
+    ++Index;
+    if (!consumeIf('_'))
+      return nullptr;
   }
 
-  size_t Index;
-  if (parsePositiveInteger(&Index))
-    return nullptr;
-  ++Index;
-  if (!consumeIf('_'))
-    return nullptr;
+  // Itanium ABI 5.1.8: In a generic lambda, uses of auto in the parameter list
+  // are mangled as the corresponding artificial template type parameter.
+  if (ParsingLambdaParams)
+    return make<NameType>("auto");
+
   if (Index >= TemplateParams.size()) {
     FixForwardReferences = true;
     return make<NameType>("FORWARD_REFERENCE");

Modified: libcxxabi/trunk/test/test_demangle.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/test_demangle.pass.cpp?rev=327690&r1=327689&r2=327690&view=diff
==============================================================================
--- libcxxabi/trunk/test/test_demangle.pass.cpp (original)
+++ libcxxabi/trunk/test/test_demangle.pass.cpp Thu Mar 15 20:06:30 2018
@@ -29604,7 +29604,7 @@ const char* cases[][2] =
     {"PFvRmOE", "void (*)(unsigned long&) &&"},
     {"_ZTW1x", "thread-local wrapper routine for x"},
     {"_ZTHN3fooE", "thread-local initialization routine for foo"},
-    {"_Z4algoIJiiiEEvZ1gEUlDpT_E_", "void algo<int, int, int>(g::'lambda'(int, int, int))"},
+
     // attribute abi_tag
     {"_Z1fB3foov", "f[abi:foo]()"},
     {"_Z1fB3fooB3barv", "f[abi:foo][abi:bar]()"},
@@ -29725,6 +29725,8 @@ const char* cases[][2] =
 
     {"_ZGRDC1x1yE_", "reference temporary for [x, y]"},
     {"_ZGR1bIvE2_", "reference temporary for b<void>"},
+
+    {"_ZZ18test_assign_throwsI20small_throws_on_copyLb0EEvvENKUlRNSt3__13anyEOT_E_clIRS0_EEDaS3_S5_", "auto void test_assign_throws<small_throws_on_copy, false>()::'lambda'(std::__1::any&, auto&&)::operator()<small_throws_on_copy&>(std::__1::any&, auto&&) const"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);




More information about the cfe-commits mailing list