[cfe-commits] r46864 - in /cfe/trunk: Lex/Preprocessor.cpp Parse/ParseDecl.cpp Parse/ParseStmt.cpp include/clang/Basic/TokenKinds.def

Steve Naroff snaroff at apple.com
Thu Feb 7 15:24:33 PST 2008


Author: snaroff
Date: Thu Feb  7 17:24:32 2008
New Revision: 46864

URL: http://llvm.org/viewvc/llvm-project?rev=46864&view=rev
Log:

- Add support for fuzzy parsing line-oriented __asm's (yuck).
- Change handling of __w64 to a built-in macro.


Modified:
    cfe/trunk/Lex/Preprocessor.cpp
    cfe/trunk/Parse/ParseDecl.cpp
    cfe/trunk/Parse/ParseStmt.cpp
    cfe/trunk/include/clang/Basic/TokenKinds.def

Modified: cfe/trunk/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Lex/Preprocessor.cpp?rev=46864&r1=46863&r2=46864&view=diff

==============================================================================
--- cfe/trunk/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/Lex/Preprocessor.cpp Thu Feb  7 17:24:32 2008
@@ -429,6 +429,7 @@
     DefineBuiltinMacro(Buf, "__cdecl=");
     DefineBuiltinMacro(Buf, "_cdecl=");
     DefineBuiltinMacro(Buf, "__ptr64=");
+    DefineBuiltinMacro(Buf, "__w64=");
     DefineBuiltinMacro(Buf, "__forceinline=");
     DefineBuiltinMacro(Buf, "__int8=char");
     DefineBuiltinMacro(Buf, "__int16=short");

Modified: cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseDecl.cpp?rev=46864&r1=46863&r2=46864&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/Parse/ParseDecl.cpp Thu Feb  7 17:24:32 2008
@@ -483,8 +483,6 @@
     case tok::kw_typedef:
       isInvalid = DS.SetStorageClassSpec(DeclSpec::SCS_typedef, Loc, PrevSpec);
       break;
-    case tok::kw___w64: // ignore Microsoft specifier
-      break;
     case tok::kw___declspec:
       FuzzyParseMicrosoftDeclspec();
       // Don't consume the next token, __declspec's can appear one after

Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=46864&r1=46863&r2=46864&view=diff

==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Thu Feb  7 17:24:32 2008
@@ -14,6 +14,7 @@
 
 #include "clang/Parse/Parser.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/SourceManager.h"
 #include "clang/Parse/DeclSpec.h"
 #include "clang/Parse/Scope.h"
 using namespace clang;
@@ -911,10 +912,21 @@
 }
 
 Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
-  unsigned short savedBraceCount = BraceCount;
-  do {
-    ConsumeAnyToken();
-  } while (BraceCount > savedBraceCount && Tok.isNot(tok::eof));
+  if (Tok.is(tok::l_brace)) {
+    unsigned short savedBraceCount = BraceCount;
+    do {
+      ConsumeAnyToken();
+    } while (BraceCount > savedBraceCount && Tok.isNot(tok::eof));
+  } else { 
+    // From the MS website: If used without braces, the __asm keyword means
+    // that the rest of the line is an assembly-language statement.
+    SourceManager &SrcMgr = PP.getSourceManager();
+    unsigned lineNo = SrcMgr.getLineNumber(Tok.getLocation());
+    do {
+      ConsumeAnyToken();
+    } while ((SrcMgr.getLineNumber(Tok.getLocation()) == lineNo) && 
+             Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof));
+  }
   return false;
 }
 
@@ -937,7 +949,7 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
   SourceLocation AsmLoc = ConsumeToken();
   
-  if (Tok.is(tok::l_brace)) {
+  if (getLang().Microsoft && Tok.isNot(tok::l_paren)) {
     msAsm = true;
     return FuzzyParseMicrosoftAsmStatement();
   }

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=46864&r1=46863&r2=46864&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Thu Feb  7 17:24:32 2008
@@ -299,8 +299,7 @@
 // Apple Extension.
 KEYWORD(__private_extern__          , EXTC90|EXTC99|NOTCPP)
 
-// Microsoft Extensions.
-KEYWORD(__w64          , EXTC90|EXTC99|NOTCPP)
+// Microsoft Extension.
 KEYWORD(__declspec     , EXTC90|EXTC99|NOTCPP)
 
 // Alternate spelling for various tokens.  There are GCC extensions in all





More information about the cfe-commits mailing list