This revision was not accepted when it landed; it landed in state "Needs Review". This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGbf45e27a676d: [Clang] Fix invalid utf-8 detection (authored by cor3ntin).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129223/new/ https://reviews.llvm.org/D129223 Files: clang/test/Lexer/comment-invalid-utf8.c llvm/lib/Support/ConvertUTF.cpp Index: llvm/lib/Support/ConvertUTF.cpp =================================================================== --- llvm/lib/Support/ConvertUTF.cpp +++ llvm/lib/Support/ConvertUTF.cpp @@ -423,7 +423,7 @@ */ unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) { int length = trailingBytesForUTF8[*source] + 1; - return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length + return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length : 0; } Index: clang/test/Lexer/comment-invalid-utf8.c =================================================================== --- clang/test/Lexer/comment-invalid-utf8.c +++ clang/test/Lexer/comment-invalid-utf8.c @@ -25,3 +25,14 @@ // abcd // abcd // expected-warning@-1 {{invalid UTF-8 in comment}} + + +//§ § § ð ä½ å¥½ © + +/*§ § § ð ä½ å¥½ ©*/ + +/* +§ § § ð ä½ å¥½ © +*/ + +/* § § § ð ä½ å¥½ © */
Index: llvm/lib/Support/ConvertUTF.cpp =================================================================== --- llvm/lib/Support/ConvertUTF.cpp +++ llvm/lib/Support/ConvertUTF.cpp @@ -423,7 +423,7 @@ */ unsigned getUTF8SequenceSize(const UTF8 *source, const UTF8 *sourceEnd) { int length = trailingBytesForUTF8[*source] + 1; - return (length > sourceEnd - source && isLegalUTF8(source, length)) ? length + return (length < sourceEnd - source && isLegalUTF8(source, length)) ? length : 0; } Index: clang/test/Lexer/comment-invalid-utf8.c =================================================================== --- clang/test/Lexer/comment-invalid-utf8.c +++ clang/test/Lexer/comment-invalid-utf8.c @@ -25,3 +25,14 @@ // abcd // Âabcd // expected-warning@-1 {{invalid UTF-8 in comment}} + + +//ç ç ç ð 你好 é + +/*ç ç ç ð 你好 é*/ + +/* +ç ç ç ð 你好 é +*/ + +/* ç ç ç ð 你好 é */
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits