[PATCH] Allow return type deduction for templates in delayed parsing mode.

Faisal Vali faisalv at yahoo.com
Tue Oct 29 17:53:19 PDT 2013



================
Comment at: lib/Parse/Parser.cpp:926-929
@@ +925,6 @@
+    return false;
+  for (unsigned I = 0, E = D.getNumTypeObjects(); I != E; ++I) {
+    unsigned chunkIndex = E - I - 1;
+    const DeclaratorChunk &DeclType = D.getTypeObject(chunkIndex);
+    if (DeclType.Kind == DeclaratorChunk::Function) {
+      const DeclaratorChunk::FunctionTypeInfo &FTI = DeclType.Fun;
----------------
Richard Smith wrote:
> Can you add some more difficult test cases for this (where the order in which we visit the objects matter), like:
> 
>   auto F() -> auto * { return (int*)0; }
>   auto (*G())() -> int * { return F; }
Done.

================
Comment at: lib/Parse/Parser.cpp:1014-1015
@@ -994,3 +1013,4 @@
       TemplateInfo.Kind == ParsedTemplateInfo::Template &&
-      !D.getDeclSpec().isConstexprSpecified()) {
+      !D.getDeclSpec().isConstexprSpecified() && 
+      !isFunctionDeclaratorRequiringReturnTypeDeduction(D)) {
     MultiTemplateParamsArg TemplateParameterLists(*TemplateInfo.TemplateParams);
----------------
Richard Smith wrote:
> Can you make this use something like `Sema::canSkipFunctionBody` instead?
I can have the code in ParseCXXInlineMethods use canSkipFunctionBody - but over here I am not sure how to do that since all i have at this point to work with is the Declarator (the Action.HandleDeclarator has not been called - can I call this early, won't it interfere with the ActOnStartofFunction[Template]Def?


http://llvm-reviews.chandlerc.com/D2053



More information about the cfe-commits mailing list