Repository navigation
Add ABSL_ATTRIBUTE_UNSAFE_BUFFER_USAGE_IN_CONTAINER and apply it to absl::Span. - #2420
Draft
copybara-service[bot] wants to merge 1 commit into
Draft
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
…bsl::Span. Clang's `-Wunsafe-buffer-usage-in-container` flags two-parameter `std::span` constructions whose arguments are not provably safe. The new macro wraps `[[clang::unsafe_buffer_usage_in_container]]`, which opts other container and view types into the same check, and expands to nothing on compilers that do not support the attribute. Apply it to the (pointer, length) constructor of `absl::Span` and the (pointer, length) and (begin, end) overloads of `absl::MakeSpan()` and `absl::MakeConstSpan()`, so that calls such as `absl::Span<int>(p, n)` are diagnosed while `absl::Span<int>(v.data(), v.size())` is not. PiperOrigin-RevId: 1005970571
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add ABSL_ATTRIBUTE_UNSAFE_BUFFER_USAGE_IN_CONTAINER and apply it to absl::Span.
Clang's
-Wunsafe-buffer-usage-in-containerflags two-parameterstd::spanconstructions whose arguments are not provably safe. The new macro wraps[[clang::unsafe_buffer_usage_in_container]], which opts other container and view types into the same check, and expands to nothing on compilers that do not support the attribute.Apply it to the (pointer, length) constructor of
absl::Spanand the (pointer, length) and (begin, end) overloads ofabsl::MakeSpan()andabsl::MakeConstSpan(), so that calls such asabsl::Span<int>(p, n)are diagnosed whileabsl::Span<int>(v.data(), v.size())is not.