llvm-project/clang/unittests/Tooling
Sam McCall a7691dee2d [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
2022-04-21 21:46:45 +02:00
..
RecursiveASTVisitorTests [RGT] Use GTEST_SKIP instead of just returning 2022-04-08 12:20:20 -07:00
Syntax [Testing] Drop clangTesting from clang's public library interface 2022-04-20 13:28:44 +02:00
ASTSelectionTest.cpp
CMakeLists.txt [Testing] TestAST, a helper for writing straight-line AST tests 2022-04-21 21:46:45 +02:00
CastExprTest.cpp Ignore FullExpr when traversing cast sub-expressions 2022-03-21 15:05:53 -04:00
CommentHandlerTest.cpp
CompilationDatabaseTest.cpp Revert "Rename llvm::array_lengthof into llvm::size to match std::size from C++17" 2022-01-26 16:55:53 +01:00
DependencyScannerTest.cpp [clang][deps] Ensure filesystem cache consistency 2022-01-21 13:04:25 +01:00
DiagnosticsYamlTest.cpp Remark was added to clang tooling Diagnostic 2021-05-24 11:21:44 -04:00
ExecutionTest.cpp
FixItTest.cpp [Testing] TestAST, a helper for writing straight-line AST tests 2022-04-21 21:46:45 +02:00
HeaderIncludesTest.cpp [clangd] Crash in __memcmp_avx2_movbe 2022-02-10 09:40:44 -08:00
LexicallyOrderedRecursiveASTVisitorTest.cpp
LookupTest.cpp [clang] Adjust LookupTest for UsingTypeLocs 2022-03-07 16:22:03 +01:00
QualTypeNamesTest.cpp [AST] Add more testcases to QualTypeNamesTest. NFC 2021-12-15 21:59:54 +01:00
RangeSelectorTest.cpp Widen `name` stencil to support `TypeLoc` nodes. 2021-05-13 23:23:12 +01:00
RecursiveASTVisitorTestDeclVisitor.cpp
RecursiveASTVisitorTestPostOrderVisitor.cpp [ADT] Remove APInt/APSInt toString() std::string variants 2021-06-11 13:19:15 +01:00
RecursiveASTVisitorTestTypeLocVisitor.cpp
RefactoringActionRulesTest.cpp
RefactoringCallbacksTest.cpp Remove references to the ast_type_traits namespace 2020-12-11 00:58:46 +01:00
RefactoringTest.cpp Support: Use sys::path::is_style_{posix,windows}() in a few places 2021-10-29 12:09:41 -07:00
ReplacementTest.h
ReplacementsYamlTest.cpp [yaml][clang-tidy] Fix multiline YAML serialization 2020-07-09 02:41:58 -07:00
RewriterTest.cpp
RewriterTestContext.h Tooling: Migrate some tests to FileEntryRef, NFC 2020-12-10 18:05:03 -08:00
SourceCodeBuildersTest.cpp [libTooling] Adds more support for constructing object access expressions. 2022-01-25 19:43:36 +00:00
SourceCodeTest.cpp [clang][AST] Handle overload callee type in CallExpr::getCallReturnType. 2021-04-12 09:44:17 +02:00
StandardLibraryTest.cpp [Testing] TestAST, a helper for writing straight-line AST tests 2022-04-21 21:46:45 +02:00
StencilTest.cpp [RGT] StencilTest: Fix an assertion 2022-03-18 14:13:41 -07:00
TestVisitor.h
ToolingTest.cpp Move TargetRegistry.(h|cpp) from Support to MC 2021-10-08 14:51:48 -07:00
TransformerTest.cpp [libTooling] Fix indentation. NFC. 2022-03-28 18:34:45 +00:00