Index: clangd/XRefs.cpp =================================================================== --- clangd/XRefs.cpp +++ clangd/XRefs.cpp @@ -37,6 +37,20 @@ return nullptr; } +uint32_t getLine(const SymbolLocation::Position Pos) { + uint32_t Line = Pos.line(); + if (Line >= SymbolLocation::Position::MaxLine) + log("Get an overflowed line"); + return Line; +} + +uint32_t getColumn(const SymbolLocation::Position Pos) { + uint32_t Column = Pos.column(); + if (Column >= SymbolLocation::Position::MaxColumn) + log("Get an overflowed column"); + return Column; +} + // Convert a SymbolLocation to LSP's Location. // HintPath is used to resolve the path of URI. // FIXME: figure out a good home for it, and share the implementation with @@ -57,10 +71,10 @@ } Location LSPLoc; LSPLoc.uri = URIForFile(*Path); - LSPLoc.range.start.line = Loc.Start.line(); - LSPLoc.range.start.character = Loc.Start.column(); - LSPLoc.range.end.line = Loc.End.line(); - LSPLoc.range.end.character = Loc.End.column(); + LSPLoc.range.start.line = getLine(Loc.Start); + LSPLoc.range.start.character = getColumn(Loc.Start); + LSPLoc.range.end.line = getLine(Loc.End); + LSPLoc.range.end.character = getColumn(Loc.End); return LSPLoc; } Index: clangd/index/Index.cpp =================================================================== --- clangd/index/Index.cpp +++ clangd/index/Index.cpp @@ -23,7 +23,6 @@ constexpr uint32_t SymbolLocation::Position::MaxColumn; void SymbolLocation::Position::setLine(uint32_t L) { if (L > MaxLine) { - log("Set an overflowed Line {0}", L); Line = MaxLine; return; } @@ -31,7 +30,6 @@ } void SymbolLocation::Position::setColumn(uint32_t Col) { if (Col > MaxColumn) { - log("Set an overflowed Column {0}", Col); Column = MaxColumn; return; }