diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-28 22:16:56 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2015-02-28 22:16:56 +0000 |
commit | 79cf9705c790a42fb932cafe02244a0cea5a1476 (patch) | |
tree | f57dc66ed53f4a26aaf514eb21f73601cebbc014 /llvm/lib/IR/AsmWriter.cpp | |
parent | 3a46c142bf01f54549680fb3839df0928af124c8 (diff) | |
download | bcm5719-llvm-79cf9705c790a42fb932cafe02244a0cea5a1476.tar.gz bcm5719-llvm-79cf9705c790a42fb932cafe02244a0cea5a1476.zip |
AsmWriter: Extract writeStringField(), NFCI
Extract logic for escaping a string field in the new debug info
hierarchy from `GenericDebugNode`. A follow-up commit will use it far
more widely (hence the dead code for `ShouldSkipEmpty`).
llvm-svn: 230873
Diffstat (limited to 'llvm/lib/IR/AsmWriter.cpp')
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 51be1b00f21..05aa3c5c6d9 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1306,17 +1306,24 @@ static void writeTag(raw_ostream &Out, FieldSeparator &FS, const DebugNode *N) { Out << N->getTag(); } +static void writeStringField(raw_ostream &Out, FieldSeparator &FS, + StringRef Name, StringRef Value, + bool ShouldSkipEmpty = true) { + if (ShouldSkipEmpty && Value.empty()) + return; + + Out << FS << Name << ": \""; + PrintEscapedString(Value, Out); + Out << "\""; +} + static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context) { Out << "!GenericDebugNode("; FieldSeparator FS; writeTag(Out, FS, N); - if (!N->getHeader().empty()) { - Out << FS << "header: \""; - PrintEscapedString(N->getHeader(), Out); - Out << "\""; - } + writeStringField(Out, FS, "header", N->getHeader()); if (N->getNumDwarfOperands()) { Out << FS << "operands: {"; FieldSeparator IFS; |