-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[ASan][libc++] std::basic_string annotations #72677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AdvenamTacet
merged 10 commits into
llvm:main
from
trail-of-forks:string-annotations-base
Dec 13, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3d48196
[ASan][libc++] std::basic_string annotations
a3ecbdb
Refactor: remove duplicated code with `[[__maybe_unused__]]`
002ce2d
Address code review feedback for existing code
70dcc37
Add flag informing about dylib ASan instrumentation and guard string …
2fd41a5
Add missing annotations checks
2031dfb
Additional test cases
c1c7af6
[ASan] Annotations fix
1dd7e85
[ASan] SSO annotations fixes and refactor
83865c0
[ASan] Cleaning _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
8bb077f
Updating CMake files related to `__config_site`
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
63 changes: 63 additions & 0 deletions
63
libcxx/test/std/strings/basic.string/string.capacity/reserve_size.asan.pass.cpp
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// <string> | ||
|
||
// This test verifies that the ASan annotations for basic_string objects remain accurate | ||
// after invoking basic_string::reserve(size_type __requested_capacity). | ||
// Different types are used to confirm that ASan works correctly with types of different sizes. | ||
#include <string> | ||
#include <cassert> | ||
|
||
#include "test_macros.h" | ||
#include "asan_testing.h" | ||
|
||
template <class S> | ||
void test() { | ||
S short_s1(3, 'a'), long_s1(100, 'c'); | ||
short_s1.reserve(0x1337); | ||
long_s1.reserve(0x1337); | ||
|
||
LIBCPP_ASSERT(is_string_asan_correct(short_s1)); | ||
LIBCPP_ASSERT(is_string_asan_correct(long_s1)); | ||
|
||
short_s1.clear(); | ||
long_s1.clear(); | ||
|
||
LIBCPP_ASSERT(is_string_asan_correct(short_s1)); | ||
LIBCPP_ASSERT(is_string_asan_correct(long_s1)); | ||
|
||
short_s1.reserve(0x1); | ||
long_s1.reserve(0x1); | ||
|
||
LIBCPP_ASSERT(is_string_asan_correct(short_s1)); | ||
LIBCPP_ASSERT(is_string_asan_correct(long_s1)); | ||
|
||
S short_s2(3, 'a'), long_s2(100, 'c'); | ||
short_s2.reserve(0x1); | ||
long_s2.reserve(0x1); | ||
|
||
LIBCPP_ASSERT(is_string_asan_correct(short_s2)); | ||
LIBCPP_ASSERT(is_string_asan_correct(long_s2)); | ||
} | ||
|
||
int main(int, char**) { | ||
test<std::string>(); | ||
#ifndef TEST_HAS_NO_WIDE_CHARACTERS | ||
test<std::wstring>(); | ||
#endif | ||
#if TEST_STD_VER >= 11 | ||
test<std::u16string>(); | ||
test<std::u32string>(); | ||
#endif | ||
#if TEST_STD_VER >= 20 | ||
test<std::u8string>(); | ||
#endif | ||
|
||
return 0; | ||
} |
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.