[PATCH] D67277: [clangd] Replace HighlightingKind::NumKinds with LastKind. NFC

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 6 07:28:56 PDT 2019


ilya-biryukov created this revision.
ilya-biryukov added a reviewer: hokein.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

The latter simplifies the client code by avoiding the need to handle it
as a separate case statement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67277

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h


Index: clang-tools-extra/clangd/SemanticHighlighting.h
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -41,7 +41,7 @@
   Primitive,
   Macro,
 
-  NumKinds,
+  LastKind = Macro
 };
 llvm::raw_ostream& operator<<(llvm::raw_ostream &OS, HighlightingKind K);
 
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -387,9 +387,8 @@
     return OS << "Primitive";
   case HighlightingKind::Macro:
     return OS << "Macro";
-  case HighlightingKind::NumKinds:
-    llvm_unreachable("NumKinds is not a valid HighlightingKind");
   }
+  llvm_unreachable("invalid HighlightingKind");
 }
 
 std::vector<LineHighlightings>
@@ -515,8 +514,6 @@
     return "storage.type.primitive.cpp";
   case HighlightingKind::Macro:
     return "entity.name.function.preprocessor.cpp";
-  case HighlightingKind::NumKinds:
-    llvm_unreachable("must not pass NumKinds to the function");
   }
   llvm_unreachable("unhandled HighlightingKind");
 }
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===================================================================
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -87,7 +87,7 @@
 std::vector<std::vector<std::string>> buildHighlightScopeLookupTable() {
   std::vector<std::vector<std::string>> LookupTable;
   // HighlightingKind is using as the index.
-  for (int KindValue = 0; KindValue < (int)HighlightingKind::NumKinds;
+  for (int KindValue = 0; KindValue <= (int)HighlightingKind::LastKind;
        ++KindValue)
     LookupTable.push_back({toTextMateScope((HighlightingKind)(KindValue))});
   return LookupTable;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67277.219102.patch
Type: text/x-patch
Size: 1908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190906/e3ed33dc/attachment.bin>


More information about the cfe-commits mailing list