[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang-tools-extra / clangd / index / SymbolLocation.cpp
blob61da267b93ce5b08a0650582ec9dbdcb96ad8e61
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 //===----------------------------------------------------------------------===//
9 #include "SymbolLocation.h"
11 namespace clang {
12 namespace clangd {
14 constexpr uint32_t SymbolLocation::Position::MaxLine;
15 constexpr uint32_t SymbolLocation::Position::MaxColumn;
17 void SymbolLocation::Position::setLine(uint32_t L) {
18 if (L > MaxLine)
19 L = MaxLine;
20 LineColumnPacked = (L << ColumnBits) | column();
22 void SymbolLocation::Position::setColumn(uint32_t Col) {
23 if (Col > MaxColumn)
24 Col = MaxColumn;
25 LineColumnPacked = (LineColumnPacked & ~MaxColumn) | Col;
28 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const SymbolLocation &L) {
29 if (!L)
30 return OS << "(none)";
31 return OS << L.FileURI << "[" << L.Start.line() << ":" << L.Start.column()
32 << "-" << L.End.line() << ":" << L.End.column() << ")";
35 } // namespace clangd
36 } // namespace clang