diff options
author | Justin Lebar <jlebar@google.com> | 2016-09-30 00:38:45 +0000 |
---|---|---|
committer | Justin Lebar <jlebar@google.com> | 2016-09-30 00:38:45 +0000 |
commit | dd052623fdb8f7292a60486e46c498a4294ad581 (patch) | |
tree | bfa2268dd5630c4c707e937143823366fb202818 /lib/Format/Encoding.h | |
parent | bec0fbe74a1a3757ec2693605175a0019c6509b3 (diff) |
Move UTF functions into namespace llvm.
Summary:
This lets people link against LLVM and their own version of the UTF
library.
I determined this only affects llvm, clang, lld, and lldb by running
$ git grep -wl 'UTF[0-9]\+\|\bConvertUTF\bisLegalUTF\|getNumBytesFor' | cut -f 1 -d '/' | sort | uniq
clang
lld
lldb
llvm
Tested with
ninja lldb
ninja check-clang check-llvm check-lld
(ninja check-lldb doesn't complete for me with or without this patch.)
Reviewers: rnk
Subscribers: klimek, beanz, mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D24996
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@282822 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Encoding.h')
-rw-r--r-- | lib/Format/Encoding.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/Format/Encoding.h b/lib/Format/Encoding.h index 148f7fd0e9..b2103cb412 100644 --- a/lib/Format/Encoding.h +++ b/lib/Format/Encoding.h @@ -33,16 +33,17 @@ enum Encoding { /// \brief Detects encoding of the Text. If the Text can be decoded using UTF-8, /// it is considered UTF8, otherwise we treat it as some 8-bit encoding. inline Encoding detectEncoding(StringRef Text) { - const UTF8 *Ptr = reinterpret_cast<const UTF8 *>(Text.begin()); - const UTF8 *BufEnd = reinterpret_cast<const UTF8 *>(Text.end()); - if (::isLegalUTF8String(&Ptr, BufEnd)) + const llvm::UTF8 *Ptr = reinterpret_cast<const llvm::UTF8 *>(Text.begin()); + const llvm::UTF8 *BufEnd = reinterpret_cast<const llvm::UTF8 *>(Text.end()); + if (llvm::isLegalUTF8String(&Ptr, BufEnd)) return Encoding_UTF8; return Encoding_Unknown; } inline unsigned getCodePointCountUTF8(StringRef Text) { unsigned CodePoints = 0; - for (size_t i = 0, e = Text.size(); i < e; i += getNumBytesForUTF8(Text[i])) { + for (size_t i = 0, e = Text.size(); i < e; + i += llvm::getNumBytesForUTF8(Text[i])) { ++CodePoints; } return CodePoints; @@ -97,7 +98,7 @@ inline unsigned columnWidthWithTabs(StringRef Text, unsigned StartColumn, inline unsigned getCodePointNumBytes(char FirstChar, Encoding Encoding) { switch (Encoding) { case Encoding_UTF8: - return getNumBytesForUTF8(FirstChar); + return llvm::getNumBytesForUTF8(FirstChar); default: return 1; } @@ -136,7 +137,7 @@ inline unsigned getEscapeSequenceLength(StringRef Text) { ++I; return I; } - return 1 + getNumBytesForUTF8(Text[1]); + return 1 + llvm::getNumBytesForUTF8(Text[1]); } } |