[libcxx-commits] [PATCH] D145628: [ASan][libcxx] A way to turn off annotations for containers with a specific allocator
Hans Wennborg via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Mar 21 08:15:18 PDT 2023
hans added inline comments.
================
Comment at: libcxx/docs/UsingLibcxx.rst:527
+If ``__asan_annotate_container_with_allocator<_Alloc>::value == false``, container won't be poisoned at all.
+Value may be changed by template specialization. Variable ``value`` is of type ``bool``.
+
----------------
AdvenamTacet wrote:
> hans wrote:
> > AdvenamTacet wrote:
> > > hans wrote:
> > > > Could you please include a code example which shows how to do the specialization?
> > > >
> > > > Also, will it be possible to write this in a way that works both with libc++ versions that have and don't have this change?
> > > I added examples. I hope those are helpful. If you believe that another example is necessary as well, let me know.
> > >
> > > > Also, will it be possible to write this in a way that works both with libc++ versions that have and don't have this change?
> > >
> > > Possibly a macro would be answer to that, I suggested one in an update comment. But it should be possible to solve easily with libc++ version number as well. I don't really like the idea of creating a macro here.
> > This is great, thanks!
> >
> > I'd suggest writing the example in a way that's portable, i.e. that will work both with libc++ versions which do and do not have this feature, as well as other standard libraries.
> >
> > In order to do that, I guess we'll need some kind of feature test macro. I don't think checking the libc++ version number is a good solution as it's not fine grained enough. I'm guessing libc++ has some kind of mechanism for this already similar to the standard feature test macros.
> I don't really see a good way to do it and believe that relaying on libc++ version seems the best option. If @philnik or @ldionne think that some macro should be created, I will do it. Just I have to know what macro exactly.
A version check won't work for consumers of libc++ trunk, since there are versions both with and without this template that have the same _LIBCPP_VERSION.
I think we need a macro or other feature flag, or some mechanism that works both before and after this change (instead of a class template, could we do something based on function overload resolution with the allocator type work?)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145628/new/
https://reviews.llvm.org/D145628
More information about the libcxx-commits
mailing list