@@ -336,7 +336,7 @@ static void discoverCrosssImportOverlayDependencies(
336
336
template <typename T>
337
337
void writeJSONSingleField (llvm::raw_ostream &out, StringRef fieldName,
338
338
const T &value, unsigned indentLevel,
339
- bool trailingComma);
339
+ bool trailingComma, bool nested = false );
340
340
341
341
// / Write a string value as JSON.
342
342
void writeJSONValue (llvm::raw_ostream &out, StringRef value,
@@ -442,11 +442,31 @@ void writeJSONValue(llvm::raw_ostream &out, const std::vector<T> &values,
442
442
template <typename T>
443
443
void writeJSONSingleField (llvm::raw_ostream &out, StringRef fieldName,
444
444
const T &value, unsigned indentLevel,
445
- bool trailingComma) {
445
+ bool trailingComma, bool nested ) {
446
446
out.indent (indentLevel * 2 );
447
447
writeJSONValue (out, fieldName, indentLevel);
448
448
out << " : " ;
449
- writeJSONValue (out, value, indentLevel);
449
+ auto updatedIndentLevel = indentLevel;
450
+
451
+ if (nested) {
452
+ // This is a hack to "fix" a format for a value that should be a nested
453
+ // set of strings. Currently only capturedPCMArgs (clang) is expected to
454
+ // in the nested format, which supposedly only contains one set of strings.
455
+ // Adjust the indentation to account for the nested brackets.
456
+ updatedIndentLevel += 1 ;
457
+ out << " [\n " ;
458
+ out.indent (updatedIndentLevel * 2 );
459
+ }
460
+
461
+ writeJSONValue (out, value, updatedIndentLevel);
462
+
463
+ if (nested) {
464
+ // If nested, add an extra closing brack with a correct indentation.
465
+ out << " \n " ;
466
+ out.indent (indentLevel * 2 );
467
+ out << " ]" ;
468
+ }
469
+
450
470
if (trailingComma)
451
471
out << " ," ;
452
472
out << " \n " ;
@@ -720,7 +740,7 @@ static void writeJSON(llvm::raw_ostream &out,
720
740
721
741
// Captured PCM arguments.
722
742
writeJSONSingleField (out, " capturedPCMArgs" , clangDeps->captured_pcm_args , 5 ,
723
- /* trailingComma=*/ false );
743
+ /* trailingComma=*/ false , /* nested= */ true );
724
744
}
725
745
726
746
out.indent (4 * 2 );
0 commit comments