Use getLogicalLineNumber() in FuzzyParseMicrosoftAsmStatement(), it's more general and simplifies the code.

llvm-svn: 46885
This commit is contained in:
Steve Naroff 2008-02-08 18:01:27 +00:00
parent 09d6ba1496
commit 8c099c3f03
2 changed files with 8 additions and 17 deletions

View File

@ -922,21 +922,13 @@ Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() {
// that the rest of the line is an assembly-language statement.
SourceManager &SrcMgr = PP.getSourceManager();
SourceLocation TokLoc = Tok.getLocation();
if (TokLoc.isFileID()) {
unsigned lineNo = SrcMgr.getLineNumber(TokLoc);
do {
ConsumeAnyToken();
TokLoc = Tok.getLocation();
} while (TokLoc.isFileID() && (SrcMgr.getLineNumber(TokLoc) == lineNo) &&
Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
Tok.isNot(tok::eof));
} else { // The asm tokens come from a macro expansion.
do {
ConsumeAnyToken();
TokLoc = Tok.getLocation();
} while (TokLoc.isMacroID() && Tok.isNot(tok::r_brace) &&
Tok.isNot(tok::semi) && Tok.isNot(tok::eof));
}
unsigned lineNo = SrcMgr.getLogicalLineNumber(TokLoc);
do {
ConsumeAnyToken();
TokLoc = Tok.getLocation();
} while ((SrcMgr.getLogicalLineNumber(TokLoc) == lineNo) &&
Tok.isNot(tok::r_brace) && Tok.isNot(tok::semi) &&
Tok.isNot(tok::eof));
}
return false;
}

View File

@ -5,6 +5,5 @@
void t1(void) { M }
void t2(void) { __asm int 0x2c }
// FIXME? We don't support fuzzy parsing line-oriented __asm's where the body is partially defined in a macro.
void t3(void) { __asm M2 0x2c } // expected-error{{expected ';' after expression}} expected-warning{{expression result unused}}
void t3(void) { __asm M2 0x2c }