Skip to content
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

[ASan] Disable annotations on unsupported platforms #4058

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions stl/inc/__msvc_sanitizer_annotate_container.hpp
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,28 @@ _STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new

#if !defined(_M_CEE_PURE) && !(defined(_DISABLE_STRING_ANNOTATION) && defined(_DISABLE_VECTOR_ANNOTATION))
#ifdef _DISABLE_ASAN_ANNOTATIONS

#ifdef _ENABLE_ASAN_ANNOTATIONS_ON_UNSUPPORTED_PLATFORMS
#error \
"Invalid set of defines - one cannot define both _ENABLE_ASAN_ANNOTATIONS_ON_UNSUPPORTED_PLATFORMS and _DISABLE_ASAN_ANNOTATIONS at the same time"
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved
#endif
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved

#else // ^^^ _DISABLE_ASAN_ANNOTATIONS / !_DISABLE_ASAN_ANNOTATIONS vvv

#if defined(_DISABLE_STRING_ANNOTATION) && defined(_DISABLE_VECTOR_ANNOTATION)
#define _DISABLE_ASAN_ANNOTATIONS
#elif defined(_M_ARM64EC) || defined(_M_ARM64) || defined(_M_ARM)

#ifndef _ENABLE_ASAN_ANNOTATIONS_ON_UNSUPPORTED_PLATFORMS
#define _DISABLE_ASAN_ANNOTATIONS
#endif

#elif defined(_M_CEE_PURE)
#define _DISABLE_ASAN_ANNOTATIONS
#endif

#endif // ^^^ !_DISABLE_ASAN_ANNOTATIONS
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved

#ifdef __SANITIZE_ADDRESS__

Expand Down Expand Up @@ -45,11 +66,11 @@ _STL_DISABLE_CLANG_WARNINGS

#endif // ^^^ !defined(__clang__) && !defined(__SANITIZE_ADDRESS__) ^^^

#ifdef _DISABLE_STRING_ANNOTATION
#if defined(_DISABLE_ASAN_ANNOTATION) || defined(_DISABLE_STRING_ANNOTATION)
#undef _ACTIVATE_STRING_ANNOTATION
#undef _INSERT_STRING_ANNOTATION
#endif // defined(_DISABLE_STRING_ANNOTATION)
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved
#ifdef _DISABLE_VECTOR_ANNOTATION
#if defined(_DISABLE_ASAN_ANNOTATION) || defined(_DISABLE_VECTOR_ANNOTATION)
#undef _ACTIVATE_VECTOR_ANNOTATION
#undef _INSERT_VECTOR_ANNOTATION
#endif // defined(_DISABLE_VECTOR_ANNOTATION)
strega-nil-ms marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -123,8 +144,6 @@ void __cdecl __sanitizer_annotate_contiguous_container(

#endif // insert asan annotations

#endif // !defined(_M_CEE_PURE) && asan not disabled

#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
Expand Down