DiegoAstiazaran updated this revision to Diff 206317.
DiegoAstiazaran edited the summary of this revision.
DiegoAstiazaran added a comment.
Herald added a subscriber: ormris.

Path name generation was moved to serialization phase as @juliehockett 
suggested.
Empty string declaration fixed.
Removed anonymous namespaces.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63663/new/

https://reviews.llvm.org/D63663

Files:
  clang-tools-extra/clang-doc/BitcodeReader.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.cpp
  clang-tools-extra/clang-doc/BitcodeWriter.h
  clang-tools-extra/clang-doc/Generators.cpp
  clang-tools-extra/clang-doc/Generators.h
  clang-tools-extra/clang-doc/HTMLGenerator.cpp
  clang-tools-extra/clang-doc/MDGenerator.cpp
  clang-tools-extra/clang-doc/Mapper.cpp
  clang-tools-extra/clang-doc/Representation.cpp
  clang-tools-extra/clang-doc/Representation.h
  clang-tools-extra/clang-doc/Serialize.cpp
  clang-tools-extra/clang-doc/Serialize.h
  clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
  clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
  clang-tools-extra/unittests/clang-doc/SerializeTest.cpp

Index: clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
===================================================================
--- clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
+++ clang-tools-extra/unittests/clang-doc/SerializeTest.cpp
@@ -37,7 +37,7 @@
 
   bool VisitNamespaceDecl(const NamespaceDecl *D) {
     auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
-                                 /*File=*/"test.cpp", Public);
+                                 /*File=*/"test.cpp", Public, "");
     if (I)
       EmittedInfos.emplace_back(std::move(I));
     return true;
@@ -48,7 +48,7 @@
     if (dyn_cast<CXXMethodDecl>(D))
       return true;
     auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
-                                 /*File=*/"test.cpp", Public);
+                                 /*File=*/"test.cpp", Public, "");
     if (I)
       EmittedInfos.emplace_back(std::move(I));
     return true;
@@ -56,7 +56,7 @@
 
   bool VisitCXXMethodDecl(const CXXMethodDecl *D) {
     auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
-                                 /*File=*/"test.cpp", Public);
+                                 /*File=*/"test.cpp", Public, "");
     if (I)
       EmittedInfos.emplace_back(std::move(I));
     return true;
@@ -64,7 +64,7 @@
 
   bool VisitRecordDecl(const RecordDecl *D) {
     auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
-                                 /*File=*/"test.cpp", Public);
+                                 /*File=*/"test.cpp", Public, "");
     if (I)
       EmittedInfos.emplace_back(std::move(I));
     return true;
@@ -72,7 +72,7 @@
 
   bool VisitEnumDecl(const EnumDecl *D) {
     auto I = serialize::emitInfo(D, getComment(D), /*Line=*/0,
-                                 /*File=*/"test.cpp", Public);
+                                 /*File=*/"test.cpp", Public, "");
     if (I)
       EmittedInfos.emplace_back(std::move(I));
     return true;
@@ -142,7 +142,8 @@
   E() {}
 protected:
   void ProtectedMethod();
-};)raw", 3, /*Public=*/false, Infos);
+};)raw",
+                       3, /*Public=*/false, Infos);
 
   RecordInfo *E = InfoAsRecord(Infos[0].get());
   RecordInfo ExpectedE(EmptySID, "E");
Index: clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
===================================================================
--- clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
+++ clang-tools-extra/unittests/clang-doc/HTMLGeneratorTest.cpp
@@ -72,7 +72,8 @@
 
   I.Members.emplace_back("int", "X", AccessSpecifier::AS_private);
   I.TagType = TagTypeKind::TTK_Class;
-  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record);
+  I.Parents.emplace_back(EmptySID, "F", InfoType::IT_record,
+                         llvm::SmallString<128>("/path/to"));
   I.VirtualParents.emplace_back(EmptySID, "G", InfoType::IT_record);
 
   I.ChildRecords.emplace_back(EmptySID, "ChildStruct", InfoType::IT_record);
