[cfe-commits] [PATCH] Add a new ast-test AST testing mechanism

Douglas Gregor dgregor at apple.com
Sun Mar 6 09:54:14 PST 2011


On Mar 5, 2011, at 12:23 AM, John Wiegley wrote:

> This patch authored by Eric Niebler.
> 
> Creates a new executable during the build called 'ast-test', which parses
> code and allows expectations to be stated about particular structures within
> the AST.  For example:
> 
>  // RUN: %ast_test %s
> 
>  int i; // expected-decl-type{{int}}
> 
> There are many different AST nodes that be directly tested in this way.  At
> present, the full list is in tools/ast-test/main.cpp, in the function
> ParseDirective, but proper documentation is to be provided in a subsequent
> patch.
> 
> We rely on this functionality to guarantee that the AST for particular
> features meets a certain requirement, as sometimes the lack or presence
> of a diagnostic is not suitably indicative.


I think this is really cool. My only top-level concern is that I'd rather not add another executable, since each one takes *forever* to link. Why not introduce this as a separate action at the clang -cc1 level, e.g., -verify-ast? 

  - Doug



More information about the cfe-commits mailing list