[all-commits] [llvm/llvm-project] 2fa1be: [ASan][libcxx] A way to turn off annotations for c...

Tacet via All-commits all-commits at lists.llvm.org
Thu May 4 14:17:46 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2fa1bec7a20bb23f2e6620085adb257dafaa3be0
  Author: Advenam Tacet <advenam.tacet at trailofbits.com>
  Date:   2023-05-04 (Thu, 04 May 2023)

  Changed paths:
    M libcxx/docs/UsingLibcxx.rst
    M libcxx/include/__memory/allocator_traits.h

  Log Message:
  [ASan][libcxx] A way to turn off annotations for containers with a specific allocator

This revision is part of our efforts to support container annotations with (almost) every allocator.
That patch is necessary to enable support for most annotations (D136765). Without a way to turn off annotations, it's hard to use ASan with area allocators (no calls to destructors).

This is an answer to a request about it. This patch provides a solution to the aforementioned issue by introducing a new template structure `__asan_annotate_container_with_allocator`, which allows the disabling of container annotations for a specific allocator.


To turn off annotations, it is sufficient to create a template specialization with a false value using a [Unary Type Trait](https://en.cppreference.com/w/cpp/types/integral_constant).

The proposed structure is being used in the code enabling annotations for all allocators in `std::vector`, `std::basic_string`, and `std::deque`. (D136765 D146214 D146815)

Possibility to do it was added to ASan API in rGdd1b7b797a116eed588fd752fbe61d34deeb24e4 commit.

For context on not calling a destructor, look at https://eel.is/c++draft/basic.life#5 and notes there, you may also read a discussion in D136765.

Reviewed By: ldionne, philnik, #libc, hans

Spies: EricWF, mikhail.ramalho, #sanitizers, libcxx-commits, hans, vitalybuka

Differential Revision: https://reviews.llvm.org/D145628

More information about the All-commits mailing list