@@ -89,7 +90,7 @@
   assert(!Err);
   std::string Expected = R"raw(<h1>class r</h1>
 <p><em>Defined at line 10 of test.cpp</em></p>
-<p>Inherits from F, G</p>
+<p>Inherits from <a href="/path/to/F.html">F</a>, G</p>
 <br>
 <h2>Members</h2>
 <p>private int X</p>
Index: clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
===================================================================
--- clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -110,30 +110,8 @@
   return false;
 }
 
-// A function to extract the appropriate path name for a given info's
-// documentation. The path returned is a composite of the parent namespaces as
-// directories plus the decl name as the filename.
-//
-// Example: Given the below, the <ext> path for class C will be <
-// root>/A/B/C.<ext>
-//
-// namespace A {
-// namesapce B {
-//
-// class C {};
-//
-// }
-// }
 llvm::Expected<llvm::SmallString<128>>
-getInfoOutputFile(StringRef Root,
-                  llvm::SmallVectorImpl<doc::Reference> &Namespaces,
-                  StringRef Name, StringRef Ext) {
-  std::error_code OK;
-  llvm::SmallString<128> Path;
-  llvm::sys::path::native(Root, Path);
-  for (auto R = Namespaces.rbegin(), E = Namespaces.rend(); R != E; ++R)
-    llvm::sys::path::append(Path, R->Name);
-
+getInfoOutputFile(llvm::SmallString<128> Path, StringRef Name, StringRef Ext) {
   if (CreateDirectory(Path))
     return llvm::make_error<llvm::StringError>("Unable to create directory.\n",
                                                llvm::inconvertibleErrorCode());
@@ -200,7 +178,7 @@
   // Mapping phase
   llvm::outs() << "Mapping decls...\n";
   clang::doc::ClangDocContext CDCtx = {Exec->get()->getExecutionContext(),
-                                       PublicOnly};
+                                       PublicOnly, OutDirectory};
   auto Err =
       Exec->get()->execute(doc::newMapperActionFactory(CDCtx), ArgAdjuster);
   if (Err) {
@@ -227,11 +205,10 @@
 
     doc::Info *I = Reduced.get().get();
 
-    auto InfoPath =
-        getInfoOutputFile(OutDirectory, I->Namespace, I->Name, "." + Format);
+    auto InfoPath = getInfoOutputFile(I->Path, I->Name, "." + Format);
     if (!InfoPath) {
       llvm::errs() << toString(InfoPath.takeError()) << "\n";
-      continue;
+      return 1;
     }
     std::error_code FileErr;
     llvm::raw_fd_ostream InfoOS(InfoPath.get(), FileErr, llvm::sys::fs::F_None);
Index: clang-tools-extra/clang-doc/Serialize.h
===================================================================
--- clang-tools-extra/clang-doc/Serialize.h
+++ clang-tools-extra/clang-doc/Serialize.h
@@ -28,15 +28,20 @@
 namespace serialize {
 
 std::unique_ptr<Info> emitInfo(const NamespaceDecl *D, const FullComment *FC,
-                               int LineNumber, StringRef File, bool PublicOnly);
+                               int LineNumber, StringRef File, bool PublicOnly,
+                               const std::string &OutDirectory);
 std::unique_ptr<Info> emitInfo(const RecordDecl *D, const FullComment *FC,
-                               int LineNumber, StringRef File, bool PublicOnly);
+                               int LineNumber, StringRef File, bool PublicOnly,
+                               const std::string &OutDirectory);
 std::unique_ptr<Info> emitInfo(const EnumDecl *D, const FullComment *FC,
-                               int LineNumber, StringRef File, bool PublicOnly);
+                               int LineNumber, StringRef File, bool PublicOnly,
+                               const std::string &OutDirectory);
 std::unique_ptr<Info> emitInfo(const FunctionDecl *D, const FullComment *FC,
-                               int LineNumber, StringRef File, bool PublicOnly);
+                               int LineNumber, StringRef File, bool PublicOnly,
+                               const std::string &OutDirectory);
 std::unique_ptr<Info> emitInfo(const CXXMethodDecl *D, const FullComment *FC,
-                               int LineNumber, StringRef File, bool PublicOnly);
+                               int LineNumber, StringRef File, bool PublicOnly,
+                               const std::string &OutDirectory);
 
 // Function to hash a given USR value for storage.
 // As USRs (Unified Symbol Resolution) could be large, especially for functions
