From 8e97cca1494ab994a2c338fe19b80ee8ede45f73 Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Sat, 2 Dec 2017 03:35:19 +0000 Subject: [PATCH] [clangd] Fix FuzzyMatch tests on windows, NFC Without specifying the signedness of the underlying type for Action, packing it in a 1-bit field may restrict its range to [-1, 0] which can't represent Match. llvm-svn: 319606 --- clang-tools-extra/clangd/FuzzyMatch.cpp | 4 ++-- clang-tools-extra/clangd/FuzzyMatch.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/clang-tools-extra/clangd/FuzzyMatch.cpp b/clang-tools-extra/clangd/FuzzyMatch.cpp index b010d420b26d..cf680280e796 100644 --- a/clang-tools-extra/clangd/FuzzyMatch.cpp +++ b/clang-tools-extra/clangd/FuzzyMatch.cpp @@ -115,7 +115,7 @@ Optional FuzzyMatcher::match(StringRef Word) { // It's not obvious how to segment digits, we treat them as lowercase letters. // As we don't decode UTF-8, we treat bytes over 127 as lowercase too. // This means we require exact (case-sensitive) match. -enum FuzzyMatcher::CharType : char { +enum FuzzyMatcher::CharType : unsigned char { Empty = 0, // Before-the-start and after-the-end (and control chars). Lower = 1, // Lowercase letters, digits, and non-ASCII bytes. Upper = 2, // Uppercase letters. @@ -144,7 +144,7 @@ constexpr static uint8_t CharTypes[] = { // e.g. XMLHttpRequest_Async // +--+---+------ +---- // ^Head ^Tail ^Separator -enum FuzzyMatcher::CharRole : char { +enum FuzzyMatcher::CharRole : unsigned char { Unknown = 0, // Stray control characters or impossible states. Tail = 1, // Part of a word segment, but not the first character. Head = 2, // The first character of a word segment. diff --git a/clang-tools-extra/clangd/FuzzyMatch.h b/clang-tools-extra/clangd/FuzzyMatch.h index 879419ed8beb..283ce0ca6008 100644 --- a/clang-tools-extra/clangd/FuzzyMatch.h +++ b/clang-tools-extra/clangd/FuzzyMatch.h @@ -43,9 +43,9 @@ public: private: // We truncate the pattern and the word to bound the cost of matching. constexpr static int MaxPat = 63, MaxWord = 127; - enum CharRole : char; // For segmentation. - enum CharType : char; // For segmentation. - enum Action { Miss = 0, Match = 1 }; + enum CharRole : unsigned char; // For segmentation. + enum CharType : unsigned char; // For segmentation. + enum Action : unsigned char { Miss = 0, Match = 1 }; bool init(llvm::StringRef Word); void buildGraph();