[clang-tools-extra] [clang-doc] [feat] add --repository-line-prefix argument (PR #131280)
Mohamed Emad via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 20 10:37:36 PDT 2025
================
@@ -750,11 +754,15 @@ genHTML(const EnumInfo &I, const ClangDocContext &CDCtx) {
Out.emplace_back(std::move(Table));
if (I.DefLoc) {
- if (!CDCtx.RepositoryUrl)
- Out.emplace_back(writeFileDefinition(*I.DefLoc));
- else
- Out.emplace_back(
- writeFileDefinition(*I.DefLoc, StringRef{*CDCtx.RepositoryUrl}));
+ std::optional<StringRef> RepoUrl;
+ std::optional<StringRef> RepoLinePrefix;
+
+ if (CDCtx.RepositoryUrl)
+ RepoUrl = StringRef{*CDCtx.RepositoryUrl};
+ if (CDCtx.RepositoryLinePrefix)
+ RepoLinePrefix = StringRef{*CDCtx.RepositoryLinePrefix};
+
+ Out.emplace_back(writeFileDefinition(*I.DefLoc, RepoUrl, RepoLinePrefix));
----------------
hulxv wrote:
> Perhaps its better if WriteFileDefinition just takes StringRef arguments instead of optional<StringRef>? Then instead of checking the optional, you can either just use the StringRef as is or at worst check for empty(). Do you think that would allow us to simplify this code?
Yup, I think that. it will be better
https://github.com/llvm/llvm-project/pull/131280
More information about the cfe-commits
mailing list