In nothrow new-expressions, null-check the result if we're going to
apply sanitizers to it.
This avoids a sanitizer false positive that we are initializing a null
pointer.
llvm-svn: 350779
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index fabbb4c..884ce96 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1656,9 +1656,10 @@
// Emit a null check on the allocation result if the allocation
// function is allowed to return null (because it has a non-throwing
// exception spec or is the reserved placement new) and we have an
- // interesting initializer.
+ // interesting initializer will be running sanitizers on the initialization.
bool nullCheck = E->shouldNullCheckAllocation() &&
- (!allocType.isPODType(getContext()) || E->hasInitializer());
+ (!allocType.isPODType(getContext()) || E->hasInitializer() ||
+ sanitizePerformTypeCheck());
llvm::BasicBlock *nullCheckBB = nullptr;
llvm::BasicBlock *contBB = nullptr;