9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOLID_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_SYMBOLID_H
12#include "llvm/ADT/Hashing.h"
13#include "llvm/ADT/StringRef.h"
14#include "llvm/ADT/bit.h"
15#include "llvm/Support/Error.h"
16#include "llvm/Support/raw_ostream.h"
36 explicit SymbolID(llvm::StringRef USR);
39 return HashValue == Sym.HashValue;
44 return llvm::bit_cast<IntTy>(HashValue) <
45 llvm::bit_cast<IntTy>(Sym.HashValue);
51 llvm::StringRef
raw()
const;
55 std::string
str()
const;
56 static llvm::Expected<SymbolID>
fromStr(llvm::StringRef);
59 explicit operator bool()
const {
return !
isNull(); }
62 using IntTy = uint64_t;
63 static_assert(
sizeof(IntTy) ==
RawSize);
64 std::array<uint8_t, RawSize> HashValue{};
70 "size_t longer than SHA1!");
72 memcpy(&Result, ID.
raw().data(),
sizeof(
size_t));
73 return llvm::hash_code(Result);
77llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const SymbolID &ID);
84template <>
struct DenseMapInfo<
clang::clangd::SymbolID> {
86 return hash_value(Sym);
static constexpr size_t RawSize
static llvm::Expected< SymbolID > fromStr(llvm::StringRef)
bool operator==(const SymbolID &Sym) const
static SymbolID fromRaw(llvm::StringRef)
llvm::StringRef raw() const
bool operator<(const SymbolID &Sym) const
bool operator!=(const SymbolID &Sym) const
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
llvm::hash_code hash_value(const SymbolID &ID)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Some operations such as code completion produce a set of candidates.
static unsigned getHashValue(const clang::clangd::SymbolID &Sym)
static bool isEqual(const clang::clangd::SymbolID &LHS, const clang::clangd::SymbolID &RHS)