Index: clang-tools-extra/clang-doc/Serialize.cpp
===================================================================
--- clang-tools-extra/clang-doc/Serialize.cpp
+++ clang-tools-extra/clang-doc/Serialize.cpp
@@ -24,6 +24,30 @@
   return llvm::SHA1::hash(arrayRefFromStringRef(USR));
 }
 
+// A function to extract the appropriate directory name for a given info's
+// documentation. The path returned is a composite of the parent namespaces
+//
+// Example: Given the below, the <ext> path for class C will be <
+// root>/A/B/C
+//
+// namespace A {
+// namesapce B {
+//
+// class C {};
+//
+// }
+// }
+llvm::SmallString<128>
+getInfoOutputFile(StringRef Root,
+                  const llvm::SmallVectorImpl<doc::Reference> &Namespaces) {
+  std::error_code OK;
+  llvm::SmallString<128> Path;
+  llvm::sys::path::native(Root, Path);
+  for (auto R = Namespaces.rbegin(), E = Namespaces.rend(); R != E; ++R)
+    llvm::sys::path::append(Path, R->Name);
+  return Path;
+}
+
 class ClangDocCommentVisitor
     : public ConstCommentVisitor<ClangDocCommentVisitor> {
 public:
@@ -242,28 +266,6 @@
   }
 }
 
-static void parseBases(RecordInfo &I, const CXXRecordDecl *D) {
-  // Don't parse bases if this isn't a definition.
-  if (!D->isThisDeclarationADefinition())
-    return;
-  for (const CXXBaseSpecifier &B : D->bases()) {
-    if (B.isVirtual())
-      continue;
-    if (const auto *P = getDeclForType(B.getType()))
-      I.Parents.emplace_back(getUSRForDecl(P), P->getNameAsString(),
-                             InfoType::IT_record);
-    else
-      I.Parents.emplace_back(B.getType().getAsString());
-  }
-  for (const CXXBaseSpecifier &B : D->vbases()) {
-    if (const auto *P = getDeclForType(B.getType()))
-      I.VirtualParents.emplace_back(getUSRForDecl(P), P->getNameAsString(),
-                                    InfoType::IT_record);
-    else
-      I.VirtualParents.emplace_back(B.getType().getAsString());
-  }
-}
-
 template <typename T>
 static void
 populateParentNamespaces(llvm::SmallVector<Reference, 4> &Namespaces,
@@ -285,6 +287,32 @@
   }
 }
 
