9 #ifndef LLVM_CLANG_BASIC_JSONSUPPORT_H
10 #define LLVM_CLANG_BASIC_JSONSUPPORT_H
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/raw_ostream.h"
20 inline raw_ostream &
Indent(raw_ostream &Out,
const unsigned int Space,
22 for (
unsigned int I = 0; I < Space * 2; ++I)
23 Out << (IsDot ?
" " :
" ");
37 Pos = Str.find(
'\\', Pos);
38 if (Pos == std::string::npos)
42 size_t TempPos = (Pos != 0) ? Pos - 1 : 0;
45 if (TempPos != Str.find(
"\\\\", Pos)) {
46 Str.insert(Pos,
"\\");
56 Pos = Str.find(
'\"', Pos);
57 if (Pos == std::string::npos)
61 size_t TempPos = (Pos != 0) ? Pos - 1 : 0;
64 if (TempPos != Str.find(
"\\\"", Pos)) {
65 Str.insert(Pos,
"\\");
73 Str.erase(
std::remove(Str.begin(), Str.end(),
'\n'), Str.end());
78 return '\"' + Str +
'\"';
83 bool AddBraces =
true) {
104 std::remove_if(filename.begin(), filename.end(), [](
auto Char) {
105 static const char ForbiddenChars[] =
"<>*?\"|";
106 return std::find(std::begin(ForbiddenChars), std::end(ForbiddenChars),
107 Char) != std::end(ForbiddenChars);
109 filename.erase(RemoveIt, filename.end());
111 std::replace(filename.begin(), filename.end(),
'\\',
'/');
113 Out <<
"\"line\": " << PLoc.
getLine()
115 <<
", \"file\": \"" << filename <<
"\"";
126 Out <<
", \"spelling\": ";
132 #endif // LLVM_CLANG_BASIC_JSONSUPPORT_H