[BuildLibcalls, Attrs] Support more variants of C++'s new, add attributes for C+...
[lldb.git] / clang-tools-extra / clang-include-fixer / YamlSymbolIndex.h
1 //===-- YamlSymbolIndex.h ---------------------------------------*- 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 #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLSYMBOLINDEX_H
10 #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLSYMBOLINDEX_H
11
12 #include "SymbolIndex.h"
13 #include "find-all-symbols/SymbolInfo.h"
14 #include "llvm/Support/ErrorOr.h"
15 #include <map>
16 #include <vector>
17
18 namespace clang {
19 namespace include_fixer {
20
21 /// Yaml format database.
22 class YamlSymbolIndex : public SymbolIndex {
23 public:
24   /// Create a new Yaml db from a file.
25   static llvm::ErrorOr<std::unique_ptr<YamlSymbolIndex>>
26   createFromFile(llvm::StringRef FilePath);
27   /// Look for a file called \c Name in \c Directory and all parent directories.
28   static llvm::ErrorOr<std::unique_ptr<YamlSymbolIndex>>
29   createFromDirectory(llvm::StringRef Directory, llvm::StringRef Name);
30
31   std::vector<find_all_symbols::SymbolAndSignals>
32   search(llvm::StringRef Identifier) override;
33
34 private:
35   explicit YamlSymbolIndex(
36       std::vector<find_all_symbols::SymbolAndSignals> Symbols)
37       : Symbols(std::move(Symbols)) {}
38
39   std::vector<find_all_symbols::SymbolAndSignals> Symbols;
40 };
41
42 } // namespace include_fixer
43 } // namespace clang
44
45 #endif // LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_YAMLSYMBOLINDEX_H