[Testing] TestAST, a helper for writing straight-line AST tests
Tests that need ASTs have to deal with the awkward control flow of FrontendAction in some way. There are a few idioms used: - don't bother with unit tests, use clang -dump-ast - create an ASTConsumer by hand, which is bulky - use ASTMatchFinder - works pretty well if matchers are actually needed, very strange if they are not - use ASTUnit - this yields nice straight-line code, but ASTUnit is a terrifically complicated library not designed for this purpose TestAST provides a very simple way to write straight-line tests: specify the code/flags and it provides an AST that is kept alive until the object is destroyed. It's loosely modeled after TestTU in clangd, which we've successfully used for a variety of tests. I've updated a couple of clang tests to use this helper, IMO they're clearer. Differential Revision: https://reviews.llvm.org/D123668
Loading
Please sign in to comment