[clang] bad error message on incorrect string literal #18079 (PR #81670)

via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 14 11:27:48 PST 2024


================
@@ -2270,9 +2270,11 @@ bool Lexer::LexRawStringLiteral(Token &Result, const char *CurPtr,
       const char *PrefixEnd = &CurPtr[PrefixLen];
       if (PrefixLen == 16) {
         Diag(PrefixEnd, diag::err_raw_delim_too_long);
-      } else {
+      } else if (*PrefixEnd != '\n') {
----------------
akshaykumars614 wrote:

I implemented it in that way initially, but the PrefixLen variable is assigned with the last token of the translation file (which is usually \n) when it could not find '(' token. So, I couldn't find the practical scenario where the *PrefixEnd will be other than \n. Hence I flipped the cases.
Can you suggest any scenarios if you can remember on top of your head?

https://github.com/llvm/llvm-project/pull/81670


More information about the cfe-commits mailing list