aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-07 23:16:37 +0000
committerChris Lattner <sabre@nondot.org>2010-07-07 23:16:37 +0000
commit7b880dc38cc2ba5ddd18c44f716ec87b58d0f484 (patch)
tree000882bcac59da47a13f2e33f5c4f5e0f4182740 /lib
parent5e49a2a15f0c0404c8e06564aca8cbd41f499ab7 (diff)
downloadexternal_llvm-7b880dc38cc2ba5ddd18c44f716ec87b58d0f484.zip
external_llvm-7b880dc38cc2ba5ddd18c44f716ec87b58d0f484.tar.gz
external_llvm-7b880dc38cc2ba5ddd18c44f716ec87b58d0f484.tar.bz2
use PrintEscapedString to handle attribute section with escapes in it,
PR7399. The asm parser already handles this. This is of dubious utility (see the PR) but the asmprinter was clearly broken here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@107834 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/AsmWriter.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index e98636b..3150cec 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -70,8 +70,7 @@ static const Module *getModuleFromVal(const Value *V) {
// PrintEscapedString - Print each character of the specified string, escaping
// it if it is not printable or if it is an escape char.
-static void PrintEscapedString(const StringRef &Name,
- raw_ostream &Out) {
+static void PrintEscapedString(StringRef Name, raw_ostream &Out) {
for (unsigned i = 0, e = Name.size(); i != e; ++i) {
unsigned char C = Name[i];
if (isprint(C) && C != '\\' && C != '"')
@@ -1472,8 +1471,11 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) {
writeOperand(GV->getInitializer(), false);
}
- if (GV->hasSection())
- Out << ", section \"" << GV->getSection() << '"';
+ if (GV->hasSection()) {
+ Out << ", section \"";
+ PrintEscapedString(GV->getSection(), Out);
+ Out << '"';
+ }
if (GV->getAlignment())
Out << ", align " << GV->getAlignment();
@@ -1631,8 +1633,11 @@ void AssemblyWriter::printFunction(const Function *F) {
Attributes FnAttrs = Attrs.getFnAttributes();
if (FnAttrs != Attribute::None)
Out << ' ' << Attribute::getAsString(Attrs.getFnAttributes());
- if (F->hasSection())
- Out << " section \"" << F->getSection() << '"';
+ if (F->hasSection()) {
+ Out << " section \"";
+ PrintEscapedString(F->getSection(), Out);
+ Out << '"';
+ }
if (F->getAlignment())
Out << " align " << F->getAlignment();
if (F->hasGC())