summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2017-02-13 23:49:55 +0000
committerNick Lewycky <nicholas@mxc.ca>2017-02-13 23:49:55 +0000
commit075276218096f0386590a1eaff1e742b4264d75c (patch)
tree6385d4239b3c2fb416741ce100d171b7a4a17c2b /clang/lib/CodeGen/CGExprCXX.cpp
parent47a8b6829c716aaf21b2173e71e05f5ff409cad0 (diff)
downloadbcm5719-llvm-075276218096f0386590a1eaff1e742b4264d75c.tar.gz
bcm5719-llvm-075276218096f0386590a1eaff1e742b4264d75c.zip
When the new expr's array size is an ICE, emit it as a constant expression.
This bypasses integer sanitization checks which are redundant on the expression since it's been checked by Sema. Fixes a clang codegen assertion on "void test() { new int[0+1]{0}; }" when building with -fsanitize=signed-integer-overflow. llvm-svn: 295006
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 71c8fb8b7ae..ebe0841b3c2 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -659,7 +659,10 @@ static llvm::Value *EmitCXXNewAllocSize(CodeGenFunction &CGF,
// Emit the array size expression.
// We multiply the size of all dimensions for NumElements.
// e.g for 'int[2][3]', ElemType is 'int' and NumElements is 6.
- numElements = CGF.EmitScalarExpr(e->getArraySize());
+ numElements = CGF.CGM.EmitConstantExpr(e->getArraySize(),
+ CGF.getContext().getSizeType(), &CGF);
+ if (!numElements)
+ numElements = CGF.EmitScalarExpr(e->getArraySize());
assert(isa<llvm::IntegerType>(numElements->getType()));
// The number of elements can be have an arbitrary integer type;
OpenPOWER on IntegriCloud