[cfe-commits] r147091 - in /cfe/trunk: lib/Lex/Lexer.cpp test/Lexer/escape_newline.c

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Dec 21 12:19:55 PST 2011


Author: akirtzidis
Date: Wed Dec 21 14:19:55 2011
New Revision: 147091

URL: http://llvm.org/viewvc/llvm-project?rev=147091&view=rev
Log:
In Lexer::getCharAndSizeSlow[NoWarn] make sure we don't go over the end of the buffer
when the end of the buffer is immediately after an escaped newline.

Fixes http://llvm.org/PR10153.

Modified:
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/test/Lexer/escape_newline.c

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=147091&r1=147090&r2=147091&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Dec 21 14:19:55 2011
@@ -1171,6 +1171,10 @@
       // Found backslash<whitespace><newline>.  Parse the char after it.
       Size += EscapedNewLineSize;
       Ptr  += EscapedNewLineSize;
+
+      if (Ptr[0] == '\0')
+        return '\\';
+
       // Use slow version to accumulate a correct size field.
       return getCharAndSizeSlow(Ptr, Size, Tok);
     }
@@ -1222,6 +1226,9 @@
       Size += EscapedNewLineSize;
       Ptr  += EscapedNewLineSize;
 
+      if (Ptr[0] == '\0')
+        return '\\';
+
       // Use slow version to accumulate a correct size field.
       return getCharAndSizeSlowNoWarn(Ptr, Size, Features);
     }

Modified: cfe/trunk/test/Lexer/escape_newline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/escape_newline.c?rev=147091&r1=147090&r2=147091&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/escape_newline.c (original)
+++ cfe/trunk/test/Lexer/escape_newline.c Wed Dec 21 14:19:55 2011
@@ -1,7 +1,10 @@
 // RUN: %clang_cc1 -E -trigraphs %s | grep -- ' ->'
 // RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'backslash and newline separated by space'
 // RUN: %clang_cc1 -E -trigraphs %s 2>&1 | grep 'trigraph converted'
+// RUN: %clang_cc1 -E -CC -trigraphs %s
 
 // This is an ugly way to spell a -> token.
  -??/      
 >
+
+// \





More information about the cfe-commits mailing list