[llvm] r230873 - AsmWriter: Extract writeStringField(), NFCI
Duncan P. N. Exon Smith
dexonsmith at apple.com
Sat Feb 28 14:16:56 PST 2015
Author: dexonsmith
Date: Sat Feb 28 16:16:56 2015
New Revision: 230873
URL: http://llvm.org/viewvc/llvm-project?rev=230873&view=rev
Log:
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`).
Modified:
llvm/trunk/lib/IR/AsmWriter.cpp
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=230873&r1=230872&r2=230873&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Sat Feb 28 16:16:56 2015
@@ -1306,17 +1306,24 @@ static void writeTag(raw_ostream &Out, F
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;
More information about the llvm-commits
mailing list