Debian Codegraph @

clang-tools-extra/clangd/index/SymbolLocation.cpp

raw
1 //===--- SymbolLocation.cpp --------------------------------------*- C++-*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "SymbolLocation.h"
10
11 namespace clang {
12 namespace clangd {
13
14 void SymbolLocation::Position::setLine(uint32_t L) {
15 if (L > MaxLine)
16 L = MaxLine;
17 LineColumnPacked = (L << ColumnBits) | column();
18 }
19 void SymbolLocation::Position::setColumn(uint32_t Col) {
20 if (Col > MaxColumn)
21 Col = MaxColumn;
22 LineColumnPacked = (LineColumnPacked & ~MaxColumn) | Col;
23 }
24
25 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolLocation &L) {
26 if (!L)
27 return OS << "(none)";
28 return OS << L.FileURI << "[" << L.Start.line() << ":" << L.Start.column()
29 << "-" << L.End.line() << ":" << L.End.column() << ")";
30 }
31
32 } // namespace clangd
33 } // namespace clang