diff --git a/clang-tools-extra/clang-doc/HTMLGenerator.cpp b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
index 18a0de826630c..37d94ace17477 100644
--- a/clang-tools-extra/clang-doc/HTMLGenerator.cpp
+++ b/clang-tools-extra/clang-doc/HTMLGenerator.cpp
@@ -494,7 +494,7 @@ genReferencesBlock(const std::vector &References,
static std::unique_ptr
writeFileDefinition(const Location &L,
std::optional RepositoryUrl = std::nullopt) {
- if (!L.IsFileInRootDir && !RepositoryUrl)
+ if (!L.IsFileInRootDir || !RepositoryUrl)
return std::make_unique(
HTMLTag::TAG_P, "Defined at line " + std::to_string(L.LineNumber) +
" of file " + L.Filename);