]> granicus.if.org Git - clang/commitdiff
- Add support for fuzzy parsing line-oriented __asm's (yuck).
authorSteve Naroff <snaroff@apple.com>
Thu, 7 Feb 2008 23:24:32 +0000 (23:24 +0000)
committerSteve Naroff <snaroff@apple.com>
Thu, 7 Feb 2008 23:24:32 +0000 (23:24 +0000)
- Change handling of __w64 to a built-in macro.

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

Lex/Preprocessor.cpp
Parse/ParseDecl.cpp
Parse/ParseStmt.cpp
include/clang/Basic/TokenKinds.def

index 2fe08c6715d8aa738f986da642e94a574cb1bbcc..141536a1be985c2418ead8459dadd06910cdaabc 100644 (file)
@@ -429,6 +429,7 @@ static void InitializePredefinedMacros(Preprocessor &PP,
     DefineBuiltinMacro(Buf, "__cdecl=");
     DefineBuiltinMacro(Buf, "_cdecl=");
     DefineBuiltinMacro(Buf, "__ptr64=");
+    DefineBuiltinMacro(Buf, "__w64=");
     DefineBuiltinMacro(Buf, "__forceinline=");
     DefineBuiltinMacro(Buf, "__int8=char");
     DefineBuiltinMacro(Buf, "__int16=short");
index 2fc4d0de216d991c5c830c01987a101e489b2c50..368887298e9a4c230cc57d854e0460d59ef58cde 100644 (file)
@@ -483,8 +483,6 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS) {
     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
index 052aa1a8eeca9cd25ebb8f7295c48bd469b23995..7da47e84f2b771289291686adbdf9d5c78fff89d 100644 (file)
@@ -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::ParseReturnStatement() {
 }
 
 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 @@ Parser::StmtResult Parser::ParseAsmStatement(bool &msAsm) {
   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();
   }
index f747da11e41f847514d0cabef3d7f4632c88dd91..d2fe914f82acff64a49921be60477c783eacb61c 100644 (file)
@@ -299,8 +299,7 @@ KEYWORD(__thread                    , EXTC90|EXTC99|EXTCPP|EXTCPP0x)
 // 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