<p dir="ltr">LGTM</p>
<div class="gmail_quote">On 15 Dec 2014 11:28, "Reid Kleckner" <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi rsmith,<br>
<br>
Previously we would attempt to build a TypeSourceInfo for a null type,<br>
and then we would forget to pop the function scope before returning an<br>
error.<br>
<br>
<a href="http://reviews.llvm.org/D6665" target="_blank">http://reviews.llvm.org/D6665</a><br>
<br>
Files:<br>
include/clang/Sema/Sema.h<br>
lib/Sema/TreeTransform.h<br>
test/SemaCXX/lambda-expressions.cpp<br>
<br>
Index: include/clang/Sema/Sema.h<br>
===================================================================<br>
--- include/clang/Sema/Sema.h<br>
+++ include/clang/Sema/Sema.h<br>
@@ -3101,6 +3101,18 @@<br>
Sema &S;<br>
};<br>
<br>
+ /// An RAII helper that pops function a function scope on exit.<br>
+ struct FunctionScopeRAII {<br>
+ Sema &S;<br>
+ bool Active;<br>
+ FunctionScopeRAII(Sema &S) : Active(true), S(S) {}<br>
+ ~FunctionScopeRAII() {<br>
+ if (Active)<br>
+ S.PopFunctionScopeInfo();<br>
+ }<br>
+ void disable() { Active = false; }<br>
+ };<br>
+<br>
StmtResult ActOnDeclStmt(DeclGroupPtrTy Decl,<br>
SourceLocation StartLoc,<br>
SourceLocation EndLoc);<br>
Index: lib/Sema/TreeTransform.h<br>
===================================================================<br>
--- lib/Sema/TreeTransform.h<br>
+++ lib/Sema/TreeTransform.h<br>
@@ -9121,6 +9121,8 @@<br>
}<br>
<br>
LambdaScopeInfo *LSI = getSema().PushLambdaScope();<br>
+ Sema::FunctionScopeRAII FuncScopeCleanup(getSema());<br>
+<br>
// Transform the template parameters, and add them to the current<br>
// instantiation scope. The null case is handled correctly.<br>
LSI->GLTemplateParameterList = getDerived().TransformTemplateParameterList(<br>
@@ -9145,10 +9147,10 @@<br>
return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,<br>
ExceptionStorage, Changed);<br>
});<br>
+ if (NewCallOpType.isNull())<br>
+ return ExprError();<br>
NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,<br>
NewCallOpType);<br>
- if (!NewCallOpTSI)<br>
- return ExprError();<br>
}<br>
<br>
// Create the local class that will describe the lambda.<br>
@@ -9168,6 +9170,10 @@<br>
<br>
getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);<br>
<br>
+ // TransformLambdaScope will manage the function scope, so we can disable the<br>
+ // cleanup.<br>
+ FuncScopeCleanup.disable();<br>
+<br>
return getDerived().TransformLambdaScope(E, NewCallOperator,<br>
InitCaptureExprsAndTypes);<br>
}<br>
Index: test/SemaCXX/lambda-expressions.cpp<br>
===================================================================<br>
--- test/SemaCXX/lambda-expressions.cpp<br>
+++ test/SemaCXX/lambda-expressions.cpp<br>
@@ -425,3 +425,17 @@<br>
}<br>
template void g<int>();<br>
}<br>
+<br>
+namespace error_in_transform_prototype {<br>
+ template<class T><br>
+ void f(T t) {<br>
+ // expected-error@+2 {{type 'int' cannot be used prior to '::' because it has no members}}<br>
+ // expected-error@+1 {{no member named 'ns' in 'error_in_transform_prototype::S'}}<br>
+ auto x = [](typename T::ns::type &k) {};<br>
+ }<br>
+ class S {};<br>
+ void foo() {<br>
+ f(5); // expected-note {{requested here}}<br>
+ f(S()); // expected-note {{requested here}}<br>
+ }<br>
+}<br>
<br>
EMAIL PREFERENCES<br>
<a href="http://reviews.llvm.org/settings/panel/emailpreferences/" target="_blank">http://reviews.llvm.org/settings/panel/emailpreferences/</a><br>
</blockquote></div>