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

Mohamed Emad via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 18 22:46:20 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)
----------------
hulxv wrote:

> This logic isn't correct, and happens to prevent us from effectively using the --repository= string anywhere, as evidenced by our tests.

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

> An alternative would be to change the deref of the option to use .value_or("") instead.

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

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


More information about the cfe-commits mailing list