Skip to content

[libc++][ASan] Removing clang version checks #71673

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
merged 1 commit into from
Nov 9, 2023

Conversation

AdvenamTacet
Copy link
Member

This commit removes checks like _LIBCPP_CLANG_VER >= 1600 related to ASan annotations. As only 2 previous versions are supported, it's a TODO for LLVM18.

_LIBCPP_CLANG_VER is referenced in two more places (not related to ASan), I'm not sure if we should update it in the same PR.

# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400

// Warn if a compiler version is used that is not supported anymore
// LLVM RELEASE Update the minimum compiler versions
# if defined(_LIBCPP_CLANG_VER)
# if _LIBCPP_CLANG_VER < 1500
# warning "Libc++ only supports Clang 15 and later"
# endif
# elif defined(_LIBCPP_APPLE_CLANG_VER)
# if _LIBCPP_APPLE_CLANG_VER < 1500
# warning "Libc++ only supports AppleClang 15 and later"
# endif
# elif defined(_LIBCPP_GCC_VER)
# if _LIBCPP_GCC_VER < 1300
# warning "Libc++ only supports GCC 13 and later"
# endif
# endif

This commit removes checks like `_LIBCPP_CLANG_VER >= 1600` related to ASan annotations.
@AdvenamTacet AdvenamTacet requested a review from a team as a code owner November 8, 2023 12:57
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Nov 8, 2023
@AdvenamTacet AdvenamTacet self-assigned this Nov 8, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2023

@llvm/pr-subscribers-libcxx

Author: Tacet (AdvenamTacet)

Changes

This commit removes checks like _LIBCPP_CLANG_VER &gt;= 1600 related to ASan annotations. As only 2 previous versions are supported, it's a TODO for LLVM18.

_LIBCPP_CLANG_VER is referenced in two more places (not related to ASan), I'm not sure if we should update it in the same PR.

# if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1400

// Warn if a compiler version is used that is not supported anymore
// LLVM RELEASE Update the minimum compiler versions
# if defined(_LIBCPP_CLANG_VER)
# if _LIBCPP_CLANG_VER < 1500
# warning "Libc++ only supports Clang 15 and later"
# endif
# elif defined(_LIBCPP_APPLE_CLANG_VER)
# if _LIBCPP_APPLE_CLANG_VER < 1500
# warning "Libc++ only supports AppleClang 15 and later"
# endif
# elif defined(_LIBCPP_GCC_VER)
# if _LIBCPP_GCC_VER < 1300
# warning "Libc++ only supports GCC 13 and later"
# endif
# endif


Full diff: https://github.com/llvm/llvm-project/pull/71673.diff

4 Files Affected:

  • (modified) libcxx/include/__config (-2)
  • (modified) libcxx/include/__memory/allocator_traits.h (+1-8)
  • (modified) libcxx/include/deque (+2-2)
  • (modified) libcxx/test/support/asan_testing.h (+1-1)
diff --git a/libcxx/include/__config b/libcxx/include/__config
index b9b20fbfb271e8e..dd93448d68e2db2 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -1073,12 +1073,10 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
 #  ifndef _LIBCPP_HAS_NO_ASAN
     extern "C" _LIBCPP_EXPORTED_FROM_ABI void
     __sanitizer_annotate_contiguous_container(const void*, const void*, const void*, const void*);
-#    if _LIBCPP_CLANG_VER >= 1600
 extern "C" _LIBCPP_EXPORTED_FROM_ABI void __sanitizer_annotate_double_ended_contiguous_container(
     const void*, const void*, const void*, const void*, const void*, const void*);
 extern "C" _LIBCPP_EXPORTED_FROM_ABI int
 __sanitizer_verify_double_ended_contiguous_container(const void*, const void*, const void*, const void*);
-#    endif
 #  endif
 
 // Try to find out if RTTI is disabled.
diff --git a/libcxx/include/__memory/allocator_traits.h b/libcxx/include/__memory/allocator_traits.h
index 4658098d64c9d08..157254619ebeda6 100644
--- a/libcxx/include/__memory/allocator_traits.h
+++ b/libcxx/include/__memory/allocator_traits.h
@@ -408,14 +408,7 @@ struct __is_cpp17_copy_insertable<_Alloc, __enable_if_t<
 
 #ifdef _LIBCPP_HAS_ASAN_CONTAINER_ANNOTATIONS_FOR_ALL_ALLOCATORS
 template <class _Alloc>
-struct __asan_annotate_container_with_allocator
-#   if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 1600
-      : true_type {};
-#   else
-      // TODO(LLVM-18): Remove the special-casing
-      : false_type {};
-#   endif
-
+struct __asan_annotate_container_with_allocator : true_type {};
 template <class _Tp>
 struct __asan_annotate_container_with_allocator<allocator<_Tp> > : true_type {};
 #endif
diff --git a/libcxx/include/deque b/libcxx/include/deque
index 6b6d8e2bdda6682..d2ddce319567166 100644
--- a/libcxx/include/deque
+++ b/libcxx/include/deque
@@ -966,7 +966,7 @@ public:
 // __asan_annotate_container_with_allocator to false.
 // For more details, see the "Using libc++" documentation page or
 // the documentation for __sanitizer_annotate_contiguous_container.
-#if !defined(_LIBCPP_HAS_NO_ASAN) && _LIBCPP_CLANG_VER >= 1600
+#if !defined(_LIBCPP_HAS_NO_ASAN)
     // TODO LLVM18: Remove the special-casing
     _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(
         const void* __beg,
@@ -982,7 +982,7 @@ public:
 #else
     _LIBCPP_HIDE_FROM_ABI void __annotate_double_ended_contiguous_container(
         const void*, const void*, const void*, const void*, const void*, const void*) const _NOEXCEPT {}
-#endif // !defined(_LIBCPP_HAS_NO_ASAN) && _LIBCPP_CLANG_VER >= 1600
+#endif // !defined(_LIBCPP_HAS_NO_ASAN)
 
     _LIBCPP_HIDE_FROM_ABI
     void __annotate_from_to(size_type __beg, size_type __end, __asan_annotation_type __annotation_type, __asan_annotation_place __place) const _NOEXCEPT {
diff --git a/libcxx/test/support/asan_testing.h b/libcxx/test/support/asan_testing.h
index d8e97af421139f2..759956ba687b46c 100644
--- a/libcxx/test/support/asan_testing.h
+++ b/libcxx/test/support/asan_testing.h
@@ -34,7 +34,7 @@ TEST_CONSTEXPR bool is_contiguous_container_asan_correct ( const std::vector<T,
 }
 #endif // TEST_HAS_FEATURE(address_sanitizer)
 
-#if TEST_HAS_FEATURE(address_sanitizer) && _LIBCPP_CLANG_VER >= 1600
+#if TEST_HAS_FEATURE(address_sanitizer)
 extern "C" int __sanitizer_verify_double_ended_contiguous_container(
     const void* beg, const void* con_beg, const void* con_end, const void* end);
 extern "C" bool __sanitizer_is_annotable(const void* address, const unsigned long size);

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the cleanup!

@ldionne ldionne merged commit 8a454e1 into llvm:main Nov 9, 2023
@ldionne
Copy link
Member

ldionne commented Nov 9, 2023

FWIW we can do the remaining _LIBCPP_CLANG_VER checks separately.

@AdvenamTacet AdvenamTacet deleted the asan-remove-version-checks branch January 22, 2024 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants