//===--- TestAST.h - Build clang ASTs for testing -------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // In normal operation of Clang, the FrontendAction's lifecycle both creates // and destroys the AST, and code should operate on it during callbacks in // between (e.g. via ASTConsumer). // // For tests it is often more convenient to parse an AST from code, and keep it // alive as a normal local object, with assertions as straight-line code. // TestAST provides such an interface. // (ASTUnit can be used for this purpose, but is a production library with // broad scope and complicated API). // //===----------------------------------------------------------------------===// #ifndef LLVM_CLANG_TESTING_TESTAST_H #define LLVM_CLANG_TESTING_TESTAST_H #include "clang/Basic/LLVM.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Testing/CommandLineArgs.h" #include "llvm/ADT/StringRef.h" #include <string> #include <vector> namespace clang { /// Specifies a virtual source file to be parsed as part of a test. struct TestInputs { … }; /// The result of parsing a file specified by TestInputs. /// /// The ASTContext, Sema etc are valid as long as this object is alive. class TestAST { … }; } // end namespace clang #endif