diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-08 07:16:20 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-09-08 07:16:20 +0000 |
commit | e5f0588840b20897631cc8110344fd2745ef4caa (patch) | |
tree | 8fb7656a4564a1c23cb52532ca9622efe9f9ba67 /include/clang/Basic/ConvertUTF.h | |
parent | 49f9434a4a69d56779aa37feb2d85e06e7289fce (diff) |
When a bad UTF-8 encoding or bogus escape sequence is encountered in a
string literal, produce a diagnostic pointing at the erroneous character
range, not at the start of the literal.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163459 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Basic/ConvertUTF.h')
-rw-r--r-- | include/clang/Basic/ConvertUTF.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/include/clang/Basic/ConvertUTF.h b/include/clang/Basic/ConvertUTF.h index 5be304b475..cdc42699e3 100644 --- a/include/clang/Basic/ConvertUTF.h +++ b/include/clang/Basic/ConvertUTF.h @@ -158,7 +158,9 @@ ConversionResult ConvertUTF32toUTF16 ( Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); -Boolean isLegalUTF8String(const UTF8 *source, const UTF8 *sourceEnd); +Boolean isLegalUTF8String(const UTF8 **source, const UTF8 *sourceEnd); + +unsigned getNumBytesForUTF8(UTF8 firstByte); #ifdef __cplusplus } @@ -174,11 +176,13 @@ namespace clang { * Convert an UTF8 StringRef to UTF8, UTF16, or UTF32 depending on * WideCharWidth. The converted data is written to ResultPtr, which needs to * point to at least WideCharWidth * (Source.Size() + 1) bytes. On success, - * ResultPtr will point one after the end of the copied string. + * ResultPtr will point one after the end of the copied string. On failure, + * ResultPtr will not be changed, and ErrorPtr will be set to the location of + * the first character which could not be converted. * \return true on success. */ bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source, - char *&ResultPtr); + char *&ResultPtr, const UTF8 *&ErrorPtr); /** * Convert an Unicode code point to UTF8 sequence. |