+static void parseBases(RecordInfo &I, const CXXRecordDecl *D,
+                       const std::string &OutDirectory) {
+  // Don't parse bases if this isn't a definition.
+  if (!D->isThisDeclarationADefinition())
+    return;
+  for (const CXXBaseSpecifier &B : D->bases()) {
+    if (B.isVirtual())
+      continue;
+    if (const auto *P = getDeclForType(B.getType())) {
+      llvm::SmallVector<Reference, 4> ParentNamespaces;
+      populateParentNamespaces(ParentNamespaces, P);
+      auto InfoDirectory = getInfoOutputFile(OutDirectory, ParentNamespaces);
+      I.Parents.emplace_back(getUSRForDecl(P), P->getNameAsString(),
+                             InfoType::IT_record, InfoDirectory);
+    } else
+      I.Parents.emplace_back(B.getType().getAsString());
+  }
+  for (const CXXBaseSpecifier &B : D->vbases()) {
+    if (const auto *P = getDeclForType(B.getType()))
+      I.VirtualParents.emplace_back(getUSRForDecl(P), P->getNameAsString(),
+                                    InfoType::IT_record);
+    else
+      I.VirtualParents.emplace_back(B.getType().getAsString());
+  }
+}
+
 template <typename T>
 static void populateInfo(Info &I, const T *D, const FullComment *C) {
   I.USR = getUSRForDecl(D);
@@ -325,18 +353,21 @@
 
 std::unique_ptr<Info> emitInfo(const NamespaceDecl *D, const FullComment *FC,
                                int LineNumber, llvm::StringRef File,
-                               bool PublicOnly) {
+                               bool PublicOnly,
+                               const std::string &OutDirectory) {
   if (PublicOnly && ((D->isAnonymousNamespace()) ||
                      !isPublic(D->getAccess(), D->getLinkageInternal())))
     return nullptr;
   auto I = llvm::make_unique<NamespaceInfo>();
   populateInfo(*I, D, FC);
+  I->Path = getInfoOutputFile(OutDirectory, I->Namespace);
   return std::unique_ptr<Info>{std::move(I)};
 }
 
 std::unique_ptr<Info> emitInfo(const RecordDecl *D, const FullComment *FC,
                                int LineNumber, llvm::StringRef File,
-                               bool PublicOnly) {
+                               bool PublicOnly,
+                               const std::string &OutDirectory) {
   if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
     return nullptr;
   auto I = llvm::make_unique<RecordInfo>();
@@ -344,13 +375,15 @@
   I->TagType = D->getTagKind();
   parseFields(*I, D, PublicOnly);
   if (const auto *C = dyn_cast<CXXRecordDecl>(D))
-    parseBases(*I, C);
+    parseBases(*I, C, OutDirectory);
+  I->Path = getInfoOutputFile(OutDirectory, I->Namespace);
   return std::unique_ptr<Info>{std::move(I)};
 }
 
 std::unique_ptr<Info> emitInfo(const FunctionDecl *D, const FullComment *FC,
                                int LineNumber, llvm::StringRef File,
-                               bool PublicOnly) {
+                               bool PublicOnly,
+                               const std::string &OutDirectory) {
   if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
     return nullptr;
   FunctionInfo Func;
@@ -364,12 +397,14 @@
   else
     I->USR = SymbolID();
   I->ChildFunctions.emplace_back(std::move(Func));
+  I->Path = getInfoOutputFile(OutDirectory, I->Namespace);
   return std::unique_ptr<Info>{std::move(I)};
 }
 
 std::unique_ptr<Info> emitInfo(const CXXMethodDecl *D, const FullComment *FC,
                                int LineNumber, llvm::StringRef File,
-                               bool PublicOnly) {
+                               bool PublicOnly,
+                               const std::string &OutDirectory) {
   if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
     return nullptr;
   FunctionInfo Func;
@@ -385,12 +420,14 @@
   auto I = llvm::make_unique<RecordInfo>();
   I->USR = ParentUSR;
   I->ChildFunctions.emplace_back(std::move(Func));
+  I->Path = getInfoOutputFile(OutDirectory, I->Namespace);
   return std::unique_ptr<Info>{std::move(I)};
 }
 
 std::unique_ptr<Info> emitInfo(const EnumDecl *D, const FullComment *FC,
                                int LineNumber, llvm::StringRef File,
-                               bool PublicOnly) {
+                               bool PublicOnly,
+                               const std::string &OutDirectory) {
   if (PublicOnly && !isPublic(D->getAccess(), D->getLinkageInternal()))
     return nullptr;
   EnumInfo Enum;
@@ -422,6 +459,7 @@
   auto I = llvm::make_unique<NamespaceInfo>();
   I->USR = SymbolID();
   I->ChildEnums.emplace_back(std::move(Enum));
+  I->Path = getInfoOutputFile(OutDirectory, I->Namespace);
   return std::unique_ptr<Info>{std::move(I)};
 }
 
Index: clang-tools-extra/clang-doc/Representation.h
===================================================================
--- clang-tools-extra/clang-doc/Representation.h
+++ clang-tools-extra/clang-doc/Representation.h
@@ -76,6 +76,11 @@
   Reference(llvm::StringRef Name) : Name(Name) {}
   Reference(SymbolID USR, StringRef Name, InfoType IT)
       : USR(USR), Name(Name), RefType(IT) {}
+  Reference(SymbolID USR, StringRef Name, InfoType IT,
+            llvm::SmallString<128> Path)
+      : USR(USR), Name(Name), RefType(IT), Path(Path) {}
+  Reference(SymbolID USR, StringRef Name, InfoType IT, std::string Path)
+      : USR(USR), Name(Name), RefType(IT), Path(Path) {}
 
   bool operator==(const Reference &Other) const {
     return std::tie(USR, Name, RefType) ==
@@ -87,6 +92,8 @@
   InfoType RefType = InfoType::IT_default; // Indicates the type of this
                                            // Reference (namespace, record,
                                            // function, enum, default).
+  llvm::SmallString<128> Path; // Path of directory where the clang-doc
+                               // generated file will be saved
 };
 
 // A base struct for TypeInfos
@@ -171,6 +178,8 @@
   llvm::SmallVector<Reference, 4>
       Namespace; // List of parent namespaces for this decl.
   std::vector<CommentInfo> Description; // Comment description of this decl.
+  llvm::SmallString<128> Path;          // Path of directory where the clang-doc
+                                        // generated file will be saved
 
   void mergeBase(Info &&I);
   bool mergeable(const Info &Other);
@@ -282,6 +291,7 @@
 struct ClangDocContext {
   tooling::ExecutionContext *ECtx;
   bool PublicOnly;
+  std::string OutDirectory;
 };
 
 } // namespace doc
