blob: 79006bf27c581dab724377e6769ff0fa55d5f3b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
//===--- Index.cpp -----------------------------------------------*- C++-*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "Index.h"
#include "llvm/Support/SHA1.h"
namespace clang {
namespace clangd {
namespace {
ArrayRef<uint8_t> toArrayRef(StringRef S) {
return {reinterpret_cast<const uint8_t *>(S.data()), S.size()};
}
} // namespace
SymbolID::SymbolID(llvm::StringRef USR)
: HashValue(llvm::SHA1::hash(toArrayRef(USR))) {}
SymbolSlab::const_iterator SymbolSlab::begin() const { return Symbols.begin(); }
SymbolSlab::const_iterator SymbolSlab::end() const { return Symbols.end(); }
SymbolSlab::const_iterator SymbolSlab::find(const SymbolID &SymID) const {
return Symbols.find(SymID);
}
void SymbolSlab::freeze() { Frozen = true; }
void SymbolSlab::insert(Symbol S) {
assert(!Frozen && "Can't insert a symbol after the slab has been frozen!");
Symbols[S.ID] = std::move(S);
}
} // namespace clangd
} // namespace clang
|