[libcxx-commits] [libcxx] [ASan][libc++] String annotations optimizations fix with lambda (PR #76200)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Fri Dec 22 11:18:03 PST 2023


================
@@ -922,7 +922,10 @@ public:
       // Turning off ASan instrumentation for variable initialization with _LIBCPP_STRING_INTERNAL_MEMORY_ACCESS
       // does not work consistently during initialization of __r_, so we instead unpoison __str's memory manually first.
       // __str's memory needs to be unpoisoned only in the case where it's a short string.
-      : __r_(((__str.__is_long() ? 0 : (__str.__annotate_delete(), 0)), std::move(__str.__r_))) {
+      // Lambda is used because of optimization challenges encountered within comma constructors.
+      // Lambda with argument is correctly optimized, but it does not solve the problem with internal memory
+      // access macro.
----------------
ldionne wrote:

IMO this comment doesn't add information we want to retain in the code, and I would remove it. I think this kind of information is best found in the commit message.

https://github.com/llvm/llvm-project/pull/76200


More information about the libcxx-commits mailing list