[all-commits] [llvm/llvm-project] bc2f4c: [libc++][NFC] Rewrite function call on two lines f...
Vitaly Buka via All-commits
all-commits at lists.llvm.org
Wed Jun 12 12:44:54 PDT 2024
Branch: refs/heads/users/vitalybuka/spr/test95264
Home: https://github.com/llvm/llvm-project
Commit: bc2f4cbcc3e734c0ae847964f0c7f1912e770e16
https://github.com/llvm/llvm-project/commit/bc2f4cbcc3e734c0ae847964f0c7f1912e770e16
Author: Louis Dionne <ldionne.2 at gmail.com>
Date: 2024-06-12 (Wed, 12 Jun 2024)
Changed paths:
M libcxx/include/string
Log Message:
-----------
[libc++][NFC] Rewrite function call on two lines for clarity (#79141)
Previously, there was a ternary conditional with a less-than comparison
appearing inside a template argument, which was really confusing because
of the <...> of the function template. This patch rewrites the same
statement on two lines for clarity.
(cherry picked from commit 382f70a877f00ab71f3cb5ba461b52e1b59cd292)
Commit: e803d6ad5a06fadd9755f4afe058acd69dd11089
https://github.com/llvm/llvm-project/commit/e803d6ad5a06fadd9755f4afe058acd69dd11089
Author: Vitaly Buka <vitalybuka at google.com>
Date: 2024-06-12 (Wed, 12 Jun 2024)
Changed paths:
M libcxx/include/string
Log Message:
-----------
[libcxx] Align `__recommend() + 1` by __endian_factor (#90292)
This is detected by asan after #83774
Allocation size will be divided by `__endian_factor` before storing. If
it's not aligned,
we will not be able to recover allocation size to pass into
`__alloc_traits::deallocate`.
we have code like this
```
auto __allocation = std::__allocate_at_least(__alloc(), __recommend(__sz) + 1);
__p = __allocation.ptr;
__set_long_cap(__allocation.count);
void __set_long_cap(size_type __s) _NOEXCEPT {
__r_.first().__l.__cap_ = __s / __endian_factor;
__r_.first().__l.__is_long_ = true;
}
size_type __get_long_cap() const _NOEXCEPT {
return __r_.first().__l.__cap_ * __endian_factor;
}
inline ~basic_string() {
__annotate_delete();
if (__is_long())
__alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap());
}
```
1. __recommend() -> even size
2. `std::__allocate_at_least(__alloc(), __recommend(__sz) + 1)` - > not
even size
3. ` __set_long_cap() `- > lose one bit of size for __endian_factor == 2
(see `/ __endian_factor`)
4. `__alloc_traits::deallocate(__alloc(), __get_long_pointer(),
__get_long_cap())` -> uses even size (see `__get_long_cap`)
(cherry picked from commit d129ea8d2fa347e63deec0791faf389b84f20ce1)
Compare: https://github.com/llvm/llvm-project/compare/bc2f4cbcc3e7%5E...e803d6ad5a06
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list