/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- ClangCommentHTMLTagsEmitter.cpp - Generate HTML tag list for Clang -=// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | // This tablegen backend emits efficient matchers for HTML tags that are used |
10 | | // in documentation comments. |
11 | | // |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #include "TableGenBackends.h" |
15 | | #include "llvm/TableGen/Record.h" |
16 | | #include "llvm/TableGen/StringMatcher.h" |
17 | | #include "llvm/TableGen/TableGenBackend.h" |
18 | | #include <vector> |
19 | | |
20 | | using namespace llvm; |
21 | | |
22 | 0 | void clang::EmitClangCommentHTMLTags(RecordKeeper &Records, raw_ostream &OS) { |
23 | 0 | std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Tag"); |
24 | 0 | std::vector<StringMatcher::StringPair> Matches; |
25 | 0 | for (Record *Tag : Tags) { |
26 | 0 | Matches.emplace_back(std::string(Tag->getValueAsString("Spelling")), |
27 | 0 | "return true;"); |
28 | 0 | } |
29 | |
|
30 | 0 | emitSourceFileHeader("HTML tag name matcher", OS); |
31 | |
|
32 | 0 | OS << "bool isHTMLTagName(StringRef Name) {\n"; |
33 | 0 | StringMatcher("Name", Matches, OS).Emit(); |
34 | 0 | OS << " return false;\n" |
35 | 0 | << "}\n\n"; |
36 | 0 | } |
37 | | |
38 | | void clang::EmitClangCommentHTMLTagsProperties(RecordKeeper &Records, |
39 | 0 | raw_ostream &OS) { |
40 | 0 | std::vector<Record *> Tags = Records.getAllDerivedDefinitions("Tag"); |
41 | 0 | std::vector<StringMatcher::StringPair> MatchesEndTagOptional; |
42 | 0 | std::vector<StringMatcher::StringPair> MatchesEndTagForbidden; |
43 | 0 | for (Record *Tag : Tags) { |
44 | 0 | std::string Spelling = std::string(Tag->getValueAsString("Spelling")); |
45 | 0 | StringMatcher::StringPair Match(Spelling, "return true;"); |
46 | 0 | if (Tag->getValueAsBit("EndTagOptional")) |
47 | 0 | MatchesEndTagOptional.push_back(Match); |
48 | 0 | if (Tag->getValueAsBit("EndTagForbidden")) |
49 | 0 | MatchesEndTagForbidden.push_back(Match); |
50 | 0 | } |
51 | |
|
52 | 0 | emitSourceFileHeader("HTML tag properties", OS); |
53 | |
|
54 | 0 | OS << "bool isHTMLEndTagOptional(StringRef Name) {\n"; |
55 | 0 | StringMatcher("Name", MatchesEndTagOptional, OS).Emit(); |
56 | 0 | OS << " return false;\n" |
57 | 0 | << "}\n\n"; |
58 | |
|
59 | 0 | OS << "bool isHTMLEndTagForbidden(StringRef Name) {\n"; |
60 | 0 | StringMatcher("Name", MatchesEndTagForbidden, OS).Emit(); |
61 | 0 | OS << " return false;\n" |
62 | 0 | << "}\n\n"; |
63 | 0 | } |
64 | | |