9 #ifndef LLVM_CLANG_BASIC_JSONSUPPORT_H
10 #define LLVM_CLANG_BASIC_JSONSUPPORT_H
14 #include "llvm/ADT/StringRef.h"
15 #include "llvm/Support/Path.h"
16 #include "llvm/Support/raw_ostream.h"
21 inline raw_ostream &
Indent(raw_ostream &Out,
const unsigned int Space,
23 for (
unsigned int I = 0; I < Space * 2; ++I)
24 Out << (IsDot ?
" " :
" ");
38 Pos = Str.find(
'\\', Pos);
39 if (Pos == std::string::npos)
43 size_t TempPos = (Pos != 0) ? Pos - 1 : 0;
46 if (TempPos != Str.find(
"\\\\", Pos)) {
47 Str.insert(Pos,
"\\");
57 Pos = Str.find(
'\"', Pos);
58 if (Pos == std::string::npos)
62 size_t TempPos = (Pos != 0) ? Pos - 1 : 0;
65 if (TempPos != Str.find(
"\\\"", Pos)) {
66 Str.insert(Pos,
"\\");
74 llvm::erase_value(Str,
'\n');
79 return '\"' + Str +
'\"';
84 bool AddBraces =
true) {
102 if (is_style_windows(llvm::sys::path::Style::native)) {
105 std::remove_if(filename.begin(), filename.end(), [](
auto Char) {
106 static const char ForbiddenChars[] =
"<>*?\"|";
107 return std::find(std::begin(ForbiddenChars),
108 std::end(ForbiddenChars),
109 Char) != std::end(ForbiddenChars);
111 filename.erase(RemoveIt, filename.end());
113 std::replace(filename.begin(), filename.end(),
'\\',
'/');
115 Out <<
"\"line\": " << PLoc.
getLine()
117 <<
", \"file\": \"" << filename <<
"\"";
128 Out <<
", \"spelling\": ";
134 #endif // LLVM_CLANG_BASIC_JSONSUPPORT_H