This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. sammccall marked an inline comment as done. Closed by commit rG817550919e78: [Lex] Don't assert when decoding invalid UCNs. (authored by sammccall).
Changed prior to commit: https://reviews.llvm.org/D125059?vs=427494&id=427534#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D125059/new/ https://reviews.llvm.org/D125059 Files: clang/lib/Lex/LiteralSupport.cpp clang/test/Lexer/unicode.c Index: clang/test/Lexer/unicode.c =================================================================== --- clang/test/Lexer/unicode.c +++ clang/test/Lexer/unicode.c @@ -28,6 +28,9 @@ int _; +extern int X\UAAAAAAAA; // expected-error {{not allowed in an identifier}} +int Y = '\UAAAAAAAA'; // expected-error {{invalid universal character}} + #ifdef __cplusplus extern int ༀ; Index: clang/lib/Lex/LiteralSupport.cpp =================================================================== --- clang/lib/Lex/LiteralSupport.cpp +++ clang/lib/Lex/LiteralSupport.cpp @@ -320,10 +320,8 @@ llvm::SmallVectorImpl<char> &Str) { char ResultBuf[4]; char *ResultPtr = ResultBuf; - bool Res = llvm::ConvertCodePointToUTF8(Codepoint, ResultPtr); - (void)Res; - assert(Res && "Unexpected conversion failure"); - Str.append(ResultBuf, ResultPtr); + if (llvm::ConvertCodePointToUTF8(Codepoint, ResultPtr)) + Str.append(ResultBuf, ResultPtr); } void clang::expandUCNs(SmallVectorImpl<char> &Buf, StringRef Input) {
Index: clang/test/Lexer/unicode.c =================================================================== --- clang/test/Lexer/unicode.c +++ clang/test/Lexer/unicode.c @@ -28,6 +28,9 @@ int _; +extern int X\UAAAAAAAA; // expected-error {{not allowed in an identifier}} +int Y = '\UAAAAAAAA'; // expected-error {{invalid universal character}} + #ifdef __cplusplus extern int à¼; Index: clang/lib/Lex/LiteralSupport.cpp =================================================================== --- clang/lib/Lex/LiteralSupport.cpp +++ clang/lib/Lex/LiteralSupport.cpp @@ -320,10 +320,8 @@ llvm::SmallVectorImpl<char> &Str) { char ResultBuf[4]; char *ResultPtr = ResultBuf; - bool Res = llvm::ConvertCodePointToUTF8(Codepoint, ResultPtr); - (void)Res; - assert(Res && "Unexpected conversion failure"); - Str.append(ResultBuf, ResultPtr); + if (llvm::ConvertCodePointToUTF8(Codepoint, ResultPtr)) + Str.append(ResultBuf, ResultPtr); } void clang::expandUCNs(SmallVectorImpl<char> &Buf, StringRef Input) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits