[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

Shafik Yaghmour via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 7 09:53:51 PDT 2022


shafik created this revision.
shafik added reviewers: aprantl, dblaikie, probinson.
Herald added a project: All.
shafik requested review of this revision.

D70524 <https://reviews.llvm.org/D70524> added support for auto return types for C++ member functions. I was implementing support on the LLDB side for looking up the deduced type.

I ran into trouble with some cases with respect to lambdas. I looked into how gcc was handling these cases and it appears gcc emits the deduced return type for lambdas.

So I am changing out behavior to match that.


https://reviews.llvm.org/D123319

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp


Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1678,8 +1678,14 @@
   SmallVector<llvm::Metadata *, 16> Elts;
   // First element is always return type. For 'void' functions it is NULL.
   QualType temp = Func->getReturnType();
-  if (temp->getTypeClass() == Type::Auto && decl)
-    Elts.push_back(CreateType(cast<AutoType>(temp)));
+  if (temp->getTypeClass() == Type::Auto && decl) {
+    const AutoType *AT = cast<AutoType>(temp);
+
+    if (AT->isDeduced() && ThisPtr->getPointeeCXXRecordDecl()->isLambda())
+      Elts.push_back(getOrCreateType(AT->getDeducedType(),Unit));
+    else
+      Elts.push_back(CreateType(AT));
+  }
   else
     Elts.push_back(Args[0]);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123319.421242.patch
Type: text/x-patch
Size: 815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220407/02aa93e5/attachment.bin>


More information about the cfe-commits mailing list