[clang-tools-extra] [clang-doc][fix] crashes when generating HTML without `--repository` (PR #131698)

Paul Kirth via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 19 10:29:39 PDT 2025


================
@@ -494,7 +494,7 @@ genReferencesBlock(const std::vector<Reference> &References,
 static std::unique_ptr<TagNode>
 writeFileDefinition(const Location &L,
                     std::optional<StringRef> RepositoryUrl = std::nullopt) {
-  if (!L.IsFileInRootDir && !RepositoryUrl)
+  if (!L.IsFileInRootDir || !RepositoryUrl)
----------------
ilovepi wrote:

> The whole next logic depends on `RepositoryUrl`. how can we continue using it if it's not passed?

What I mean is that often `!L.IsFileInRootDir || !RepositoryUrl` is true when we want to use the `--repository` flag, meaning we never use the URL in situations where we should.

>If RepositoryUrl is not passed, shouldn't we use file:// protocol as I think? In this case, the FileUrl should be something like file:///path/to/file, not just an empty string

Maybe. I think we're still generating a valid path in the HTML, but different generation methods are welcome. Some of this may be obsoleted after @PeterChou1 finishes landing https://github.com/llvm/llvm-project/pull/108653 and the prerequisite Mustache support in LLVM support.


https://github.com/llvm/llvm-project/pull/131698


More information about the cfe-commits mailing list