diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-01-10 00:03:29 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-01-10 00:03:29 +0000 |
commit | 2f72a7521a59b3e292c342d0470ef5a6044be99a (patch) | |
tree | b3f9904bd802437e61655034b8c207f63f28c7a2 /clang/lib | |
parent | 2eeade18142c3cd076c7c012d2b7357e91b771c6 (diff) | |
download | bcm5719-llvm-2f72a7521a59b3e292c342d0470ef5a6044be99a.tar.gz bcm5719-llvm-2f72a7521a59b3e292c342d0470ef5a6044be99a.zip |
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
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index fabbb4ca54c..884ce96859c 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -1656,9 +1656,10 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) { // 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; |