Index: clang-tools-extra/clang-doc/Representation.cpp
===================================================================
--- clang-tools-extra/clang-doc/Representation.cpp
+++ clang-tools-extra/clang-doc/Representation.cpp
@@ -117,6 +117,8 @@
     USR = Other.USR;
   if (Name == "")
     Name = Other.Name;
+  if (Path == "")
+    Path = Other.Path;
   if (Namespace.empty())
     Namespace = std::move(Other.Namespace);
   // Unconditionally extend the description, since each decl may have a comment.
Index: clang-tools-extra/clang-doc/Mapper.cpp
===================================================================
--- clang-tools-extra/clang-doc/Mapper.cpp
+++ clang-tools-extra/clang-doc/Mapper.cpp
@@ -39,13 +39,13 @@
 
   auto I = serialize::emitInfo(
       D, getComment(D, D->getASTContext()), getLine(D, D->getASTContext()),
-      getFile(D, D->getASTContext()), CDCtx.PublicOnly);
+      getFile(D, D->getASTContext()), CDCtx.PublicOnly, CDCtx.OutDirectory);
 
   // A null in place of I indicates that the serializer is skipping this decl
   // for some reason (e.g. we're only reporting public decls).
   if (I)
     CDCtx.ECtx->reportResult(llvm::toHex(llvm::toStringRef(I->USR)),
-                       serialize::serialize(I));
+                             serialize::serialize(I));
   return true;
 }
 
