diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-08-15 18:09:18 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-08-15 18:09:18 +0000 |
commit | 89c57a2198145564ab6d0b2ad10fee5a1131bd15 (patch) | |
tree | 3e422389ea5c144f3275ec5f607c773498010b20 /lib/Sema/SemaStmt.cpp | |
parent | 317d6ef9d55c3577606bc64eb1a89a51a325f66e (diff) |
[ms-inline asm] Capturing loop-scoped (std::string)Reg with a StringRef is bad.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaStmt.cpp')
-rw-r--r-- | lib/Sema/SemaStmt.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index 74e8cfed2e..e176e38dc2 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -2857,7 +2857,9 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, SourceLocation EndLoc) { // MS-style inline assembly is not fully supported, so emit a warning. Diag(AsmLoc, diag::warn_unsupported_msasm); + unsigned NumClobberRegs = 0; SmallVector<StringRef,4> Clobbers; + SmallVector<std::string,4> ClobberRegs; // Empty asm statements don't need to instantiate the AsmParser, etc. if (AsmToks.empty()) { @@ -2962,13 +2964,13 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, TheTarget->createMCInstPrinter(1, *MAI, *MII, *MRI, *STI); // Build the list of clobbers. + ClobberRegs.resize(NumClobberRegs + Desc.getNumDefs()); for (unsigned i = 0, e = Desc.getNumDefs(); i != e; ++i) { const llvm::MCOperand &Op = Inst.getOperand(i); if (!Op.isReg()) continue; - std::string Reg; - llvm::raw_string_ostream OS(Reg); + llvm::raw_string_ostream OS(ClobberRegs[NumClobberRegs]); IP->printRegName(OS, Op.getReg()); StringRef Clobber(OS.str()); @@ -2976,7 +2978,7 @@ StmtResult Sema::ActOnMSAsmStmt(SourceLocation AsmLoc, return StmtError(Diag(AsmLoc, diag::err_asm_unknown_register_name) << Clobber); // FIXME: Asm blocks may result in redundant clobbers. - Clobbers.push_back(Reg); + Clobbers.push_back(ClobberRegs[NumClobberRegs++]); } } |