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

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 18 06:16:33 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`.
----------------
usx95 wrote:

> Was this already discussed somewhere else?

This was discussed in https://github.com/llvm/llvm-project/pull/111499#discussion_r1836463450

> I think we should try to find an alternative for limiting the parameter name this way, since it's possible it won't be easy to change in some cases.

Changing parameter names should be relatively easy though. It is not part of the signature/mangled name so it should be relatively local change.
Other alternatives include 
- using parameter indices: But this reduces readability and is very brittle.
- `[[clang::lifetime_capture_by(__global)]]`: But this only reduces the likelyhood of name collision.

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


More information about the cfe-commits mailing list