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

Adrian Prantl via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 14 15:28:49 PDT 2022


aprantl added inline comments.


================
Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:1684
+
+    if (AT->isDeduced() && ThisPtr->getPointeeCXXRecordDecl()->isLambda())
+      Elts.push_back(getOrCreateType(AT->getDeducedType(),Unit));
----------------
aprantl wrote:
> Can you add a comment here, explaining why lambdas are special?
this is still missing ^


================
Comment at: clang/test/CodeGenCXX/no_auto_return_lambda.cpp:1
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
----------------
It would be nice to also have a comment in here, about what is being tested.
Ie.: `// Test that clang emits the deduced return type for lambdas.`


================
Comment at: clang/test/CodeGenCXX/no_auto_return_lambda.cpp:8
+
+// CHECK: !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+// CHECK-NOT: !DIBasicType(tag: DW_TAG_unspecified_type, name: "auto")
----------------
This test is very fragile. Instead of checking that no unspecified type *follows* the first declaration of `int` and hoping that no other `int` is emitted in this CU, it would be better to explictly check for the return type of the `DISubprogram` for `g` using FileCheck variable substitutions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123319/new/

https://reviews.llvm.org/D123319



More information about the cfe-commits mailing list