]> granicus.if.org Git - clang/commitdiff
Integrate the following from the 'objective-rewrite' branch:
authorSteve Naroff <snaroff@apple.com>
Tue, 8 Dec 2009 16:38:12 +0000 (16:38 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 8 Dec 2009 16:38:12 +0000 (16:38 +0000)
http://llvm.org/viewvc/llvm-project?view=rev&revision=80043

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90860 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Lex/Lexer.cpp
test/Lexer/msdos-cpm-eof.c [new file with mode: 0644]

index 451e1cebfff697d92f380f59b133e5dafb30af7e..dc8609d4efc67c8e68c79138865f6f1be5c53a0f 100644 (file)
@@ -33,7 +33,7 @@
 #include <cctype>
 using namespace clang;
 
-static void InitCharacterInfo();
+static void InitCharacterInfo(LangOptions);
 
 //===----------------------------------------------------------------------===//
 // Token Class Implementation
@@ -59,7 +59,7 @@ tok::ObjCKeywordKind Token::getObjCKeywordID() const {
 
 void Lexer::InitLexer(const char *BufStart, const char *BufPtr,
                       const char *BufEnd) {
-  InitCharacterInfo();
+  InitCharacterInfo(Features);
 
   BufferStart = BufStart;
   BufferPtr = BufPtr;
@@ -253,7 +253,7 @@ enum {
 
 // Statically initialize CharInfo table based on ASCII character set
 // Reference: FreeBSD 7.2 /usr/share/misc/ascii
-static const unsigned char CharInfo[256] =
+static unsigned char CharInfo[256] =
 {
 // 0 NUL         1 SOH         2 STX         3 ETX
 // 4 EOT         5 ENQ         6 ACK         7 BEL
@@ -321,7 +321,7 @@ static const unsigned char CharInfo[256] =
    0           , 0           , 0           , 0
 };
 
-static void InitCharacterInfo() {
+static void InitCharacterInfo(LangOptions Features) {
   static bool isInited = false;
   if (isInited) return;
   // check the statically-initialized CharInfo table
@@ -339,6 +339,11 @@ static void InitCharacterInfo() {
   }
   for (unsigned i = '0'; i <= '9'; ++i)
     assert(CHAR_NUMBER == CharInfo[i]);
+    
+  if (Features.Microsoft)
+    // Hack to treat DOS & CP/M EOF (^Z) as horizontal whitespace.
+    CharInfo[26/*sub*/] = CHAR_HORZ_WS;  
+
   isInited = true;
 }
 
diff --git a/test/Lexer/msdos-cpm-eof.c b/test/Lexer/msdos-cpm-eof.c
new file mode 100644 (file)
index 0000000..e4dacd9
--- /dev/null
@@ -0,0 +1,5 @@
+// RUN: clang-cc -fsyntax-only -verify -fms-extensions %s
+
+int a;
+
+\1a