[Mlir-commits] [mlir] [mlir] Fix -Wdangling-assignment-gsl in OperationSupport.h (PR #126140)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Feb 6 14:11:30 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: Shoaib Meenai (smeenai)

<details>
<summary>Changes</summary>

This warning is causing lots of build spam when I use a recent Clang as
my host compiler. a3b4d9147406cbd90090466a9b2b9bb2e9f6000c fixes the
same issue in clangd; apply that fix here too. I also think this is a
potential false positive though. Fix variable casing while I'm here.


---
Full diff: https://github.com/llvm/llvm-project/pull/126140.diff


1 Files Affected:

- (modified) mlir/include/mlir/IR/OperationSupport.h (+6-4) 


``````````diff
diff --git a/mlir/include/mlir/IR/OperationSupport.h b/mlir/include/mlir/IR/OperationSupport.h
index d4035d14ab74650..bcbf9458ff96e7f 100644
--- a/mlir/include/mlir/IR/OperationSupport.h
+++ b/mlir/include/mlir/IR/OperationSupport.h
@@ -997,13 +997,15 @@ struct OperationState {
     if (!properties) {
       T *p = new T{};
       properties = p;
-      propertiesDeleter = [](OpaqueProperties prop) {
+      constexpr auto deleter = [](OpaqueProperties prop) {
         delete prop.as<const T *>();
       };
-      propertiesSetter = [](OpaqueProperties new_prop,
-                            const OpaqueProperties prop) {
-        *new_prop.as<T *>() = *prop.as<const T *>();
+      propertiesDeleter = deleter;
+      constexpr auto setter = [](OpaqueProperties newProp,
+                                 const OpaqueProperties prop) {
+        *newProp.as<T *>() = *prop.as<const T *>();
       };
+      propertiesSetter = setter;
       propertiesId = TypeID::get<T>();
     }
     assert(propertiesId == TypeID::get<T>() && "Inconsistent properties");

``````````

</details>


https://github.com/llvm/llvm-project/pull/126140


More information about the Mlir-commits mailing list