[clang] [clang] Support 'this' position for lifetimebound attribute (PR #115021)

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 5 10:20:50 PST 2024


================
@@ -739,10 +742,16 @@ class YAMLConverter {
       PI.setLifetimebound(P.Lifetimebound);
       PI.setType(std::string(P.Type));
       PI.setRetainCountConvention(P.RetainCountConvention);
-      if (OutInfo.Params.size() <= P.Position)
+      if (static_cast<int>(OutInfo.Params.size()) <= P.Position)
         OutInfo.Params.resize(P.Position + 1);
-      OutInfo.Params[P.Position] |= PI;
+      if (P.Position < -1)
+        emitError("parameter position smaller than -1 is not valid");
+      else if (P.Position == -1)
+        thisOrSelf = PI;
+      else
+        OutInfo.Params[P.Position] |= PI;
----------------
compnerd wrote:

I wonder if we should rewrite this to make it easier to introduce additional implicit parameters in the future:

```suggestion
      if (P.Position == -1)
        thisOrSelf = PI;
      else if (P.Position > 0)
        OutInfo.Params[P.Position] |= PI;
      else
        emitError("invalid parameter position " + itostr(P.Position));
```

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


More information about the cfe-commits mailing list