LCOV - code coverage report
Current view: top level - clang/tools/extra/clangd/index - Serialization.h (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 0 2 0.0 %
Date: 2018-10-20 13:21:21 Functions: 0 0 -
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===--- Serialization.h - Binary serialization of index data ----*- 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             : // This file provides serialization of indexed symbols and other data.
      11             : //
      12             : // It writes sections:
      13             : //  - metadata such as version info
      14             : //  - a string table (which is compressed)
      15             : //  - lists of encoded symbols
      16             : //
      17             : // The format has a simple versioning scheme: the format version number is
      18             : // written in the file and non-current versions are rejected when reading.
      19             : //
      20             : // Human-readable YAML serialization is also supported, and recommended for
      21             : // debugging and experiments only.
      22             : //
      23             : //===----------------------------------------------------------------------===//
      24             : 
      25             : #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_RIFF_H
      26             : #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_RIFF_H
      27             : #include "Index.h"
      28             : #include "llvm/Support/Error.h"
      29             : 
      30             : namespace clang {
      31             : namespace clangd {
      32             : 
      33             : enum class IndexFileFormat {
      34             :   RIFF, // Versioned binary format, suitable for production use.
      35             :   YAML, // Human-readable format, suitable for experiments and debugging.
      36             : };
      37             : 
      38             : // Holds the contents of an index file that was read.
      39             : struct IndexFileIn {
      40             :   llvm::Optional<SymbolSlab> Symbols;
      41             :   llvm::Optional<RefSlab> Refs;
      42             : };
      43             : // Parse an index file. The input must be a RIFF or YAML file.
      44             : llvm::Expected<IndexFileIn> readIndexFile(llvm::StringRef);
      45             : 
      46             : // Specifies the contents of an index file to be written.
      47             : struct IndexFileOut {
      48             :   const SymbolSlab *Symbols = nullptr;
      49             :   const RefSlab *Refs = nullptr;
      50             :   // TODO: Support serializing Dex posting lists.
      51             :   IndexFileFormat Format = IndexFileFormat::RIFF;
      52             : 
      53             :   IndexFileOut() = default;
      54             :   IndexFileOut(const IndexFileIn &I)
      55           0 :       : Symbols(I.Symbols ? I.Symbols.getPointer() : nullptr),
      56           0 :         Refs(I.Refs ? I.Refs.getPointer() : nullptr) {}
      57             : };
      58             : // Serializes an index file.
      59             : llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const IndexFileOut &O);
      60             : 
      61             : // Convert a single symbol to YAML, a nice debug representation.
      62             : std::string toYAML(const Symbol &);
      63             : std::string toYAML(const std::pair<SymbolID, ArrayRef<Ref>> &);
      64             : 
      65             : // Build an in-memory static index from an index file.
      66             : // The size should be relatively small, so data can be managed in memory.
      67             : std::unique_ptr<SymbolIndex> loadIndex(llvm::StringRef Filename,
      68             :                                        llvm::ArrayRef<std::string> URISchemes,
      69             :                                        bool UseDex = true);
      70             : 
      71             : } // namespace clangd
      72             : } // namespace clang
      73             : 
      74             : #endif

Generated by: LCOV version 1.13