[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:58:33 PST 2017
timshen updated this revision to Diff 86377.
timshen added a comment.
ActOnFinishFullExpr after exiting the expression evaluation context.
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,8 +4589,15 @@
if (ElementType.isNull())
return QualType();
- ExprResult SizeResult
- = getDerived().TransformExpr(T->getSizeExpr());
+ ExprResult SizeResult;
+ {
+ EnterExpressionEvaluationContext Context(SemaRef,
+ Sema::PotentiallyEvaluated);
+ SizeResult = getDerived().TransformExpr(T->getSizeExpr());
+ }
+ if (SizeResult.isInvalid())
+ return QualType();
+ SizeResult = SemaRef.ActOnFinishFullExpr(SizeResult.get());
if (SizeResult.isInvalid())
return QualType();
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: finishing the function body while in an expression evaluation
+ // context seems wrong. Investigate more.
ActOnFinishFunctionBody(Function, Body.get(),
/*IsInstantiation=*/true);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24333.86377.patch
Type: text/x-patch
Size: 1856 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170131/14f7601e/attachment.bin>
More information about the cfe-commits
mailing list