CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
69 lines
2.3 KiB
C++
69 lines
2.3 KiB
C++
//===--- Ref.cpp -------------------------------------------------*- C++-*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "Ref.h"
|
|
#include "llvm/ADT/STLExtras.h"
|
|
|
|
namespace clang {
|
|
namespace clangd {
|
|
|
|
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, RefKind K) {
|
|
if (K == RefKind::Unknown)
|
|
return OS << "Unknown";
|
|
static constexpr std::array<const char *, 5> Messages = {"Decl", "Def", "Ref",
|
|
"Spelled", "Call"};
|
|
bool VisitedOnce = false;
|
|
for (unsigned I = 0; I < Messages.size(); ++I) {
|
|
if (static_cast<uint8_t>(K) & 1u << I) {
|
|
if (VisitedOnce)
|
|
OS << ", ";
|
|
OS << Messages[I];
|
|
VisitedOnce = true;
|
|
}
|
|
}
|
|
return OS;
|
|
}
|
|
|
|
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Ref &R) {
|
|
return OS << R.Location << ":" << R.Kind;
|
|
}
|
|
|
|
void RefSlab::Builder::insert(const SymbolID &ID, const Ref &S) {
|
|
Entry E = {ID, S};
|
|
E.Reference.Location.FileURI = UniqueStrings.save(S.Location.FileURI).data();
|
|
Entries.insert(std::move(E));
|
|
}
|
|
|
|
RefSlab RefSlab::Builder::build() && {
|
|
std::vector<std::pair<SymbolID, llvm::ArrayRef<Ref>>> Result;
|
|
// We'll reuse the arena, as it only has unique strings and we need them all.
|
|
// We need to group refs by symbol and form contiguous arrays on the arena.
|
|
std::vector<std::pair<SymbolID, const Ref *>> Flat;
|
|
Flat.reserve(Entries.size());
|
|
for (const Entry &E : Entries)
|
|
Flat.emplace_back(E.Symbol, &E.Reference);
|
|
// Group by SymbolID.
|
|
llvm::sort(Flat, llvm::less_first());
|
|
std::vector<Ref> Refs;
|
|
// Loop over symbols, copying refs for each onto the arena.
|
|
for (auto I = Flat.begin(), End = Flat.end(); I != End;) {
|
|
SymbolID Sym = I->first;
|
|
Refs.clear();
|
|
do {
|
|
Refs.push_back(*I->second);
|
|
++I;
|
|
} while (I != End && I->first == Sym);
|
|
llvm::sort(Refs); // By file, affects xrefs display order.
|
|
Result.emplace_back(Sym, llvm::ArrayRef<Ref>(Refs).copy(Arena));
|
|
}
|
|
return RefSlab(std::move(Result), std::move(Arena), Entries.size());
|
|
}
|
|
|
|
} // namespace clangd
|
|
} // namespace clang
|