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;
 }
 


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;
 }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to