|
25 | 25 | #include "llvm/ADT/SmallString.h"
|
26 | 26 | #include "llvm/ADT/StringSwitch.h"
|
27 | 27 | #include "llvm/ADT/Twine.h"
|
| 28 | +#include "llvm/ADT/bit.h" |
28 | 29 | #include "llvm/Support/Compiler.h"
|
29 | 30 | #include "llvm/Support/MathExtras.h"
|
30 | 31 | #include "llvm/Support/MemoryBuffer.h"
|
@@ -60,7 +61,7 @@ using clang::isWhitespace;
|
60 | 61 | static bool EncodeToUTF8(unsigned CharValue,
|
61 | 62 | SmallVectorImpl<char> &Result) {
|
62 | 63 | // Number of bits in the value, ignoring leading zeros.
|
63 |
| - unsigned NumBits = 32-llvm::countLeadingZeros(CharValue); |
| 64 | + unsigned NumBits = 32-llvm::countl_zero(CharValue); |
64 | 65 |
|
65 | 66 | // Handle the leading byte, based on the number of bits in the value.
|
66 | 67 | unsigned NumTrailingBytes;
|
@@ -100,7 +101,7 @@ static bool EncodeToUTF8(unsigned CharValue,
|
100 | 101 |
|
101 | 102 | /// CLO8 - Return the number of leading ones in the specified 8-bit value.
|
102 | 103 | static unsigned CLO8(unsigned char C) {
|
103 |
| - return llvm::countLeadingOnes(uint32_t(C) << 24); |
| 104 | + return llvm::countl_zero(uint32_t(C) << 24); |
104 | 105 | }
|
105 | 106 |
|
106 | 107 | /// isStartOfUTF8Character - Return true if this isn't a UTF8 continuation
|
@@ -162,7 +163,7 @@ uint32_t swift::validateUTF8CharacterAndAdvance(const char *&Ptr,
|
162 | 163 | // If we got here, we read the appropriate number of accumulated bytes.
|
163 | 164 | // Verify that the encoding was actually minimal.
|
164 | 165 | // Number of bits in the value, ignoring leading zeros.
|
165 |
| - unsigned NumBits = 32-llvm::countLeadingZeros(CharValue); |
| 166 | + unsigned NumBits = 32-llvm::countl_zero(CharValue); |
166 | 167 |
|
167 | 168 | if (NumBits <= 5+6)
|
168 | 169 | return EncodedBytes == 2 ? CharValue : ~0U;
|
|
0 commit comments