top level decls

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?


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.



This is one idea that Steve and I batted around yesterday, and it has some nice properties. Decls can be handed back to the consumer at the moment they are processed, which obviates some of the bookkeeping issues in the Parser.