[clangd] Replace HighlightingKind::NumKinds with LastKind. NFC
Summary:
The latter simplifies the client code by avoiding the need to handle it
as a separate case statement.
Reviewers: hokein
Reviewed By: hokein
Subscribers: nridge, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D67277
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@371375 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clangd/ClangdLSPServer.cpp b/clangd/ClangdLSPServer.cpp
index ee17cb0..a977e95 100644
--- a/clangd/ClangdLSPServer.cpp
+++ b/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;
diff --git a/clangd/SemanticHighlighting.cpp b/clangd/SemanticHighlighting.cpp
index 6316c1e..61de0f4 100644
--- a/clangd/SemanticHighlighting.cpp
+++ b/clangd/SemanticHighlighting.cpp
@@ -383,9 +383,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>
@@ -511,8 +510,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");
}
diff --git a/clangd/SemanticHighlighting.h b/clangd/SemanticHighlighting.h
index 3fcb611..930fcca 100644
--- a/clangd/SemanticHighlighting.h
+++ b/clangd/SemanticHighlighting.h
@@ -41,7 +41,7 @@
Primitive,
Macro,
- NumKinds,
+ LastKind = Macro
};
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, HighlightingKind K);