[libcxx-commits] [libcxx] [ASan][libc++] Turn on ASan annotations for short strings (PR #75882)

via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 18 17:36:30 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff 47db1e2ab9541dd94a75d5812cdbad6c3c3d7a42 b67e8917ce21d7a15907ee1513f7432f7eb79931 -- libcxx/test/libcxx/containers/strings/basic.string/asan_deque_integration.pass.cpp libcxx/test/libcxx/containers/strings/basic.string/asan_short.pass.cpp libcxx/test/libcxx/containers/strings/basic.string/asan_vector_integration.pass.cpp libcxx/include/string libcxx/test/support/asan_testing.h
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/libcxx/containers/strings/basic.string/asan_deque_integration.pass.cpp b/libcxx/test/libcxx/containers/strings/basic.string/asan_deque_integration.pass.cpp
index 95a025ced7..cb5bbd67b1 100644
--- a/libcxx/test/libcxx/containers/strings/basic.string/asan_deque_integration.pass.cpp
+++ b/libcxx/test/libcxx/containers/strings/basic.string/asan_deque_integration.pass.cpp
@@ -159,7 +159,7 @@ void test_string() {
   }
 }
 
-template<class S>
+template <class S>
 void test_container() {
   test_string<std::deque<S, std::allocator<S>>, S>();
   test_string<std::deque<S, min_allocator<S>>, S>();
diff --git a/libcxx/test/libcxx/containers/strings/basic.string/asan_short.pass.cpp b/libcxx/test/libcxx/containers/strings/basic.string/asan_short.pass.cpp
index 6c692b38c3..adeb7c4abd 100644
--- a/libcxx/test/libcxx/containers/strings/basic.string/asan_short.pass.cpp
+++ b/libcxx/test/libcxx/containers/strings/basic.string/asan_short.pass.cpp
@@ -45,7 +45,8 @@ int main(int, char**) {
     const T t[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g'};
     C c(std::begin(t), std::end(t));
     assert(is_string_asan_correct(c));
-    assert(__sanitizer_verify_contiguous_container(c.data(), c.data() + c.size() + 1, c.data() + c.capacity() + 1) != 0);
+    assert(__sanitizer_verify_contiguous_container(c.data(), c.data() + c.size() + 1, c.data() + c.capacity() + 1) !=
+           0);
     volatile T foo = c[c.size() + 1]; // should trigger ASAN. Use volatile to prevent being optimized away.
     assert(false);                    // if we got here, ASAN didn't trigger
     ((void)foo);
diff --git a/libcxx/test/libcxx/containers/strings/basic.string/asan_vector_integration.pass.cpp b/libcxx/test/libcxx/containers/strings/basic.string/asan_vector_integration.pass.cpp
index a3a33ea84c..0ae1b9f65d 100644
--- a/libcxx/test/libcxx/containers/strings/basic.string/asan_vector_integration.pass.cpp
+++ b/libcxx/test/libcxx/containers/strings/basic.string/asan_vector_integration.pass.cpp
@@ -159,7 +159,7 @@ void test_string() {
   }
 }
 
-template<class S>
+template <class S>
 void test_container() {
   test_string<std::vector<S, std::allocator<S>>, S>();
   test_string<std::vector<S, min_allocator<S>>, S>();
diff --git a/libcxx/test/support/asan_testing.h b/libcxx/test/support/asan_testing.h
index 23545ff0d0..5b07b97a2d 100644
--- a/libcxx/test/support/asan_testing.h
+++ b/libcxx/test/support/asan_testing.h
@@ -77,7 +77,8 @@ TEST_CONSTEXPR bool is_string_asan_correct(const std::basic_string<ChrT, TraitsT
   if (std::is_same<Alloc, std::allocator<ChrT>>::value)
     return __sanitizer_verify_contiguous_container(c.data(), c.data() + c.size() + 1, c.data() + c.capacity() + 1) != 0;
   else
-    return __sanitizer_verify_contiguous_container(c.data(), c.data() + c.capacity() + 1, c.data() + c.capacity() + 1) != 0;
+    return __sanitizer_verify_contiguous_container(
+               c.data(), c.data() + c.capacity() + 1, c.data() + c.capacity() + 1) != 0;
 }
 #else
 #  include <string>

``````````

</details>


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


More information about the libcxx-commits mailing list