DR1748: the reserved placement allocation functions have undefined behavior if
they're given a null pointer as an argument, so we do not need to emit null
checks on their results.
llvm-svn: 229213
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index fd25b58..1f54d24 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -208,8 +208,9 @@
}
bool CXXNewExpr::shouldNullCheckAllocation(const ASTContext &Ctx) const {
- return getOperatorNew()->getType()->
- castAs<FunctionProtoType>()->isNothrow(Ctx);
+ return getOperatorNew()->getType()->castAs<FunctionProtoType>()->isNothrow(
+ Ctx) &&
+ !getOperatorNew()->isReservedGlobalPlacementOperator();
}
// CXXDeleteExpr