16 #ifndef LLVM_CLANG_LIB_FORMAT_ENCODING_H
17 #define LLVM_CLANG_LIB_FORMAT_ENCODING_H
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/Support/ConvertUTF.h"
22 #include "llvm/Support/Unicode.h"
36 const UTF8 *Ptr =
reinterpret_cast<const UTF8 *
>(Text.begin());
37 const UTF8 *BufEnd =
reinterpret_cast<const UTF8 *
>(Text.end());
38 if (::isLegalUTF8String(&Ptr, BufEnd))
44 unsigned CodePoints = 0;
45 for (
size_t i = 0, e = Text.size(); i < e; i += getNumBytesForUTF8(Text[i])) {
67 int ContentWidth = llvm::sys::unicode::columnWidthUTF8(Text);
72 if (ContentWidth >= 0)
83 unsigned TotalWidth = 0;
84 StringRef Tail =
Text;
86 StringRef::size_type TabPos = Tail.find(
'\t');
87 if (TabPos == StringRef::npos)
90 TotalWidth += TabWidth - (TotalWidth + StartColumn) % TabWidth;
91 Tail = Tail.substr(TabPos + 1);
100 return getNumBytesForUTF8(FirstChar);
106 inline bool isOctDigit(
char c) {
return '0' <= c && c <=
'7'; }
109 return (
'0' <= c && c <=
'9') || (
'a' <= c && c <=
'f') ||
110 (
'A' <= c && c <=
'F');
117 assert(Text[0] ==
'\\');
128 while (I < Text.size() &&
isHexDigit(Text[I]))
135 while (I < Text.size() && I < 4 &&
isOctDigit(Text[I]))
139 return 1 + getNumBytesForUTF8(Text[1]);
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
detail::InMemoryDirectory::const_iterator I