[clang-tools-extra] r319606 - [clangd] Fix FuzzyMatch tests on windows, NFC
Sam McCall via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 1 19:35:19 PST 2017
Author: sammccall
Date: Fri Dec 1 19:35:19 2017
New Revision: 319606
URL: http://llvm.org/viewvc/llvm-project?rev=319606&view=rev
Log:
[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.
Modified:
clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
clang-tools-extra/trunk/clangd/FuzzyMatch.h
Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.cpp?rev=319606&r1=319605&r2=319606&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/FuzzyMatch.cpp (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.cpp Fri Dec 1 19:35:19 2017
@@ -115,7 +115,7 @@ Optional<float> FuzzyMatcher::match(Stri
// 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.
Modified: clang-tools-extra/trunk/clangd/FuzzyMatch.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FuzzyMatch.h?rev=319606&r1=319605&r2=319606&view=diff
==============================================================================
--- clang-tools-extra/trunk/clangd/FuzzyMatch.h (original)
+++ clang-tools-extra/trunk/clangd/FuzzyMatch.h Fri Dec 1 19:35:19 2017
@@ -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();
More information about the cfe-commits
mailing list