[cfe-commits] r46977 - in /cfe/trunk: Parse/ParseDecl.cpp Parse/ParseStmt.cpp include/clang/Parse/Parser.h
Steve Naroff
snaroff at apple.com
Mon Feb 11 15:15:56 PST 2008
Author: snaroff
Date: Mon Feb 11 17:15:56 2008
New Revision: 46977
URL: http://llvm.org/viewvc/llvm-project?rev=46977&view=rev
Log:
Several cleanups surrounding Parser::ParseAsmStatement() and Parser::FuzzyParseMicrosoftAsmStatement().
Modified:
cfe/trunk/Parse/ParseDecl.cpp
cfe/trunk/Parse/ParseStmt.cpp
cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/trunk/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseDecl.cpp?rev=46977&r1=46976&r2=46977&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/Parse/ParseDecl.cpp Mon Feb 11 17:15:56 2008
@@ -872,6 +872,19 @@
}
/// isTypeSpecifierQualifier - Return true if the current token could be the
+/// start of a type-qualifier-list.
+bool Parser::isTypeQualifier() const {
+ switch (Tok.getKind()) {
+ default: return false;
+ // type-qualifier
+ case tok::kw_const:
+ case tok::kw_volatile:
+ case tok::kw_restrict:
+ return true;
+ }
+}
+
+/// isTypeSpecifierQualifier - Return true if the current token could be the
/// start of a specifier-qualifier-list.
bool Parser::isTypeSpecifierQualifier() const {
switch (Tok.getKind()) {
Modified: cfe/trunk/Parse/ParseStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Parse/ParseStmt.cpp?rev=46977&r1=46976&r2=46977&view=diff
==============================================================================
--- cfe/trunk/Parse/ParseStmt.cpp (original)
+++ cfe/trunk/Parse/ParseStmt.cpp Mon Feb 11 17:15:56 2008
@@ -911,6 +911,8 @@
return Actions.ActOnReturnStmt(ReturnLoc, R.Val);
}
+/// FuzzyParseMicrosoftAsmStatement. When -fms-extensions is enabled, this
+/// routine is called to skip/ignore tokens that comprise the MS asm statement.
Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
if (Tok.is(tok::l_brace)) {
unsigned short savedBraceCount = BraceCount;
@@ -934,7 +936,11 @@
}
/// ParseAsmStatement - Parse a GNU extended asm statement.
-/// [GNU] asm-statement:
+/// asm-statement:
+/// gnu-asm-statement
+/// ms-asm-statement
+///
+/// [GNU] gnu-asm-statement:
/// 'asm' type-qualifier[opt] '(' asm-argument ')' ';'
///
/// [GNU] asm-argument:
@@ -948,11 +954,19 @@
/// asm-string-literal
/// asm-clobbers ',' asm-string-literal
///
+/// [MS] ms-asm-statement:
+/// '__asm' assembly-instruction ';'[opt]
+/// '__asm' '{' assembly-instruction-list '}' ';'[opt]
+///
+/// [MS] assembly-instruction-list:
+/// assembly-instruction ';'[opt]
+/// assembly-instruction-list ';' assembly-instruction ';'[opt]
+///
Parser::StmtResult Parser::ParseAsmStatement(bool &msAsm) {
assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
SourceLocation AsmLoc = ConsumeToken();
- if (getLang().Microsoft && Tok.isNot(tok::l_paren)) {
+ if (getLang().Microsoft && Tok.isNot(tok::l_paren) && !isTypeQualifier()) {
msAsm = true;
return FuzzyParseMicrosoftAsmStatement();
}
Modified: cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=46977&r1=46976&r2=46977&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/trunk/include/clang/Parse/Parser.h Mon Feb 11 17:15:56 2008
@@ -439,6 +439,7 @@
bool isDeclarationSpecifier() const;
bool isTypeSpecifierQualifier() const;
+ bool isTypeQualifier() const;
TypeTy *ParseTypeName();
AttributeList *ParseAttributes();
More information about the cfe-commits
mailing list