[llvm-branch-commits] [cfe-branch] r168808 - in /cfe/branches/release_32: ./ lib/Lex/Lexer.cpp test/Lexer/eof-char.c test/Lexer/eof-file.c test/Lexer/eof-string.c

Pawel Wodnicki pawel at 32bitmicro.com
Wed Nov 28 12:50:18 PST 2012


Author: pawel
Date: Wed Nov 28 14:50:18 2012
New Revision: 168808

URL: http://llvm.org/viewvc/llvm-project?rev=168808&view=rev
Log:
Merging r168269: into the 3.2 release branch.

Fix crash on end-of-file after \ in a char literal, fixes PR14369.

This makes LexCharConstant() look more like LexStringLiteral(), which doesn't
have this bug. Add tests for eof after \ for several other cases.

Added:
    cfe/branches/release_32/test/Lexer/eof-char.c
      - copied unchanged from r168269, cfe/trunk/test/Lexer/eof-char.c
    cfe/branches/release_32/test/Lexer/eof-file.c
      - copied unchanged from r168269, cfe/trunk/test/Lexer/eof-file.c
    cfe/branches/release_32/test/Lexer/eof-string.c
      - copied unchanged from r168269, cfe/trunk/test/Lexer/eof-string.c
Modified:
    cfe/branches/release_32/   (props changed)
    cfe/branches/release_32/lib/Lex/Lexer.cpp

Propchange: cfe/branches/release_32/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 28 14:50:18 2012
@@ -1,3 +1,3 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:167749,167762,167780,167788,167790,167813-167814,167868,167884,167920,167925,167935,168024,168063,168124,168277-168278,168297,168355,168379
+/cfe/trunk:167749,167762,167780,167788,167790,167813-167814,167868,167884,167920,167925,167935,168024,168063,168124,168269,168277-168278,168297,168355,168379
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_32/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_32/lib/Lex/Lexer.cpp?rev=168808&r1=168807&r2=168808&view=diff
==============================================================================
--- cfe/branches/release_32/lib/Lex/Lexer.cpp (original)
+++ cfe/branches/release_32/lib/Lex/Lexer.cpp Wed Nov 28 14:50:18 2012
@@ -1816,17 +1816,18 @@
 
   while (C != '\'') {
     // Skip escaped characters.
-    if (C == '\\') {
-      // Skip the escaped character.
-      // FIXME: UCN's
-      getAndAdvanceChar(CurPtr, Result);
-    } else if (C == '\n' || C == '\r' ||             // Newline.
-               (C == 0 && CurPtr-1 == BufferEnd)) {  // End of file.
+    if (C == '\\')
+      C = getAndAdvanceChar(CurPtr, Result);
+
+    if (C == '\n' || C == '\r' ||             // Newline.
+        (C == 0 && CurPtr-1 == BufferEnd)) {  // End of file.
       if (!isLexingRawMode() && !LangOpts.AsmPreprocessor)
         Diag(BufferPtr, diag::ext_unterminated_char);
       FormTokenWithChars(Result, CurPtr-1, tok::unknown);
       return;
-    } else if (C == 0) {
+    }
+
+    if (C == 0) {
       if (isCodeCompletionPoint(CurPtr-1)) {
         PP->CodeCompleteNaturalLanguage();
         FormTokenWithChars(Result, CurPtr-1, tok::unknown);





More information about the llvm-branch-commits mailing list