diff options
author | Steve Naroff <snaroff@apple.com> | 2008-02-08 03:36:19 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-02-08 03:36:19 +0000 |
commit | db5f7d769954f6e2f7662ce140e16615a17baa60 (patch) | |
tree | 452b9c49c48ef171c653e7b49ff280765a9af224 /clang/Parse/ParseStmt.cpp | |
parent | 7a55a94ba1dee753091698d569aaabefec83e5c1 (diff) | |
download | bcm5719-llvm-db5f7d769954f6e2f7662ce140e16615a17baa60.tar.gz bcm5719-llvm-db5f7d769954f6e2f7662ce140e16615a17baa60.zip |
Support fuzzy parsing MS line-oriented __asm's that originate from a macro (a case where we can't obtain source line info). As the test case indicates, we don't currently support line-oriented asm statements that mix file/macro body tokens.
llvm-svn: 46878
Diffstat (limited to 'clang/Parse/ParseStmt.cpp')
-rw-r--r-- | clang/Parse/ParseStmt.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/clang/Parse/ParseStmt.cpp b/clang/Parse/ParseStmt.cpp index 7da47e84f2b..4be3f1e40a9 100644 --- a/clang/Parse/ParseStmt.cpp +++ b/clang/Parse/ParseStmt.cpp @@ -921,11 +921,22 @@ Parser::StmtResult Parser::FuzzyParseMicrosoftAsmStatement() { // 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)); + 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)); + } } return false; } |