16 #ifndef LLVM_CLANG_LIB_FORMAT_ENCODING_H
17 #define LLVM_CLANG_LIB_FORMAT_ENCODING_H
20 #include "llvm/Support/ConvertUTF.h"
21 #include "llvm/Support/Unicode.h"
35 const UTF8 *Ptr =
reinterpret_cast<const UTF8 *
>(Text.begin());
36 const UTF8 *BufEnd =
reinterpret_cast<const UTF8 *
>(Text.end());
37 if (::isLegalUTF8String(&Ptr, BufEnd))
43 unsigned CodePoints = 0;
44 for (
size_t i = 0, e = Text.size(); i < e; i += getNumBytesForUTF8(Text[i])) {
66 int ContentWidth = llvm::sys::unicode::columnWidthUTF8(Text);
71 if (ContentWidth >= 0)
82 unsigned TotalWidth = 0;
83 StringRef Tail = Text;
85 StringRef::size_type TabPos = Tail.find(
'\t');
86 if (TabPos == StringRef::npos)
89 TotalWidth += TabWidth - (TotalWidth + StartColumn) % TabWidth;
90 Tail = Tail.substr(TabPos + 1);
99 return getNumBytesForUTF8(FirstChar);
105 inline bool isOctDigit(
char c) {
return '0' <= c && c <=
'7'; }
108 return (
'0' <= c && c <=
'9') || (
'a' <= c && c <=
'f') ||
109 (
'A' <= c && c <=
'F');
116 assert(Text[0] ==
'\\');
127 while (I < Text.size() &&
isHexDigit(Text[I]))
134 while (I < Text.size() && I < 4 &&
isOctDigit(Text[I]))
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...