[llvm] ee67f78 - Fix error caused by reference to local binding (#151789)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 21:57:30 PDT 2025
Author: Arvind Sudarsanam
Date: 2025-08-02T00:57:26-04:00
New Revision: ee67f78776d0af64bc27cabcca62883f7a698467
URL: https://github.com/llvm/llvm-project/commit/ee67f78776d0af64bc27cabcca62883f7a698467
DIFF: https://github.com/llvm/llvm-project/commit/ee67f78776d0af64bc27cabcca62883f7a698467.diff
LOG: Fix error caused by reference to local binding (#151789)
This change fixes one of the failures in
https://github.com/llvm/llvm-project/pull/147321
Following code snippet:
`
for (const auto &[CategoryName, PropSet] : PSRegistry) {
J.attributeObject(CategoryName, [&] {
for (const auto &[PropName, PropVal] : PropSet) {
`
causes a build warning that is emitted as an error.
error: reference to local binding 'PropSet' declared in enclosing lambda
expression
This is resolved by capturing PropSet in a local variable.
Thanks
Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam at intel.com>
Added:
Modified:
llvm/lib/Frontend/Offloading/PropertySet.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Frontend/Offloading/PropertySet.cpp b/llvm/lib/Frontend/Offloading/PropertySet.cpp
index 5aff34ff1afd5..9a1044e7ae1e4 100644
--- a/llvm/lib/Frontend/Offloading/PropertySet.cpp
+++ b/llvm/lib/Frontend/Offloading/PropertySet.cpp
@@ -19,8 +19,9 @@ void llvm::offloading::writePropertiesToJSON(
json::OStream J(Out);
J.object([&] {
for (const auto &[CategoryName, PropSet] : PSRegistry) {
+ auto PropSetCapture = PropSet;
J.attributeObject(CategoryName, [&] {
- for (const auto &[PropName, PropVal] : PropSet) {
+ for (const auto &[PropName, PropVal] : PropSetCapture) {
switch (PropVal.index()) {
case 0:
J.attribute(PropName, std::get<uint32_t>(PropVal));
More information about the llvm-commits
mailing list