LCOV - code coverage report
Current view: top level - clang/tools/extra/include-fixer - SymbolIndexManager.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 4 4 100.0 %
Date: 2018-10-20 13:21:21 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- SymbolIndexManager.h - Managing multiple SymbolIndices --*- C++ -*-===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : 
      10             : #ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H
      11             : #define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_SYMBOLINDEXMANAGER_H
      12             : 
      13             : #include "SymbolIndex.h"
      14             : #include "find-all-symbols/SymbolInfo.h"
      15             : #include "llvm/ADT/StringRef.h"
      16             : 
      17             : #ifdef _MSC_VER
      18             : // Disable warnings from ppltasks.h transitively included by <future>.
      19             : #pragma warning(push)
      20             : #pragma warning(disable:4530)
      21             : #endif
      22             : 
      23             : #include <future>
      24             : 
      25             : #ifdef _MSC_VER
      26             : #pragma warning(pop)
      27             : #endif
      28             : 
      29             : namespace clang {
      30             : namespace include_fixer {
      31             : 
      32             : /// This class provides an interface for finding the header files corresponding
      33             : /// to an identifier in the source code from multiple symbol databases.
      34          50 : class SymbolIndexManager {
      35             : public:
      36          50 :   void addSymbolIndex(std::function<std::unique_ptr<SymbolIndex>()> F) {
      37             : #if LLVM_ENABLE_THREADS
      38             :     auto Strategy = std::launch::async;
      39             : #else
      40             :     auto Strategy = std::launch::deferred;
      41             : #endif
      42         100 :     SymbolIndices.push_back(std::async(Strategy, F));
      43          50 :   }
      44             : 
      45             :   /// Search for header files to be included for an identifier.
      46             :   /// \param Identifier The identifier being searched for. May or may not be
      47             :   ///                   fully qualified.
      48             :   /// \param IsNestedSearch Whether searching nested classes. If true, the
      49             :   ///        method tries to strip identifier name parts from the end until it
      50             :   ///        finds the corresponding candidates in database (e.g for identifier
      51             :   ///        "b::foo", the method will try to find "b" if it fails to find
      52             :   ///        "b::foo").
      53             :   ///
      54             :   /// \returns A list of symbol candidates.
      55             :   std::vector<find_all_symbols::SymbolInfo>
      56             :   search(llvm::StringRef Identifier, bool IsNestedSearch = true,
      57             :          llvm::StringRef FileName = "") const;
      58             : 
      59             : private:
      60             :   std::vector<std::shared_future<std::unique_ptr<SymbolIndex>>> SymbolIndices;
      61             : };
      62             : 
      63             : } // namespace include_fixer
      64             : } // namespace clang
      65             : 
      66             : #endif

Generated by: LCOV version 1.13