[PATCH] D144627: [Clang] Fix a crash when taking the address of a consteval lambda

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 23 05:48:45 PST 2023


aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM with a minor cleanup.



================
Comment at: clang/lib/Sema/SemaExpr.cpp:17976-17983
     auto *FD = cast<FunctionDecl>(DR->getDecl());
-    SemaRef.Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
-        << FD;
+    if (auto *MD = llvm::dyn_cast<CXXMethodDecl>(FD);
+        MD && (MD->isLambdaStaticInvoker() || isLambdaCallOperator(MD)))
+      SemaRef.Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
+          << MD->getParent() << 1;
+    else
+      SemaRef.Diag(DR->getBeginLoc(), diag::err_invalid_consteval_take_address)
----------------
Minor simplification, NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144627



More information about the cfe-commits mailing list