[PATCH] D120143: [demangler] Add co_await demangling

Nathan Sidwell via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 18 09:59:32 PST 2022


urnathan created this revision.
urnathan added reviewers: iains, ChuanqiXu, bruno.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The demangler doesn't understand 'aw' as an operator name. This adds the necessary smarts -- you may use this as an operator function name, but not as an expression operator.


https://reviews.llvm.org/D120143

Files:
  libcxxabi/src/demangle/ItaniumDemangle.h
  libcxxabi/test/test_demangle.pass.cpp
  llvm/include/llvm/Demangle/ItaniumDemangle.h


Index: llvm/include/llvm/Demangle/ItaniumDemangle.h
===================================================================
--- llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -2568,6 +2568,7 @@
       Call,        // Function call: expr (expr*)
       CCast,       // C cast: (type)expr
       Conditional, // Conditional: expr ? expr : expr
+      NameOnly,    // Overload only, not allowed in expression.
       // Below do not have operator names
       NamedCast, // Named cast, @<type>(expr)
       OfIdOp,    // alignof, sizeof, typeid
@@ -2877,6 +2878,7 @@
       {"ad", OperatorInfo::Prefix, false, "operator&"},
       {"an", OperatorInfo::Binary, false, "operator&"},
       {"at", OperatorInfo::OfIdOp, /*Type*/ true, "alignof ("},
+      {"aw", OperatorInfo::NameOnly, false, "operator co_await"},
       {"az", OperatorInfo::OfIdOp, /*Type*/ false, "alignof ("},
       {"cc", OperatorInfo::NamedCast, false, "const_cast"},
       {"cl", OperatorInfo::Call, false, "operator()"},
@@ -4573,6 +4575,10 @@
         return nullptr;
       return make<EnclosingExpr>(Sym, Arg, ")");
     }
+    case OperatorInfo::NameOnly: {
+      // Not valid as an expression operand.
+      return nullptr;
+    }
     }
     DEMANGLE_UNREACHABLE;
   }
Index: libcxxabi/test/test_demangle.pass.cpp
===================================================================
--- libcxxabi/test/test_demangle.pass.cpp
+++ libcxxabi/test/test_demangle.pass.cpp
@@ -65023,6 +65023,8 @@
     {"_ZN2FnIXdlLj4EEXgsdaLj4EEEEvv", "void Fn<delete 4u, ::delete[] 4u>()"},
 
     {"_Z3TPLIiET_S0_", "int TPL<int>(int)"},
+
+    {"_ZN1XawEv", "X::operator co_await()"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
@@ -65123,6 +65125,8 @@
 
     "_ZN1fIiEEvNTUt_E",
     "_ZNDTUt_Ev",
+
+    "_ZN1fIXawLi0EEEEvv",
 };
 
 const unsigned NI = sizeof(invalid_cases) / sizeof(invalid_cases[0]);
Index: libcxxabi/src/demangle/ItaniumDemangle.h
===================================================================
--- libcxxabi/src/demangle/ItaniumDemangle.h
+++ libcxxabi/src/demangle/ItaniumDemangle.h
@@ -2568,6 +2568,7 @@
       Call,        // Function call: expr (expr*)
       CCast,       // C cast: (type)expr
       Conditional, // Conditional: expr ? expr : expr
+      NameOnly,    // Overload only, not allowed in expression.
       // Below do not have operator names
       NamedCast, // Named cast, @<type>(expr)
       OfIdOp,    // alignof, sizeof, typeid
@@ -2877,6 +2878,7 @@
       {"ad", OperatorInfo::Prefix, false, "operator&"},
       {"an", OperatorInfo::Binary, false, "operator&"},
       {"at", OperatorInfo::OfIdOp, /*Type*/ true, "alignof ("},
+      {"aw", OperatorInfo::NameOnly, false, "operator co_await"},
       {"az", OperatorInfo::OfIdOp, /*Type*/ false, "alignof ("},
       {"cc", OperatorInfo::NamedCast, false, "const_cast"},
       {"cl", OperatorInfo::Call, false, "operator()"},
@@ -4573,6 +4575,10 @@
         return nullptr;
       return make<EnclosingExpr>(Sym, Arg, ")");
     }
+    case OperatorInfo::NameOnly: {
+      // Not valid as an expression operand.
+      return nullptr;
+    }
     }
     DEMANGLE_UNREACHABLE;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120143.409966.patch
Type: text/x-patch
Size: 3210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220218/9a453f22/attachment.bin>


More information about the llvm-commits mailing list