mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-17 18:31:04 +00:00
ptx: bug fix: use after free
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120571 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7a874ddda0
commit
3608d2ac67
@ -130,20 +130,21 @@ void PTXAsmPrinter::EmitFunctionBodyStart() {
|
||||
}
|
||||
|
||||
void PTXAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||
SmallString<128> sstr;
|
||||
raw_svector_ostream OS(sstr);
|
||||
std::string str;
|
||||
str.reserve(64);
|
||||
|
||||
// Write instruction to str
|
||||
raw_string_ostream OS(str);
|
||||
printInstruction(MI, OS);
|
||||
OS << ';';
|
||||
OS.flush();
|
||||
|
||||
// Replace "%type" if found
|
||||
StringRef strref = OS.str();
|
||||
size_t pos;
|
||||
if ((pos = strref.find("%type")) != StringRef::npos) {
|
||||
std::string str = strref;
|
||||
if ((pos = str.find("%type")) != std::string::npos)
|
||||
str.replace(pos, /*strlen("%type")==*/5, getInstructionTypeName(MI));
|
||||
strref = StringRef(str);
|
||||
}
|
||||
|
||||
StringRef strref = StringRef(str);
|
||||
OutStreamer.EmitRawText(strref);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user