diff options
-rw-r--r-- | clang/lib/CodeGen/ItaniumCXXABI.cpp | 3 | ||||
-rw-r--r-- | clang/test/CodeGen/address-sanitizer-and-array-cookie.cpp | 10 |
2 files changed, 3 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index bfb18aee2e6..c375b82ea93 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -1847,7 +1847,8 @@ Address ItaniumCXXABI::InitializeArrayCookie(CodeGenFunction &CGF, llvm::Instruction *SI = CGF.Builder.CreateStore(NumElements, NumElementsPtr); // Handle the array cookie specially in ASan. - if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0) { + if (CGM.getLangOpts().Sanitize.has(SanitizerKind::Address) && AS == 0 && + expr->getOperatorNew()->isReplaceableGlobalAllocationFunction()) { // The store to the CookiePtr does not need to be instrumented. CGM.getSanitizerMetadata()->disableSanitizerForInstruction(SI); llvm::FunctionType *FTy = diff --git a/clang/test/CodeGen/address-sanitizer-and-array-cookie.cpp b/clang/test/CodeGen/address-sanitizer-and-array-cookie.cpp index 90b6ad0e051..ea895377891 100644 --- a/clang/test/CodeGen/address-sanitizer-and-array-cookie.cpp +++ b/clang/test/CodeGen/address-sanitizer-and-array-cookie.cpp @@ -7,7 +7,7 @@ namespace std { std::nothrow_t nothrow; } void *operator new[](size_t, const std::nothrow_t &) throw(); -void *operator new[](size_t, void *); +void *operator new[](size_t, char *); struct C { int x; @@ -53,11 +53,3 @@ C *CallPlacementNew() { } // ASAN-LABEL: CallPlacementNew // ASAN-NOT: __asan_poison_cxx_array_cookie - -void *operator new[](size_t n, int); - -C *CallNewWithArgs() { -// ASAN-LABEL: CallNewWithArgs -// ASAN: call void @__asan_poison_cxx_array_cookie - return new (123) C[20]; -} |