[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

Boaz Brickner via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 18 05:37:58 PST 2024


================
@@ -3951,7 +3958,7 @@ The capturing entity ``X`` can be one of the following:
       std::set<std::string_view> s;
     };
 
-- 'global', 'unknown' (without quotes).
+- `global`, `unknown`.
----------------
bricknerb wrote:

To clarify, I suggested the following:

```c++
void captureInt(const int &i [[clang::lifetime_capture_by(global)]],
                X &global);
```

If the parameter is named "global" then it is a known function parameter, no?
As a user I might not understand what the error is trying to say in this case.

So we're introducing new keywords ("global" and "unknown") implicitly, and prevent using them as parameter names in some cases.
Are there alternatives for this behavior?

We should also make sure we test this use case.

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


More information about the llvm-commits mailing list