Index: clang-tools-extra/clang-doc/MDGenerator.cpp
===================================================================
--- clang-tools-extra/clang-doc/MDGenerator.cpp
+++ clang-tools-extra/clang-doc/MDGenerator.cpp
@@ -18,7 +18,7 @@
 namespace clang {
 namespace doc {
 
-namespace {
+namespace md_generator {
 
 // Markdown generation
 
@@ -30,6 +30,19 @@
   return "[" + Text.str() + "](" + Link.str() + ")";
 }
 
+std::string genReferenceList(const llvm::SmallVectorImpl<Reference> &Refs) {
+  std::string Buffer;
+  llvm::raw_string_ostream Stream(Buffer);
+  bool First = true;
+  for (const auto &R : Refs) {
+    if (!First)
+      Stream << ", ";
+    Stream << R.Name;
+    First = false;
+  }
+  return Stream.str();
+}
+
 void writeLine(const Twine &Text, raw_ostream &OS) { OS << Text << "\n\n"; }
 
 void writeNewLine(raw_ostream &OS) { OS << "\n\n"; }
@@ -92,7 +105,9 @@
   }
 }
 
-} // namespace
+} // namespace md_generator
+
+using namespace md_generator;
 
 void genMarkdown(const EnumInfo &I, llvm::raw_ostream &OS) {
   if (I.Scoped)
Index: clang-tools-extra/clang-doc/HTMLGenerator.cpp
===================================================================
--- clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -18,7 +18,7 @@
 namespace clang {
 namespace doc {
 
-namespace {
+namespace html_generator {
 
 // HTML generation
 
@@ -26,10 +26,44 @@
   return "<" + Tag.str() + ">" + Text.str() + "</" + Tag.str() + ">";
 }
 
+std::string genTag(const Twine &Text, const Twine &Tag,
+                   const llvm::StringMap<std::string> &Options) {
+  std::string OptionsText;
+  for (auto &Option : Options) {
+    OptionsText = OptionsText + " " + Option.getKey().str() + "=\"" +
+                  Option.getValue() + "\"";
+  }
+  return "<" + Tag.str() + OptionsText + ">" + Text.str() + "</" + Tag.str() +
+         ">";
+}
+
 std::string genItalic(const Twine &Text) { return genTag(Text, "em"); }
 
 std::string genEmphasis(const Twine &Text) { return genTag(Text, "strong"); }
 
+std::string genLink(const Twine &Text, const Twine &Link) {
+  llvm::StringMap<std::string> Options;
+  Options.try_emplace("href", Link.str());
+  return genTag(Text.str(), "a", Options);
+}
+
+std::string genReferenceList(const llvm::SmallVectorImpl<Reference> &Refs) {
+  std::string Buffer;
+  llvm::raw_string_ostream Stream(Buffer);
+  bool First = true;
+  for (const auto &R : Refs) {
+    if (!First)
+      Stream << ", ";
+    if (!R.Path.empty()) {
+      Stream << genLink(R.Name, R.Path + "/" + R.Name + ".html");
+    } else {
+      Stream << R.Name;
+    }
+    First = false;
+  }
+  return Stream.str();
+}
+
 void writeLine(const Twine &Text, raw_ostream &OS) {
   OS << genTag(Text, "p") << "\n";
 }
@@ -94,7 +128,9 @@
   }
 }
 
-} // namespace
+} // namespace html_generator
+
+using namespace html_generator;
 
 void genHTML(const EnumInfo &I, llvm::raw_ostream &OS) {
   if (I.Scoped)
Index: clang-tools-extra/clang-doc/Generators.h
===================================================================
--- clang-tools-extra/clang-doc/Generators.h
+++ clang-tools-extra/clang-doc/Generators.h
@@ -38,8 +38,6 @@
 
 std::string getTagType(TagTypeKind AS);
 
-std::string genReferenceList(const llvm::SmallVectorImpl<Reference> &Refs);
-
 } // namespace doc
 } // namespace clang
 
Index: clang-tools-extra/clang-doc/Generators.cpp
===================================================================
--- clang-tools-extra/clang-doc/Generators.cpp
+++ clang-tools-extra/clang-doc/Generators.cpp
@@ -57,19 +57,6 @@
   llvm_unreachable("Unknown TagTypeKind");
 }
 
