[cfe-dev] top level decls

Chris Lattner clattner at apple.com
Fri Nov 30 09:39:09 PST 2007


Ted and Steve,

The recent work to make the top level decl streamer interface  
(ASTConsumer) more sane got me wondering.  How are we going to handle C 
++ and ObjC features with it?

Consider:

namespace foo {
   int x; int y;
}

Will that be returned as  a single top-level decl for the whole  
namespace?  If so, that means that the entire body of some large STL  
headers will be a single top-level decl.  Given a choice, I'd prefer  
to know first that there was a namespace, then that there was x, then  
that there was y.

A similar problem happens with methods (either C++ or objc).  Also, c+ 
+ can have nested classes of course.


I'm starting to think that a pull interface for decls doesn't really  
work well.  Maybe we should change Sema to take an ASTConsumer object  
and have it push decls into the ASTConsumer, instead of fully  
returning out of the parser to return a decl.  The big problem with  
this is that it makes it harder to stop the parser at an arbitrary  
point.  We'd have to add explicit code to handle this.

Thoughts?

-Chris



More information about the cfe-dev mailing list