//===--- TestTU.h - Scratch source files for testing -------------*- C++-*-===// // // 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 // //===----------------------------------------------------------------------===// // // Many tests for indexing, code completion etc are most naturally expressed // using code examples. // TestTU lets test define these examples in a common way without dealing with // the mechanics of VFS and compiler interactions, and then easily grab the // AST, particular symbols, etc. // //===---------------------------------------------------------------------===// #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTTU_H #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTTU_H #include "../TidyProvider.h" #include "Compiler.h" #include "FeatureModule.h" #include "ParsedAST.h" #include "TestFS.h" #include "index/Index.h" #include "llvm/ADT/StringMap.h" #include <memory> #include <string> #include <utility> #include <vector> namespace clang { namespace clangd { struct TestTU { … }; // Look up an index symbol by qualified name, which must be unique. const Symbol &findSymbol(const SymbolSlab &, llvm::StringRef QName); // Look up an AST symbol by qualified name, which must be unique and top-level. const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName); // Look up an AST symbol that satisfies \p Filter. const NamedDecl &findDecl(ParsedAST &AST, std::function<bool(const NamedDecl &)> Filter); // Look up an AST symbol by unqualified name, which must be unique. const NamedDecl &findUnqualifiedDecl(ParsedAST &AST, llvm::StringRef Name); } // namespace clangd } // namespace clang #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTTU_H