@@ -386,6 +386,7 @@ static void serializeInfo(const RecordInfo &I, json::Object &Obj,
386386  Obj[" FullName"  ] = I.FullName ;
387387  Obj[" TagType"  ] = getTagType (I.TagType );
388388  Obj[" IsTypedef"  ] = I.IsTypeDef ;
389+   Obj[" MangledName"  ] = I.MangledName ;
389390
390391  if  (!I.Children .Functions .empty ()) {
391392    json::Value PubFunctionsArray = Array ();
@@ -491,6 +492,23 @@ static void serializeInfo(const NamespaceInfo &I, json::Object &Obj,
491492  serializeCommonChildren (I.Children , Obj, RepositoryUrl);
492493}
493494
495+ static  SmallString<16 > determineFileName (Info *I, SmallString<128 > &Path) {
496+   SmallString<16 > FileName;
497+   if  (I->IT  == InfoType::IT_record) {
498+     auto  *RecordSymbolInfo = static_cast <SymbolInfo *>(I);
499+     if  (RecordSymbolInfo->MangledName .size () < 255 )
500+       FileName = RecordSymbolInfo->MangledName ;
501+     else 
502+       FileName = toStringRef (toHex (RecordSymbolInfo->USR ));
503+   } else  if  (I->IT  == InfoType::IT_namespace && I->Name  != " "  )
504+     //  Serialize the global namespace as index.json
505+     FileName = I->Name ;
506+   else 
507+     FileName = I->getFileBaseName ();
508+   sys::path::append (Path, FileName + " .json"  );
509+   return  FileName;
510+ }
511+ 
494512Error JSONGenerator::generateDocs (
495513    StringRef RootDir, llvm::StringMap<std::unique_ptr<doc::Info>> Infos,
496514    const  ClangDocContext &CDCtx) {
@@ -501,15 +519,14 @@ Error JSONGenerator::generateDocs(
501519
502520    SmallString<128 > Path;
503521    sys::path::native (RootDir, Path);
504-     sys::path::append (Path, Info->getRelativeFilePath (" "  ));
505522    if  (!CreatedDirs.contains (Path)) {
506523      if  (std::error_code Err = sys::fs::create_directories (Path);
507524          Err != std::error_code ())
508525        return  createFileError (Twine (Path), Err);
509526      CreatedDirs.insert (Path);
510527    }
511528
512-     sys::path::append (Path, Info-> getFileBaseName () +  " .json "  );
529+     SmallString< 16 > FileName =  determineFileName (Info, Path );
513530    FileToInfos[Path].push_back (Info);
514531  }
515532
0 commit comments