[PATCH] D86130: [AST] Fix a crash on mangling a binding decl from a DeclRefExpr.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 18 01:43:44 PDT 2020


hokein created this revision.
hokein added a reviewer: rsmith.
Herald added a project: clang.
hokein requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86130

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/test/CodeGenCXX/mangle.cpp


Index: clang/test/CodeGenCXX/mangle.cpp
===================================================================
--- clang/test/CodeGenCXX/mangle.cpp
+++ clang/test/CodeGenCXX/mangle.cpp
@@ -1138,3 +1138,12 @@
   // CHECK-LABEL: @_ZN6test581AC1INS_5StateEEET_MNS_8identityIS3_E4typeEFbvE
   void fn1() { A(a, &State::m_fn1); }
 }
+
+namespace test59 {
+  // verify no crash.
+  template<typename T>
+  void f(T g) {
+    auto [e] = g;
+    [](decltype(e)) {};
+  }
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===================================================================
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -657,6 +657,8 @@
     mangleName(FD);
   else if (const MSGuidDecl *GuidD = dyn_cast<MSGuidDecl>(GD.getDecl()))
     mangleName(GuidD);
+  else if (const BindingDecl *BD = dyn_cast<BindingDecl>(GD.getDecl()))
+    mangleName(BD);
   else
     llvm_unreachable("unexpected kind of global decl");
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86130.286220.patch
Type: text/x-patch
Size: 943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200818/74c30c85/attachment.bin>


More information about the cfe-commits mailing list