[PATCH] D24333: [CleanupInfo] Use cleanupsHaveSideEffects instead of exprNeedsCleanups in assertions
Tim Shen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jan 30 17:46:40 PST 2017
timshen updated this revision to Diff 86375.
timshen added a comment.
Fix in the right way as rsmith pointed out.
https://reviews.llvm.org/D24333
Files:
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/test/Sema/pr30306.cpp
Index: clang/test/Sema/pr30306.cpp
===================================================================
--- /dev/null
+++ clang/test/Sema/pr30306.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -x c++ -emit-llvm < %s | FileCheck %s
+
+struct A { A(int); ~A(); };
+int f(const A &);
+// CHECK: call void @_ZN1AC1Ei
+// CHECK-NEXT: call i32 @_Z1fRK1A
+// CHECK-NEXT: call void @_ZN1AD1Ev
+// CHECK: call void @_ZN1AC1Ei
+// CHECK-NEXT: call i32 @_Z1fRK1A
+// CHECK-NEXT: call void @_ZN1AD1Ev
+template<typename T> void g() {
+ int a[f(3)];
+ int b[f(3)];
+}
+int main() { g<int>(); }
Index: clang/lib/Sema/TreeTransform.h
===================================================================
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -4589,12 +4589,18 @@
if (ElementType.isNull())
return QualType();
- ExprResult SizeResult
- = getDerived().TransformExpr(T->getSizeExpr());
- if (SizeResult.isInvalid())
- return QualType();
-
- Expr *Size = SizeResult.get();
+ Expr *Size;
+ {
+ EnterExpressionEvaluationContext Context(SemaRef,
+ Sema::PotentiallyEvaluated);
+ ExprResult SizeResult = getDerived().TransformExpr(T->getSizeExpr());
+ if (SizeResult.isInvalid())
+ return QualType();
+ SizeResult = SemaRef.ActOnFinishFullExpr(SizeResult.get());
+ if (SizeResult.isInvalid())
+ return QualType();
+ Size = SizeResult.get();
+ }
QualType Result = TL.getType();
if (getDerived().AlwaysRebuild() ||
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -3858,6 +3858,8 @@
if (Body.isInvalid())
Function->setInvalidDecl();
+ // FIXME: Exit expression evaluation context before finishing the function
+ // body.
ActOnFinishFunctionBody(Function, Body.get(),
/*IsInstantiation=*/true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24333.86375.patch
Type: text/x-patch
Size: 2032 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170131/bcbd26a0/attachment.bin>
More information about the cfe-commits
mailing list