[PATCH] D125059: [Lex] Don't assert when decoding invalid UCNs.
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 5 23:52:04 PDT 2022
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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125059.427534.patch
Type: text/x-patch
Size: 1056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220506/da2e0310/attachment.bin>
More information about the cfe-commits
mailing list