r173959 - Fix r173881 to properly skip invalid UTF-8 characters in raw lexing and -E.

Jordan Rose jordan_rose at apple.com
Wed Jan 30 11:21:12 PST 2013


Author: jrose
Date: Wed Jan 30 13:21:12 2013
New Revision: 173959

URL: http://llvm.org/viewvc/llvm-project?rev=173959&view=rev
Log:
Fix r173881 to properly skip invalid UTF-8 characters in raw lexing and -E.

This caused hangs as we processed the same invalid byte over and over.

<rdar://problem/13115651>

Modified:
    cfe/trunk/lib/Lex/Lexer.cpp
    cfe/trunk/test/Lexer/utf8-invalid.c

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=173959&r1=173958&r2=173959&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Jan 30 13:21:12 2013
@@ -3538,6 +3538,7 @@ LexNextToken:
       return LexUnicode(Result, CodePoint, CurPtr);
     
     if (isLexingRawMode() || PP->isPreprocessedOutput()) {
+      ++CurPtr;
       Kind = tok::unknown;
       break;
     }

Modified: cfe/trunk/test/Lexer/utf8-invalid.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/utf8-invalid.c?rev=173959&r1=173958&r2=173959&view=diff
==============================================================================
--- cfe/trunk/test/Lexer/utf8-invalid.c (original)
+++ cfe/trunk/test/Lexer/utf8-invalid.c Wed Jan 30 13:21:12 2013
@@ -1,6 +1,12 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -E %s -o /dev/null
 
 // Note: this file contains invalid UTF-8 before the variable name in the
 // next line. Please do not fix!
 
 extern int ‚x; // expected-error{{source file is not valid UTF-8}}
+
+#if 0
+// Don't warn about bad UTF-8 in raw lexing mode.
+extern int ‚x;
+#endif





More information about the cfe-commits mailing list