================
@@ -419,12 +421,25 @@ static void serializeReference(const Reference &Ref, 
Object &ReferenceObj) {
   }
 }
 
+static void serializeMDReference(const Reference &Ref, Object &ReferenceObj,
+                                 StringRef BasePath) {
+  serializeReference(Ref, ReferenceObj);
+  SmallString<64> Path = Ref.getRelativeFilePath(BasePath);
+  sys::path::native(Path, sys::path::Style::posix);
+  sys::path::append(Path, sys::path::Style::posix,
+                    Ref.getFileBaseName() + ".md");
+  ReferenceObj["BasePath"] = Path;
+}
+
+typedef std::function<void(const Reference &, Object &)> ReferenceFunc;
+
 // Although namespaces and records both have ScopeChildren, they serialize them
 // differently. Only enums, records, and typedefs are handled here.
-static void
-serializeCommonChildren(const ScopeChildren &Children, json::Object &Obj,
-                        const std::optional<StringRef> RepositoryUrl,
-                        const std::optional<StringRef> RepositoryLinePrefix) {
+static void serializeCommonChildren(
+    const ScopeChildren &Children, json::Object &Obj,
+    const std::optional<StringRef> RepositoryUrl,
+    const std::optional<StringRef> RepositoryLinePrefix,
+    std::optional<ReferenceFunc> MDReferenceLambda = std::nullopt) {
----------------
ilovepi wrote:

So this replaces SerializeReferenceLambda? Maybe just set a local reference to 
the one you want to use, and avoid all the branches?

https://github.com/llvm/llvm-project/pull/177221
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to