Skip to content

Commit 63d5d16

Browse files
committedSep 9, 2019
[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 llvm-svn: 371375
1 parent 6b9aeda commit 63d5d16

File tree

3 files changed

+3
-6
lines changed

3 files changed

+3
-6
lines changed
 

‎clang-tools-extra/clangd/ClangdLSPServer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ CompletionItemKindBitset defaultCompletionItemKinds() {
8787
std::vector<std::vector<std::string>> buildHighlightScopeLookupTable() {
8888
std::vector<std::vector<std::string>> LookupTable;
8989
// HighlightingKind is using as the index.
90-
for (int KindValue = 0; KindValue < (int)HighlightingKind::NumKinds;
90+
for (int KindValue = 0; KindValue <= (int)HighlightingKind::LastKind;
9191
++KindValue)
9292
LookupTable.push_back({toTextMateScope((HighlightingKind)(KindValue))});
9393
return LookupTable;

‎clang-tools-extra/clangd/SemanticHighlighting.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,8 @@ llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, HighlightingKind K) {
383383
return OS << "Primitive";
384384
case HighlightingKind::Macro:
385385
return OS << "Macro";
386-
case HighlightingKind::NumKinds:
387-
llvm_unreachable("NumKinds is not a valid HighlightingKind");
388386
}
387+
llvm_unreachable("invalid HighlightingKind");
389388
}
390389

391390
std::vector<LineHighlightings>
@@ -511,8 +510,6 @@ llvm::StringRef toTextMateScope(HighlightingKind Kind) {
511510
return "storage.type.primitive.cpp";
512511
case HighlightingKind::Macro:
513512
return "entity.name.function.preprocessor.cpp";
514-
case HighlightingKind::NumKinds:
515-
llvm_unreachable("must not pass NumKinds to the function");
516513
}
517514
llvm_unreachable("unhandled HighlightingKind");
518515
}

‎clang-tools-extra/clangd/SemanticHighlighting.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ enum class HighlightingKind {
4141
Primitive,
4242
Macro,
4343

44-
NumKinds,
44+
LastKind = Macro
4545
};
4646
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, HighlightingKind K);
4747

0 commit comments

Comments
 (0)
Please sign in to comment.