[PATCH] D53400: [clangd] Remove the overflow log.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 18 08:30:11 PDT 2018


hokein updated this revision to Diff 170091.
hokein added a comment.

Add log in XRefs.cpp.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53400

Files:
  clangd/XRefs.cpp
  clangd/index/Index.cpp


Index: clangd/index/Index.cpp
===================================================================
--- clangd/index/Index.cpp
+++ clangd/index/Index.cpp
@@ -23,15 +23,13 @@
 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;
   }
   Line = L;
 }
 void SymbolLocation::Position::setColumn(uint32_t Col) {
   if (Col > MaxColumn) {
-    log("Set an overflowed Column {0}", Col);
     Column = MaxColumn;
     return;
   }
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;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53400.170091.patch
Type: text/x-patch
Size: 1828 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181018/1d6d02a0/attachment.bin>


More information about the cfe-commits mailing list