From bd7fdadb901d086ca3f612e7eaefcb9cbbbe5fc8 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Tue, 11 Sep 2012 00:51:28 +0000 Subject: [ms-inline asm] Add $$ before numeric constants in the IR. llvm-svn: 163581 --- clang/lib/Sema/SemaStmtAsm.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'clang/lib/Sema/SemaStmtAsm.cpp') diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 5cab02d9248..78e55317251 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -413,9 +413,9 @@ static void buildMSAsmPieces(std::vector &AsmStrings, buildMSAsmPieces(AsmStrings[i], Pieces[i]); } -// Build the unmodified AsmString used by the IR. Also build the individual -// asm instruction(s) and place them in the AsmStrings vector; these are fed -// to the AsmParser. +// Build the AsmString used by the IR. Also build the individual asm +// instruction(s) and place them in the AsmStrings vector; these are fed to the +// AsmParser. static std::string buildMSAsmString(Sema &SemaRef, ArrayRef AsmToks, std::vector &AsmStrings, std::vector > &AsmTokRanges) { @@ -433,9 +433,8 @@ static std::string buildMSAsmString(Sema &SemaRef, ArrayRef AsmToks, AsmStrings.push_back(Asm.str()); AsmTokRanges.push_back(std::make_pair(startTok, i-1)); startTok = i; - Res += Asm; Asm.clear(); - Res += '\n'; + Res += "\n\t"; } if (AsmToks[i].is(tok::kw_asm)) { i++; // Skip __asm @@ -443,14 +442,20 @@ static std::string buildMSAsmString(Sema &SemaRef, ArrayRef AsmToks, } } - if (i && AsmToks[i].hasLeadingSpace() && !isNewAsm) + if (i && AsmToks[i].hasLeadingSpace() && !isNewAsm) { Asm += ' '; + Res += ' '; + } + + if (AsmToks[i].is(tok::numeric_constant)) + Res += "$$"; - Asm += getSpelling(SemaRef, AsmToks[i]); + StringRef Spelling = getSpelling(SemaRef, AsmToks[i]); + Asm += Spelling; + Res += Spelling; } AsmStrings.push_back(Asm.str()); AsmTokRanges.push_back(std::make_pair(startTok, AsmToks.size()-1)); - Res += Asm; return Res.str(); } -- cgit v1.2.3