[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


================
@@ -926,11 +935,17 @@ class YAMLConverter {
                          TheNamespace.Items, SwiftVersion);
   }
 
-  void convertFunction(const Function &Function, FunctionInfo &FI) {
+  template <typename FuncOrMethodInfo>
+  void convertFunction(const Function &Function, FuncOrMethodInfo &FI) {
     convertAvailability(Function.Availability, FI, Function.Name);
     FI.setSwiftPrivate(Function.SwiftPrivate);
     FI.SwiftName = std::string(Function.SwiftName);
-    convertParams(Function.Params, FI);
+    if constexpr (std::is_same_v<FuncOrMethodInfo, CXXMethodInfo>) {
+      FI.This = convertParams(Function.Params, FI);
+    } else {
+      if (convertParams(Function.Params, FI))
+        emitError("position -1 is only valid for C++ and Objective-C methods");
----------------
compnerd wrote:

```suggestion
        emitError("implicit instance parameter is only permitted on C++ and Objective-C methods");
```

Let's try to avoid the explicit value we use for the representation in the diagnostic.

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


More information about the cfe-commits mailing list