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 | 9091055efa871d15cc53cd8ad91689ea8cb90ddb (patch) | |
tree | dfb1d97a777083db456f1373c93825cb7581c960 /clang/lib/Format/Encoding.h | |
parent | 951c6b1955326eab68dfb77b874edb3d5f3bbbf0 (diff) | |
download | bcm5719-llvm-9091055efa871d15cc53cd8ad91689ea8cb90ddb.tar.gz bcm5719-llvm-9091055efa871d15cc53cd8ad91689ea8cb90ddb.zip |
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
llvm-svn: 282822
Diffstat (limited to 'clang/lib/Format/Encoding.h')
-rw-r--r-- | clang/lib/Format/Encoding.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Format/Encoding.h b/clang/lib/Format/Encoding.h index 148f7fd0e91..b2103cb412e 100644 --- a/clang/lib/Format/Encoding.h +++ b/clang/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]); } } |