johannes added a comment.

In https://reviews.llvm.org/D37383#858905, @teemperor wrote:

> @arphaman I suggested tablegen in https://reviews.llvm.org/D36664 because I 
> remembered we had some CMake sanity check about not having an *.inc in our 
> include dir: 
> https://github.com/llvm-mirror/clang/blob/master/CMakeLists.txt#L266 Not sure 
> if it actually fires for our case, but it looks like it does.


Yes, that was the issue why it didn't work under include/. I think the sanity 
check could be removed, since in-source builds are forbidden anyway.
Or maybe it is still useful by telling us that .inc is probably an generated 
file (most, but not all of them are generated, it seems), so another solution 
would be to just change the file extension. Actually, `.def` might be the right 
extension.

Shall we move to using TableGen only when we need it, and rename it to `.def` 
for now?
A preprocessor-only solution for the two modes could look like this:

user:

  #define DERIVED MyStmtVisitor
  #define SINGLE_TU
  #include "clang/AST/StmtDataCollectors.def"

StmtDataCollectors.def:

  #define DEF_VISIT(CLASS, CODE)\
      template <class = void> void Visit##CLASS(const CLASS *S) {\
        CODE;\
        ConstStmtVisitor<##DERIVED>::Visit##CLASS(S)\
      }
  
  #ifdef SINGLE_TU
  #define DEF_ADD_DATA(CLASS, COMMON, SINGLE, CROSS) DEF_VISIT(CLASS, COMMON; 
SINGLE)
  #else
  #define DEF_ADD_DATA(CLASS, COMMON, SINGLE, CROSS) DEF_VISIT(CLASS, COMMON, 
CROSS)
  #endif
  
  DEF_ADD_DATA(Stmt, .., .., ..)
  ...

However, I think TableGen has an advantage when we can extract some structure 
instead of just storing the code. Basically, a list of primitive and one of 
pointer members for each class could simplify things.


https://reviews.llvm.org/D37383



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to