mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-17 21:35:07 +00:00
Fix escaping in asm string literals correctly by having tblgen unescape
them, then the asmprinter emitter reescape them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66958 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e023bb6936
commit
7f3b28a786
@ -130,11 +130,20 @@ AsmWriterInst::AsmWriterInst(const CodeGenInstruction &CGI, unsigned Variant) {
|
||||
|
||||
// Emit a constant string fragment.
|
||||
if (DollarPos != LastEmitted) {
|
||||
// TODO: this should eventually handle escaping.
|
||||
if (CurVariant == Variant || CurVariant == ~0U)
|
||||
AddLiteralString(std::string(AsmString.begin()+LastEmitted,
|
||||
AsmString.begin()+DollarPos));
|
||||
LastEmitted = DollarPos;
|
||||
if (CurVariant == Variant || CurVariant == ~0U) {
|
||||
for (; LastEmitted != DollarPos; ++LastEmitted)
|
||||
switch (AsmString[LastEmitted]) {
|
||||
case '\n': AddLiteralString("\\n"); break;
|
||||
case '\t': AddLiteralString("\\t"); break;
|
||||
case '"': AddLiteralString("\\\""); break;
|
||||
case '\\': AddLiteralString("\\\\"); break;
|
||||
default:
|
||||
AddLiteralString(std::string(1, AsmString[LastEmitted]));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
LastEmitted = DollarPos;
|
||||
}
|
||||
} else if (AsmString[DollarPos] == '\\') {
|
||||
if (DollarPos+1 != AsmString.size() &&
|
||||
(CurVariant == Variant || CurVariant == ~0U)) {
|
||||
|
@ -174,11 +174,11 @@ tgtok::TokKind TGLexer::LexString() {
|
||||
CurStrVal += *CurPtr++;
|
||||
break;
|
||||
case 't':
|
||||
CurStrVal += "\\t";
|
||||
CurStrVal += '\t';
|
||||
++CurPtr;
|
||||
break;
|
||||
case 'n':
|
||||
CurStrVal += "\\n";
|
||||
CurStrVal += '\n';
|
||||
++CurPtr;
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user