brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · ca2d739 Raw
66 lines · c
1//===-- SymbolIndexManager.h - Managing multiple SymbolIndices --*- 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-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H10#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H11 12#include "SymbolIndex.h"13#include "find-all-symbols/SymbolInfo.h"14#include "llvm/ADT/StringRef.h"15 16#ifdef _MSC_VER17// Disable warnings from ppltasks.h transitively included by <future>.18#pragma warning(push)19#pragma warning(disable:4530)20#endif21 22#include <future>23 24#ifdef _MSC_VER25#pragma warning(pop)26#endif27 28namespace clang {29namespace include_fixer {30 31/// This class provides an interface for finding the header files corresponding32/// to an identifier in the source code from multiple symbol databases.33class SymbolIndexManager {34public:35  void addSymbolIndex(std::function<std::unique_ptr<SymbolIndex>()> F) {36#if LLVM_ENABLE_THREADS37    auto Strategy = std::launch::async;38#else39    auto Strategy = std::launch::deferred;40#endif41    SymbolIndices.push_back(std::async(Strategy, F));42  }43 44  /// Search for header files to be included for an identifier.45  /// \param Identifier The identifier being searched for. May or may not be46  ///                   fully qualified.47  /// \param IsNestedSearch Whether searching nested classes. If true, the48  ///        method tries to strip identifier name parts from the end until it49  ///        finds the corresponding candidates in database (e.g for identifier50  ///        "b::foo", the method will try to find "b" if it fails to find51  ///        "b::foo").52  ///53  /// \returns A list of symbol candidates.54  std::vector<find_all_symbols::SymbolInfo>55  search(llvm::StringRef Identifier, bool IsNestedSearch = true,56         llvm::StringRef FileName = "") const;57 58private:59  std::vector<std::shared_future<std::unique_ptr<SymbolIndex>>> SymbolIndices;60};61 62} // namespace include_fixer63} // namespace clang64 65#endif66