tetraxile updated this revision to Diff 547595.
tetraxile added a comment.

Thanks for the suggestion SR_team, I've just added that.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157205/new/

https://reviews.llvm.org/D157205

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3383,7 +3383,7 @@
 Type: type (aka can_type)
 Value = value
 Offset: 12 (0xc) bytes
-Size: 4 (0x4) bytes (+4 (0x4) bytes padding)
+Size: 4 bytes (+4 bytes padding)
 
 // In test::Bar
 def)",
@@ -3404,8 +3404,8 @@
 
 Type: type (aka can_type)
 Value = value
-Offset: 4 (0x4) bytes and 3 (0x3) bits
-Size: 25 (0x19) bits (+4 (0x4) bits padding)
+Offset: 4 bytes and 3 bits
+Size: 25 (0x19) bits (+4 bits padding)
 
 // In test::Bar
 def)",
Index: clang-tools-extra/clangd/Hover.cpp
===================================================================
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -1404,8 +1404,8 @@
 static std::string formatSize(uint64_t SizeInBits) {
   uint64_t Value = SizeInBits % 8 == 0 ? SizeInBits / 8 : SizeInBits;
   const char *Unit = Value != 0 && Value == SizeInBits ? "bit" : "byte";
-  return llvm::formatv("{0} ({0:x}) {1}{2}", Value, Unit, Value == 1 ? "" : 
"s")
-      .str();
+  const char *Fmt = Value >= 10 ? "{0} ({0:x}) {1}{2}" : "{0} {1}{2}";
+  return llvm::formatv(Fmt, Value, Unit, Value == 1 ? "" : "s").str();
 }
 
 // Offsets are shown in bytes + bits, so offsets of different fields


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3383,7 +3383,7 @@
 Type: type (aka can_type)
 Value = value
 Offset: 12 (0xc) bytes
-Size: 4 (0x4) bytes (+4 (0x4) bytes padding)
+Size: 4 bytes (+4 bytes padding)
 
 // In test::Bar
 def)",
@@ -3404,8 +3404,8 @@
 
 Type: type (aka can_type)
 Value = value
-Offset: 4 (0x4) bytes and 3 (0x3) bits
-Size: 25 (0x19) bits (+4 (0x4) bits padding)
+Offset: 4 bytes and 3 bits
+Size: 25 (0x19) bits (+4 bits padding)
 
 // In test::Bar
 def)",
Index: clang-tools-extra/clangd/Hover.cpp
===================================================================
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -1404,8 +1404,8 @@
 static std::string formatSize(uint64_t SizeInBits) {
   uint64_t Value = SizeInBits % 8 == 0 ? SizeInBits / 8 : SizeInBits;
   const char *Unit = Value != 0 && Value == SizeInBits ? "bit" : "byte";
-  return llvm::formatv("{0} ({0:x}) {1}{2}", Value, Unit, Value == 1 ? "" : "s")
-      .str();
+  const char *Fmt = Value >= 10 ? "{0} ({0:x}) {1}{2}" : "{0} {1}{2}";
+  return llvm::formatv(Fmt, Value, Unit, Value == 1 ? "" : "s").str();
 }
 
 // Offsets are shown in bytes + bits, so offsets of different fields
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to