[cfe-commits] [PATCH] Sema and AST for C++0x Lambda Expressions

John Freeman jfreeman at cse.tamu.edu
Tue Nov 15 22:45:57 PST 2011


I finished integrating your LambdaScopeInfo changes with my work since 
my last patch submission. Divergent branches aren't fun. :/

I saw you switched from using CheckFieldDecl to directly using 
FieldDecl::Create. Was that intentional? I had the impression that the 
extra semantic checking was preferred. Same question about switching 
from ActOnIdExpression to directly using name lookup.

A few problems concerning the CXXMethodDecl (henceforth called Method):

A. I was trying to use ActOnStartOfFunctionDef to enter the DeclContext 
owned by Method. You had used PushDeclContext directly. I believe that 
will be necessary to avoid creating an extraneous FunctionScopeInfo, but 
do we want any of the extra checking in ActOnStartOfFunctionDef?

B. A conundrum:

- PushDeclContext requires that the lexical DeclContext for Method be 
CurContext.
- CXXRecordDecl::addDecl requires that the lexical DeclContext for 
Method be the CXXRecordDecl (henceforth called Class).

How about this solution? :

1. Method.setLexicalDeclContext(CurContext).
2. PushDeclContext.
3. Add Method to the LambdaScopeInfo so that it can be retrieved later 
(we can't look it up in Class because we haven't called addDecl yet).

4. Parse body.

5. Retrieve Method from the LambdaScopeInfo.
6. ActOnFinishFunctionBody (calls PopDeclContext).
7. Method.setLexicalDeclContext(Class).
8. Class.addDecl(Method).


C. In a similar question to part A on ActOnStartOfFunctionDef vs 
PushDeclContext, concerning step 6 above, do we want to use 
PopDeclContext directly instead of ActOnFinishFunctionBody, or do we 
want the extra semantic checks?


- John



More information about the cfe-commits mailing list