From 088b472eed92260ac34a6602752ad4abed291e31 Mon Sep 17 00:00:00 2001 From: Nick Hildenbrandt Date: Wed, 6 Nov 2002 21:40:23 +0000 Subject: [PATCH] Fixes escapeing bug in strings. Fixes test case test/Regression/CBackend/2002-11-06-PrintEscaped.c git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4583 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/CBackend/CBackend.cpp | 4 ++-- lib/Target/CBackend/Writer.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index cdbe62d104c..0e274c70cc0 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -297,8 +297,8 @@ void CWriter::printConstantArray(ConstantArray *CPA) { (unsigned char)cast(CPA->getOperand(i))->getValue(); if (isprint(C)) { - if (C == '"') - Out << "\\\""; + if (C == '"' || C == '\\') + Out << "\\" << C; else Out << C; } else { diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index cdbe62d104c..0e274c70cc0 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -297,8 +297,8 @@ void CWriter::printConstantArray(ConstantArray *CPA) { (unsigned char)cast(CPA->getOperand(i))->getValue(); if (isprint(C)) { - if (C == '"') - Out << "\\\""; + if (C == '"' || C == '\\') + Out << "\\" << C; else Out << C; } else { -- 2.34.1