-std::string genReferenceList(const llvm::SmallVectorImpl<Reference> &Refs) {
-  std::string Buffer;
-  llvm::raw_string_ostream Stream(Buffer);
-  bool First = true;
-  for (const auto &R : Refs) {
-    if (!First)
-      Stream << ", ";
-    Stream << R.Name;
-    First = false;
-  }
-  return Stream.str();
-}
-
 // This anchor is used to force the linker to link in the generated object file
 // and thus register the generators.
 extern volatile int YAMLGeneratorAnchorSource;
Index: clang-tools-extra/clang-doc/BitcodeWriter.h
===================================================================
--- clang-tools-extra/clang-doc/BitcodeWriter.h
+++ clang-tools-extra/clang-doc/BitcodeWriter.h
@@ -91,6 +91,7 @@
   MEMBER_TYPE_ACCESS,
   NAMESPACE_USR,
   NAMESPACE_NAME,
+  NAMESPACE_PATH,
   ENUM_USR,
   ENUM_NAME,
   ENUM_DEFLOCATION,
@@ -99,12 +100,14 @@
   ENUM_SCOPED,
   RECORD_USR,
   RECORD_NAME,
+  RECORD_PATH,
   RECORD_DEFLOCATION,
   RECORD_LOCATION,
   RECORD_TAG_TYPE,
   REFERENCE_USR,
   REFERENCE_NAME,
   REFERENCE_TYPE,
+  REFERENCE_PATH,
   REFERENCE_FIELD,
   RI_LAST,
   RI_FIRST = VERSION
Index: clang-tools-extra/clang-doc/BitcodeWriter.cpp
===================================================================
--- clang-tools-extra/clang-doc/BitcodeWriter.cpp
+++ clang-tools-extra/clang-doc/BitcodeWriter.cpp
@@ -148,6 +148,7 @@
           {MEMBER_TYPE_ACCESS, {"Access", &IntAbbrev}},
           {NAMESPACE_USR, {"USR", &SymbolIDAbbrev}},
           {NAMESPACE_NAME, {"Name", &StringAbbrev}},
+          {NAMESPACE_PATH, {"Path", &StringAbbrev}},
           {ENUM_USR, {"USR", &SymbolIDAbbrev}},
           {ENUM_NAME, {"Name", &StringAbbrev}},
           {ENUM_DEFLOCATION, {"DefLocation", &LocationAbbrev}},
@@ -156,6 +157,7 @@
           {ENUM_SCOPED, {"Scoped", &BoolAbbrev}},
           {RECORD_USR, {"USR", &SymbolIDAbbrev}},
           {RECORD_NAME, {"Name", &StringAbbrev}},
+          {RECORD_PATH, {"Path", &StringAbbrev}},
           {RECORD_DEFLOCATION, {"DefLocation", &LocationAbbrev}},
           {RECORD_LOCATION, {"Location", &LocationAbbrev}},
           {RECORD_TAG_TYPE, {"TagType", &IntAbbrev}},
@@ -168,6 +170,7 @@
           {REFERENCE_USR, {"USR", &SymbolIDAbbrev}},
           {REFERENCE_NAME, {"Name", &StringAbbrev}},
           {REFERENCE_TYPE, {"RefType", &IntAbbrev}},
+          {REFERENCE_PATH, {"Path", &StringAbbrev}},
           {REFERENCE_FIELD, {"Field", &IntAbbrev}}};
       assert(Inits.size() == RecordIdCount);
       for (const auto &Init : Inits) {
@@ -198,18 +201,20 @@
          {ENUM_USR, ENUM_NAME, ENUM_DEFLOCATION, ENUM_LOCATION, ENUM_MEMBER,
           ENUM_SCOPED}},
         // Namespace Block
