forked from OSchip/llvm-project
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
This commit is contained in:
parent
3a46c142bf
commit
79cf9705c7
|
@ -1306,17 +1306,24 @@ static void writeTag(raw_ostream &Out, FieldSeparator &FS, const DebugNode *N) {
|
||||||
Out << N->getTag();
|
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,
|
static void writeGenericDebugNode(raw_ostream &Out, const GenericDebugNode *N,
|
||||||
TypePrinting *TypePrinter,
|
TypePrinting *TypePrinter,
|
||||||
SlotTracker *Machine, const Module *Context) {
|
SlotTracker *Machine, const Module *Context) {
|
||||||
Out << "!GenericDebugNode(";
|
Out << "!GenericDebugNode(";
|
||||||
FieldSeparator FS;
|
FieldSeparator FS;
|
||||||
writeTag(Out, FS, N);
|
writeTag(Out, FS, N);
|
||||||
if (!N->getHeader().empty()) {
|
writeStringField(Out, FS, "header", N->getHeader());
|
||||||
Out << FS << "header: \"";
|
|
||||||
PrintEscapedString(N->getHeader(), Out);
|
|
||||||
Out << "\"";
|
|
||||||
}
|
|
||||||
if (N->getNumDwarfOperands()) {
|
if (N->getNumDwarfOperands()) {
|
||||||
Out << FS << "operands: {";
|
Out << FS << "operands: {";
|
||||||
FieldSeparator IFS;
|
FieldSeparator IFS;
|
||||||
|
|
Loading…
Reference in New Issue