virtual bool runOnFunction(Function &F) {
HelloCounter++;
- std::string fname = F.getName();
- EscapeString(fname);
- errs() << "Hello: " << fname << "\n";
+ errs() << "Hello: ";
+ errs().write_escaped(F.getName()) << '\n';
return false;
}
};
virtual bool runOnFunction(Function &F) {
HelloCounter++;
- std::string fname = F.getName();
- EscapeString(fname);
- errs() << "Hello: " << fname << "\n";
+ errs() << "Hello: ";
+ errs().write_escaped(F.getName()) << '\n';
return false;
}
// Description string.
OS << ", \"";
- std::string S = R.getValueAsString("Text");
- EscapeString(S);
- OS << S << "\"";
+ OS.write_escaped(R.getValueAsString("Text")) << '"';
// Warning associated with the diagnostic.
if (DefInit *DI = dynamic_cast<DefInit*>(R.getValueInit("Group"))) {
- S = DI->getDef()->getValueAsString("GroupName");
- EscapeString(S);
- OS << ", \"" << S << "\"";
+ OS << ", \"";
+ OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"';
} else {
OS << ", 0";
}
OS << "\n#ifdef GET_DIAG_TABLE\n";
for (std::map<std::string, GroupInfo>::iterator
I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) {
- std::string S = I->first;
- EscapeString(S);
// Group option string.
- OS << " { \"" << S << "\","
- << std::string(MaxLen-I->first.size()+1, ' ');
+ OS << " { \"";
+ OS.write_escaped(I->first) << "\","
+ << std::string(MaxLen-I->first.size()+1, ' ');
// Diagnostics in the group.
if (I->second.DiagsInGroup.empty())
#ifndef TBLGEN_STRING_TO_OFFSET_TABLE_H
#define TBLGEN_STRING_TO_OFFSET_TABLE_H
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringMap.h"
-#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/raw_ostream.h"
namespace llvm {
}
void EmitString(raw_ostream &O) {
+ // Escape the string.
+ SmallString<256> Str;
+ raw_svector_ostream(Str).write_escaped(AggregateString);
+ AggregateString = Str.str();
+
O << " \"";
unsigned CharsPrinted = 0;
- EscapeString(AggregateString);
for (unsigned i = 0, e = AggregateString.size(); i != e; ++i) {
if (CharsPrinted > 70) {
O << "\"\n \"";