Making Sema public


   I need to do some "not standard" stuff while parsing and to get the
thing done I need to play a little with Sema's IdResolver. Would you
mind making Sema public and moving Sema.h (and it's dependencies) from
lib/Sema to include/clang/Sema?


I'd prefer not to, but could be convinced. What sorts of crazy things do you want to do?


I have a set of function declarations given as a vector of
FunctionDecl objects. The set is dynamic, I mean its contents depend
on the previous activity of the user. The code being parsed may call
any of these functions. I need to make the parser to insert correct
DeclRefExpr nodes when it encouters a function call so that I could
later codegen the AST and link the resulting module to another module
actually holding the definitions of these functions.

   For example the following code is to be parsed:

#include <stdio.h>

int main( int argc, char** argv ) {
  printf( "The result: %s\n", doSomething( argv[0] ) );
  return 0;

  And I have: "char* doSomething( const char* input );" given as a FunctionDecl.


hi Luckasz,

This is somewhat similar to how we synthesize builtins dynamically (see what happens when you use something like __builtin_bswap32 or something). I'd be ok with adding a top-level hook that does a virtual method call to do a "last chance" resolution if normal lookup fails. Would this work for you?


Hi Chris,

   I am not really sure where you want to add this kind of method...
One could probably add a possibility of registering a callback
function with a Preprocessor. Anyways, the "last chance" resolution is
not really what I need. You would have to call my function in every
scope being searched even if you find something (since my identifier
may be a better match for a call) and this may be too big a price to
be paid in terms of the execution time.

   My goal is not to make Sema public but to have a possibility of
merging two translation units. I think you need to find a way to do
that anyways if you want to have the precompled headers functionality
working. In that case also the code generation will have to be
decoupled from Sema (I mean the ASTConsumer::HandleTagDeclDefinition
callback) but that could be probably easily implemented by having a
sort of tag nodes in the AST telling the consumer that a certain state
has been reached. Should I go ahead and implement the latter? What do
we do about the merging of AST?