[ELF] Avoid make in elf::writeARMCmseImportLib
[llvm-project.git] / clang-tools-extra / clangd / unittests / TestWorkspace.h
bloba5e688d8a7d7829863a23d05910fc1457f17dd75
1 //===--- TestWorkspace.h - Utility for writing multi-file tests --*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // TestWorkspace builds on TestTU to provide a way to write tests involving
10 // several related files with inclusion relationships between them.
12 // The tests can exercise both index and AST based operations.
14 //===---------------------------------------------------------------------===//
16 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTWORKSPACE_H
17 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTWORKSPACE_H
19 #include "TestTU.h"
20 #include "index/Index.h"
21 #include "llvm/ADT/StringRef.h"
22 #include <optional>
23 #include <string>
24 #include <vector>
26 namespace clang {
27 namespace clangd {
29 class TestWorkspace {
30 public:
31 // The difference between addSource() and addMainFile() is that only main
32 // files will be indexed.
33 void addSource(llvm::StringRef Filename, llvm::StringRef Code) {
34 addInput(Filename.str(), {Code.str(), /*IsMainFile=*/false});
36 void addMainFile(llvm::StringRef Filename, llvm::StringRef Code) {
37 addInput(Filename.str(), {Code.str(), /*IsMainFile=*/true});
40 std::unique_ptr<SymbolIndex> index();
42 std::optional<ParsedAST> openFile(llvm::StringRef Filename);
44 private:
45 struct SourceFile {
46 std::string Code;
47 bool IsMainFile = false;
49 llvm::StringMap<SourceFile> Inputs;
50 TestTU TU;
52 void addInput(llvm::StringRef Filename, const SourceFile &Input);
55 } // namespace clangd
56 } // namespace clang
58 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_UNITTESTS_TESTWORKSPACE_H