[llvm-commits] [llvm] r66958 - in /llvm/trunk/utils/TableGen: AsmWriterEmitter.cpp TGLexer.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 13 14:33:17 PDT 2009
Author: lattner
Date: Fri Mar 13 16:33:17 2009
New Revision: 66958
URL: http://llvm.org/viewvc/llvm-project?rev=66958&view=rev
Log:
Fix escaping in asm string literals correctly by having tblgen unescape
them, then the asmprinter emitter reescape them.
Modified:
llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
llvm/trunk/utils/TableGen/TGLexer.cpp
Modified: llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp?rev=66958&r1=66957&r2=66958&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmWriterEmitter.cpp Fri Mar 13 16:33:17 2009
@@ -130,11 +130,20 @@
// 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)) {
Modified: llvm/trunk/utils/TableGen/TGLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGLexer.cpp?rev=66958&r1=66957&r2=66958&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/TGLexer.cpp (original)
+++ llvm/trunk/utils/TableGen/TGLexer.cpp Fri Mar 13 16:33:17 2009
@@ -174,11 +174,11 @@
CurStrVal += *CurPtr++;
break;
case 't':
- CurStrVal += "\\t";
+ CurStrVal += '\t';
++CurPtr;
break;
case 'n':
- CurStrVal += "\\n";
+ CurStrVal += '\n';
++CurPtr;
break;
More information about the llvm-commits
mailing list