diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h index 4cf1de488c7bde..c0bc30c7450fe4 100644 --- a/llvm/include/llvm/ADT/FunctionExtras.h +++ b/llvm/include/llvm/ADT/FunctionExtras.h @@ -35,6 +35,7 @@ #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/ADT/STLForwardCompat.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/MemAlloc.h" #include "llvm/Support/type_traits.h" #include @@ -317,8 +318,10 @@ template class UniqueFunctionBase { // Clear the old callback and inline flag to get back to as-if-null. RHS.CallbackAndInlineFlag = {}; -#ifndef NDEBUG - // In debug builds, we also scribble across the rest of the storage. +#if !defined(NDEBUG) && !LLVM_ADDRESS_SANITIZER_BUILD + // In debug builds without ASan, we also scribble across the rest of the + // storage. Scribbling under AddressSanitizer (ASan) is disabled to prevent + // overwriting poisoned objects (e.g., annotated short strings). memset(RHS.getInlineStorage(), 0xAD, InlineStorageSize); #endif }