diff options
Diffstat (limited to 'contrib/llvm-project/clang/utils/TableGen/ClangOptionDocEmitter.cpp')
-rw-r--r-- | contrib/llvm-project/clang/utils/TableGen/ClangOptionDocEmitter.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/contrib/llvm-project/clang/utils/TableGen/ClangOptionDocEmitter.cpp b/contrib/llvm-project/clang/utils/TableGen/ClangOptionDocEmitter.cpp index 6c24ad2bdcc5..75f5d057c33a 100644 --- a/contrib/llvm-project/clang/utils/TableGen/ClangOptionDocEmitter.cpp +++ b/contrib/llvm-project/clang/utils/TableGen/ClangOptionDocEmitter.cpp @@ -168,6 +168,29 @@ bool hasFlag(const Record *OptionOrGroup, StringRef OptionFlag) { return false; } +bool isIncluded(const Record *OptionOrGroup, const Record *DocInfo) { + assert(DocInfo->getValue("IncludedFlags") && "Missing includeFlags"); + for (StringRef Inclusion : DocInfo->getValueAsListOfStrings("IncludedFlags")) + if (hasFlag(OptionOrGroup, Inclusion)) + return true; + return false; +} + +bool isGroupIncluded(const DocumentedGroup &Group, const Record *DocInfo) { + if (isIncluded(Group.Group, DocInfo)) + return true; + for (auto &O : Group.Options) + if (isIncluded(O.Option, DocInfo)) + return true; + for (auto &G : Group.Groups) { + if (isIncluded(G.Group, DocInfo)) + return true; + if (isGroupIncluded(G, DocInfo)) + return true; + } + return false; +} + bool isExcluded(const Record *OptionOrGroup, const Record *DocInfo) { // FIXME: Provide a flag to specify the set of exclusions. for (StringRef Exclusion : DocInfo->getValueAsListOfStrings("ExcludedFlags")) @@ -304,6 +327,8 @@ void emitOption(const DocumentedOption &Option, const Record *DocInfo, raw_ostream &OS) { if (isExcluded(Option.Option, DocInfo)) return; + if (DocInfo->getValue("IncludedFlags") && !isIncluded(Option.Option, DocInfo)) + return; if (Option.Option->getValueAsDef("Kind")->getName() == "KIND_UNKNOWN" || Option.Option->getValueAsDef("Kind")->getName() == "KIND_INPUT") return; @@ -379,6 +404,9 @@ void emitGroup(int Depth, const DocumentedGroup &Group, const Record *DocInfo, if (isExcluded(Group.Group, DocInfo)) return; + if (DocInfo->getValue("IncludedFlags") && !isGroupIncluded(Group, DocInfo)) + return; + emitHeading(Depth, getRSTStringWithTextFallback(Group.Group, "DocName", "Name"), OS); |