-        {BI_NAMESPACE_BLOCK_ID, {NAMESPACE_USR, NAMESPACE_NAME}},
+        {BI_NAMESPACE_BLOCK_ID,
+         {NAMESPACE_USR, NAMESPACE_NAME, NAMESPACE_PATH}},
         // Record Block
         {BI_RECORD_BLOCK_ID,
-         {RECORD_USR, RECORD_NAME, RECORD_DEFLOCATION, RECORD_LOCATION,
-          RECORD_TAG_TYPE}},
+         {RECORD_USR, RECORD_NAME, RECORD_PATH, RECORD_DEFLOCATION,
+          RECORD_LOCATION, RECORD_TAG_TYPE}},
         // Function Block
         {BI_FUNCTION_BLOCK_ID,
          {FUNCTION_USR, FUNCTION_NAME, FUNCTION_DEFLOCATION, FUNCTION_LOCATION,
           FUNCTION_ACCESS, FUNCTION_IS_METHOD}},
         // Reference Block
         {BI_REFERENCE_BLOCK_ID,
-         {REFERENCE_USR, REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_FIELD}}};
+         {REFERENCE_USR, REFERENCE_NAME, REFERENCE_TYPE, REFERENCE_PATH,
+          REFERENCE_FIELD}}};
 
 // AbbreviationMap
 
@@ -380,6 +385,7 @@
   emitRecord(R.USR, REFERENCE_USR);
   emitRecord(R.Name, REFERENCE_NAME);
   emitRecord((unsigned)R.RefType, REFERENCE_TYPE);
+  emitRecord(R.Path, REFERENCE_PATH);
   emitRecord((unsigned)Field, REFERENCE_FIELD);
 }
 
@@ -427,6 +433,7 @@
   StreamSubBlockGuard Block(Stream, BI_NAMESPACE_BLOCK_ID);
   emitRecord(I.USR, NAMESPACE_USR);
   emitRecord(I.Name, NAMESPACE_NAME);
+  emitRecord(I.Path, NAMESPACE_PATH);
   for (const auto &N : I.Namespace)
     emitBlock(N, FieldId::F_namespace);
   for (const auto &CI : I.Description)
@@ -462,6 +469,7 @@
   StreamSubBlockGuard Block(Stream, BI_RECORD_BLOCK_ID);
   emitRecord(I.USR, RECORD_USR);
   emitRecord(I.Name, RECORD_NAME);
+  emitRecord(I.Path, RECORD_PATH);
   for (const auto &N : I.Namespace)
     emitBlock(N, FieldId::F_namespace);
   for (const auto &CI : I.Description)
Index: clang-tools-extra/clang-doc/BitcodeReader.cpp
===================================================================
--- clang-tools-extra/clang-doc/BitcodeReader.cpp
+++ clang-tools-extra/clang-doc/BitcodeReader.cpp
@@ -148,6 +148,8 @@
     return decodeRecord(R, I->USR, Blob);
   case NAMESPACE_NAME:
     return decodeRecord(R, I->Name, Blob);
+  case NAMESPACE_PATH:
+    return decodeRecord(R, I->Path, Blob);
   default:
     return llvm::make_error<llvm::StringError>(
         "Invalid field for NamespaceInfo.\n", llvm::inconvertibleErrorCode());
@@ -161,6 +163,8 @@
     return decodeRecord(R, I->USR, Blob);
   case RECORD_NAME:
     return decodeRecord(R, I->Name, Blob);
+  case RECORD_PATH:
+    return decodeRecord(R, I->Path, Blob);
   case RECORD_DEFLOCATION:
     return decodeRecord(R, I->DefLoc, Blob);
   case RECORD_LOCATION:
@@ -284,6 +288,8 @@
     return decodeRecord(R, I->Name, Blob);
   case REFERENCE_TYPE:
     return decodeRecord(R, I->RefType, Blob);
+  case REFERENCE_PATH:
+    return decodeRecord(R, I->Path, Blob);
   case REFERENCE_FIELD:
     return decodeRecord(R, F, Blob);
   default:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to