[cfe-dev] Why can't library users create a Sema?

Douglas Gregor dgregor at apple.com
Tue Mar 16 15:02:56 PDT 2010


On Mar 16, 2010, at 7:20 AM, Martin C.Martin wrote:

> Hi,
> 
> I'm trying to create an AST, not by parsing a file, but by calling 
> function from within a program.  It seems reasonable to do what the 
> Clang parser does, which is creating a Sema and calling methods on it. 
> For example, create an AST for x + y by calling CreateBuiltinBinOp() and 
> BuildDeclRefExpr().
> 
> However, Sema.h isn't in the include directory, but rather the lib 
> directory, which makes me think it's not "public facing."  Is that 
> right?  If so, why?  It seems to have well defined functionality and 
> should be reusable.


Yes, that is correct. We meant for Sema to be an internal interface, because while it's functionality is well-defined at a very high level, it's details are rather messy and are very likely to change. Sema should really be split into several coordinating subclasses that isolate parser callbacks from semantic analysis from template instantiation from overloading and so on.

All that said, I'm not really opposed to making Sema.h public. It's not like our AST headers offer stable interfaces, either, it's just that Sema is even less stable.

	- Doug



More information about the cfe-dev mailing list