aboutsummaryrefslogtreecommitdiff
path: root/lib/Parse/ParseStmt.cpp
diff options
context:
space:
mode:
authorChad Rosier <mcrosier@apple.com>2012-08-08 19:48:07 +0000
committerChad Rosier <mcrosier@apple.com>2012-08-08 19:48:07 +0000
commit62f22b87801882646418bae85111e565f7a53ddb (patch)
treec6b561e44f60d562e6626405c6ed058ee373099f /lib/Parse/ParseStmt.cpp
parentd24bf90ae72d7df5e0ef0a1d3dd2806462ec15b1 (diff)
[ms-inline asm] Refactor the logic to generate the AsmString into Sema. No
functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161518 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Parse/ParseStmt.cpp')
-rw-r--r--lib/Parse/ParseStmt.cpp61
1 files changed, 2 insertions, 59 deletions
diff --git a/lib/Parse/ParseStmt.cpp b/lib/Parse/ParseStmt.cpp
index 56e87e4904..d2e4309c3f 100644
--- a/lib/Parse/ParseStmt.cpp
+++ b/lib/Parse/ParseStmt.cpp
@@ -1638,41 +1638,6 @@ StmtResult Parser::ParseReturnStatement() {
return Actions.ActOnReturnStmt(ReturnLoc, R.take());
}
-// needSpaceAsmToken - This function handles whitespace around asm punctuation.
-// Returns true if a space should be emitted.
-static inline bool needSpaceAsmToken(Token currTok) {
- static Token prevTok;
-
- // No need for space after prevToken.
- switch(prevTok.getKind()) {
- default:
- break;
- case tok::l_square:
- case tok::r_square:
- case tok::l_brace:
- case tok::r_brace:
- case tok::colon:
- prevTok = currTok;
- return false;
- }
-
- // No need for a space before currToken.
- switch(currTok.getKind()) {
- default:
- break;
- case tok::l_square:
- case tok::r_square:
- case tok::l_brace:
- case tok::r_brace:
- case tok::comma:
- case tok::colon:
- prevTok = currTok;
- return false;
- }
- prevTok = currTok;
- return true;
-}
-
/// ParseMicrosoftAsmStatement. When -fms-extensions/-fasm-blocks is enabled,
/// this routine is called to collect the tokens for an MS asm statement.
///
@@ -1795,31 +1760,9 @@ StmtResult Parser::ParseMicrosoftAsmStatement(SourceLocation AsmLoc) {
EndLoc = ConsumeToken();
} while (1);
- // Collect the tokens into a string
- SmallString<512> Asm;
- SmallString<512> TokenBuf;
- TokenBuf.resize(512);
- unsigned AsmLineNum = 0;
- for (unsigned i = 0, e = AsmToks.size(); i < e; ++i) {
- const char *ThisTokBuf = &TokenBuf[0];
- bool StringInvalid = false;
- unsigned ThisTokLen =
- Lexer::getSpelling(AsmToks[i], ThisTokBuf, PP.getSourceManager(),
- PP.getLangOpts(), &StringInvalid);
- if (i && (!AsmLineNum || i != LineEnds[AsmLineNum-1]) &&
- needSpaceAsmToken(AsmToks[i]))
- Asm += ' ';
- Asm += StringRef(ThisTokBuf, ThisTokLen);
- if (i + 1 == LineEnds[AsmLineNum] && i + 1 != AsmToks.size()) {
- Asm += '\n';
- ++AsmLineNum;
- }
- }
-
// FIXME: We should be passing source locations for better diagnostics.
- std::string AsmString = Asm.c_str();
- return Actions.ActOnMSAsmStmt(AsmLoc, llvm::makeArrayRef(AsmToks), AsmString,
- EndLoc);
+ return Actions.ActOnMSAsmStmt(AsmLoc, llvm::makeArrayRef(AsmToks),
+ llvm::makeArrayRef(LineEnds), EndLoc);
}
/// ParseAsmStatement - Parse a GNU extended asm statement.