Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mrdocs.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ grammar

SymbolID = text # Base64-encoded

Bool = "1"
Bool = empty # empty element when true, omitted when false

#---------------------------------------------
# Enums
Expand Down
20 changes: 11 additions & 9 deletions src/lib/Gen/xml/XMLWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,9 @@ XMLWriter::write(T const& value)
using Type = std::decay_t<T>;

// Primitives: write as text content
if constexpr (std::is_same_v<Type, bool>)
{
os_ << '1';
}
else if constexpr (std::is_same_v<Type, std::string> ||
std::is_same_v<Type, dom::String> ||
std::is_same_v<Type, llvm::StringRef>)
if constexpr (std::is_same_v<Type, std::string> ||
std::is_same_v<Type, dom::String> ||
std::is_same_v<Type, llvm::StringRef>)
{
os_ << xmlEscape(value);
}
Expand Down Expand Up @@ -189,8 +185,14 @@ XMLWriter::writeElement(std::string_view tag, T const& value)
os_ << xmlEscape(value.Written);
os_ << "</" << tag << ">\n";
}
else if constexpr (std::is_same_v<Type, bool> ||
std::is_same_v<Type, std::string> ||
else if constexpr (std::is_same_v<Type, bool>)
{
// A false `bool` was skipped above. A true `bool` carries no
// text body: the element's presence alone encodes the value,
// so emit an empty element.
tags_.indent() << '<' << tag << "/>\n";
}
else if constexpr (std::is_same_v<Type, std::string> ||
std::is_same_v<Type, dom::String> ||
std::is_integral_v<Type> ||
std::is_same_v<Type, SymbolID> ||
Expand Down
60 changes: 30 additions & 30 deletions test-files/golden-tests/config/auto-brief/auto-brief.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>70</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -82,7 +82,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>48</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -115,7 +115,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>60</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -148,7 +148,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>55</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -183,7 +183,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>104</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -215,7 +215,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>83</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -247,7 +247,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>88</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -279,7 +279,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>93</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -311,7 +311,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>77</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -343,7 +343,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>135</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -383,7 +383,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>120</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -423,7 +423,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>125</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -463,7 +463,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>8</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -495,7 +495,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>17</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -534,7 +534,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>24</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -573,7 +573,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>175</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -596,7 +596,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>165</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -619,7 +619,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>170</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -642,7 +642,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>43</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -675,7 +675,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>65</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -698,7 +698,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>38</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -721,7 +721,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>98</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -744,7 +744,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>115</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -777,7 +777,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>130</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -800,7 +800,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>110</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -823,7 +823,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>143</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand All @@ -846,7 +846,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>32</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -907,7 +907,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>160</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -940,7 +940,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>150</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down Expand Up @@ -972,7 +972,7 @@
<source-path>auto-brief.cpp</source-path>
<line-number>155</line-number>
<column-number>1</column-number>
<documented>1</documented>
<documented/>
</location>
</source>
<kind>function</kind>
Expand Down
Loading
Loading