[clang] 36f77e2 - Revert "Revert "[clang][Lex] Fix a crash on malformed string literals""

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 6 02:53:59 PDT 2022


Author: Kadir Cetinkaya
Date: 2022-10-06T11:41:18+02:00
New Revision: 36f77e20d9aaaf93a9b00ec1bd6b7e3ceb4918b9

URL: https://github.com/llvm/llvm-project/commit/36f77e20d9aaaf93a9b00ec1bd6b7e3ceb4918b9
DIFF: https://github.com/llvm/llvm-project/commit/36f77e20d9aaaf93a9b00ec1bd6b7e3ceb4918b9.diff

LOG: Revert "Revert "[clang][Lex] Fix a crash on malformed string literals""

This reverts commit feea7ef23cb1bef92d363cc613052f8f3a878fc2.
Drops the test case, see https://reviews.llvm.org/D135161#3839510

Added: 
    

Modified: 
    clang/lib/Lex/LiteralSupport.cpp
    clang/test/Lexer/char-escapes-delimited.c
    clang/unittests/Lex/LexerTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Lex/LiteralSupport.cpp b/clang/lib/Lex/LiteralSupport.cpp
index 1a48a68c28b62..160240e49dd70 100644
--- a/clang/lib/Lex/LiteralSupport.cpp
+++ b/clang/lib/Lex/LiteralSupport.cpp
@@ -545,7 +545,6 @@ static bool ProcessNamedUCNEscape(const char *ThisTokBegin,
            diag::err_delimited_escape_missing_brace)
           << StringRef(&ThisTokBuf[-1], 1);
     }
-    ThisTokBuf++;
     return false;
   }
   ThisTokBuf++;

diff  --git a/clang/test/Lexer/char-escapes-delimited.c b/clang/test/Lexer/char-escapes-delimited.c
index 65e3dc740e3b4..43ade65a58309 100644
--- a/clang/test/Lexer/char-escapes-delimited.c
+++ b/clang/test/Lexer/char-escapes-delimited.c
@@ -94,7 +94,7 @@ void named(void) {
 
   unsigned h = U'\N{LOTUS}';                      // ext-warning {{extension}} cxx2b-warning {{C++2b}}
   unsigned i = u'\N{GREEK CAPITAL LETTER DELTA}'; // ext-warning {{extension}} cxx2b-warning {{C++2b}}
-  char j = '\NN';                                 // expected-error {{expected '{' after '\N' escape sequence}}
+  char j = '\NN';                                 // expected-error {{expected '{' after '\N' escape sequence}} expected-warning {{multi-character character constant}}
   unsigned k = u'\N{LOTUS';                       // expected-error {{incomplete universal character name}}
 }
 

diff  --git a/clang/unittests/Lex/LexerTest.cpp b/clang/unittests/Lex/LexerTest.cpp
index 0ad644ce71465..c5982b859289a 100644
--- a/clang/unittests/Lex/LexerTest.cpp
+++ b/clang/unittests/Lex/LexerTest.cpp
@@ -18,6 +18,7 @@
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/LiteralSupport.h"
 #include "clang/Lex/MacroArgs.h"
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/ModuleLoader.h"


        


More information about the cfe-commits mailing list