[PATCH] D146535: [Clang] Fix evaluation of parameters of lambda call operator attributes

Corentin Jabot via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 23 08:12:14 PDT 2023


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG82c83d7e4105: [Clang] Fix evaluation of parameters of lambda call operator attributes (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146535

Files:
  clang/lib/Sema/SemaLambda.cpp
  clang/test/SemaCXX/lambda-expressions.cpp


Index: clang/test/SemaCXX/lambda-expressions.cpp
===================================================================
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -std=c++14 -Wno-unused-value -fsyntax-only -verify -verify=expected-cxx14 -fblocks %s
-// RUN: %clang_cc1 -std=c++17 -Wno-unused-value -fsyntax-only -verify -fblocks %s
+// RUN: %clang_cc1 -std=c++17 -Wno-unused-value -verify -ast-dump -fblocks %s | FileCheck %s
 
 namespace std { class type_info; };
 
@@ -704,3 +704,13 @@
 }());
 } // namespace GH60936
 #endif
+
+// Call operator attributes refering to a variable should
+// be properly handled after D124351
+constexpr int i = 2;
+void foo() {
+  (void)[=][[gnu::aligned(i)]] () {}; // expected-warning{{C++2b extension}}
+  // CHECK: AlignedAttr
+  // CHECK-NEXT: ConstantExpr
+  // CHECK-NEXT: value: Int 2
+}
Index: clang/lib/Sema/SemaLambda.cpp
===================================================================
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -390,6 +390,9 @@
 void Sema::handleLambdaNumbering(
     CXXRecordDecl *Class, CXXMethodDecl *Method,
     std::optional<std::tuple<bool, unsigned, unsigned, Decl *>> Mangling) {
+
+  ContextRAII ManglingContext(*this, Class->getDeclContext());
+
   if (Mangling) {
     bool HasKnownInternalLinkage;
     unsigned ManglingNumber, DeviceManglingNumber;
@@ -1324,8 +1327,6 @@
       ParamInfo.getDeclSpec().getConstexprSpecifier(),
       IsLambdaStatic ? SC_Static : SC_None, Params, ExplicitResultType);
 
-  ContextRAII ManglingContext(*this, Class->getDeclContext());
-
   CheckCXXDefaultArguments(Method);
 
   // This represents the function body for the lambda function, check if we
@@ -1350,8 +1351,6 @@
 
   handleLambdaNumbering(Class, Method);
 
-  ManglingContext.pop();
-
   for (auto &&C : LSI->Captures) {
     if (!C.isVariableCapture())
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D146535.507743.patch
Type: text/x-patch
Size: 1958 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230323/a8465928/attachment-0001.bin>


More information about the cfe-commits mailing list