[libcxx-commits] [PATCH] D147680: [ASan][libc++] Turn on ASan annotations for short strings

Tacet via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Wed Apr 5 22:39:11 PDT 2023


AdvenamTacet created this revision.
AdvenamTacet added a reviewer: philnik.
Herald added a project: All.
AdvenamTacet requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

This patch turns on ASan annotations for short strings.

Revision D132769 <https://reviews.llvm.org/D132769> adds ASan annotations for strings, but annotations for short strings are turned off.
An implementation from there is correct for both string types and support for the later may be easily turned on.
This revision does it.

Reasoning behind moving it here, to a different revision:

- Long string annotations (with the default allocator only) work with old ASan API.
- Short string annotations requires new ASan API (added in rGdd1b7b797a116eed588fd752fbe61d34deeb24e4 <https://reviews.llvm.org/rGdd1b7b797a116eed588fd752fbe61d34deeb24e4>).
- If someone reports a problem with string annotations, it makes it much easier to know which patch exactly caused the problem.
- Long string is almost same as std::vector, so chance for a problem with D132769 <https://reviews.llvm.org/D132769> is minimal.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D147680

Files:
  libcxx/include/string


Index: libcxx/include/string
===================================================================
--- libcxx/include/string
+++ libcxx/include/string
@@ -618,7 +618,12 @@
 #else
 #  define _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
 #endif
-#define _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED false
+#if (_LIBCPP_CLANG_VER >= 1600)
+// TODO LLVM18: Remove special casing or macro
+#  define _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED true
+#else
+#  define _LIBCPP_SHORT_STRING_ANNOTATIONS_ALLOWED false
+#endif
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147680.511279.patch
Type: text/x-patch
Size: 534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230406/92120eb6/attachment.bin>


More information about the libcxx-commits mailing list