[libcxx-commits] [libcxx] Add [[clang::lifetimebound]] to numerous functions in libc++ include headers (PR #112751)

Richard Smith via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 21 16:24:12 PDT 2024


zygoloid wrote:

> In [#59900 (comment)](https://github.com/llvm/llvm-project/issues/59900#issuecomment-1399068948), @zygoloid mentioned that Clang was now inferring the attribute on some libc++ functions. Does it do that by hardcoding the names of some libc++ functions, or is there some other "intelligent" mechanism that it's using to do that?

For functions that clang models as "library builtins" (which covers quite a few C standard library functions as well as a handful of C++ standard library functions), it also has a list of attributes it implicitly adds to those functions. This list is hardcoded:

- [The list of functions recognized as builtins is configured here](https://github.com/llvm/llvm-project/blob/0de8de1b8432f01adb0a7c6d2f1e3d4fd8c0c30c/clang/include/clang/Basic/Builtins.td)
- [Attributes are applied here](https://github.com/llvm/llvm-project/blob/0de8de1b8432f01adb0a7c6d2f1e3d4fd8c0c30c/clang/lib/Sema/SemaDecl.cpp#L16514), based on the `Attributes` list in the `.td` file as well as some hardcoded rules.

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


More information about the libcxx-commits mailing list