================
@@ -81,29 +81,127 @@ enum class Shapes {
// MD-INDEX: **brief** Shape Types
// COM: FIXME: Serialize "enum class" in template
-// HTML-INDEX: <div>
-// HTML-INDEX: <pre><code class="language-cpp code-clang-doc">enum
Shapes : int</code></pre>
-// HTML-INDEX: </div>
-// HTML-INDEX: <table class="table-wrapper">
-// HTML-INDEX: <tbody>
-// HTML-INDEX: <tr>
-// HTML-INDEX: <th>Name</th>
-// HTML-INDEX: <th>Value</th>
-// HTML-INDEX: </tr>
-// HTML-INDEX: <tr>
-// HTML-INDEX: <td>Circle</td>
-// HTML-INDEX: <td>0</td>
-// HTML-INDEX: </tr>
-// HTML-INDEX: <tr>
-// HTML-INDEX: <td>Rectangle</td>
-// HTML-INDEX: <td>1</td>
-// HTML-INDEX: </tr>
-// HTML-INDEX: <tr>
-// HTML-INDEX: <td>Triangle</td>
-// HTML-INDEX: <td>2</td>
-// HTML-INDEX: </tr>
-// HTML-INDEX: </tbody>
-// HTML-INDEX: </table>
+// HTML-INDEX-LABEL: <pre><code class="language-cpp code-clang-doc">enum
Shapes</code></pre>
+// HTML-INDEX-NEXT: </div>
+// HTML-INDEX-NEXT: <table class="table-wrapper">
+// HTML-INDEX-NEXT: <tbody>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <th>Name</th>
+// HTML-INDEX-NEXT: <th>Value</th>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <td>Circle</td>
+// HTML-INDEX-NEXT: <td>0</td>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <td>Rectangle</td>
+// HTML-INDEX-NEXT: <td>1</td>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <td>Triangle</td>
+// HTML-INDEX-NEXT: <td>2</td>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: </tbody>
+// HTML-INDEX-NEXT: </table>
+
+/**
+ * @brief Specify the size
+ */
+enum Size : uint8_t {
+ // MD-INDEX-LINE: *Defined at
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
+ // HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+ Small, ///< A pearl
+ Medium, ///< A tennis ball
+ Large ///< A football
+};
+
+// MD-INDEX: | enum Size : uint8_t |
+// MD-INDEX: --
+// MD-INDEX: | Small |
+// MD-INDEX: | Medium |
+// MD-INDEX: | Large |
+// MD-INDEX: **brief** Specify the size
+
+// HTML-INDEX: <pre><code class="language-cpp code-clang-doc">enum
Size : uint8_t</code></pre>
+// HTML-INDEX-NEXT: </div>
+// HTML-INDEX-NEXT: <table class="table-wrapper">
+// HTML-INDEX-NEXT: <tbody>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <th>Name</th>
+// HTML-INDEX-NEXT: <th>Value</th>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <td>Small</td>
+// HTML-INDEX-NEXT: <td>0</td>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <td>Medium</td>
+// HTML-INDEX-NEXT: <td>1</td>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <td>Large</td>
+// HTML-INDEX-NEXT: <td>2</td>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: </tbody>
+// HTML-INDEX-NEXT: </table>
+
+/**
+ * @brief Very long number
+ */
+enum : long long {
+ // MD-INDEX-LINE: *Defined at
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
+ // HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+ BigVal = 999999999999
+};
+
+// MD-INDEX: | enum : long long |
+// MD-INDEX: --
+// MD-INDEX: | BigVal |
+// MD-INDEX: **brief** Very long number
+
+// HTML-INDEX: <pre><code class="language-cpp code-clang-doc">enum :
long long</code></pre>
+// HTML-INDEX-NEXT: </div>
+// HTML-INDEX-NEXT: <table class="table-wrapper">
+// HTML-INDEX-NEXT: <tbody>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <th>Name</th>
+// HTML-INDEX-NEXT: <th>Value</th>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: <tr>
+// HTML-INDEX-NEXT: <td>BigVal</td>
+// HTML-INDEX-NEXT: <td>999999999999</td>
+// HTML-INDEX-NEXT: </tr>
+// HTML-INDEX-NEXT: </tbody>
+// HTML-INDEX-NEXT: </table>
+
+/**
+ * @brief This is a top secret
+ */
+enum {
+ // MD-INDEX-LINE: *Defined at
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp#[[@LINE-1]]*
+ // HTML-INDEX-LINE: <p>Defined at line [[@LINE-2]] of file
{{.*}}clang-tools-extra{{[\/]}}test{{[\/]}}clang-doc{{[\/]}}enum.cpp</p>
+ secret = true
+};
+
+// MD-INDEX: | enum |
+// MD-INDEX: --
+// MD-INDEX: | secret |
+// MD-INDEX: **brief** This is a top secret
----------------
ilovepi wrote:
This doesn't look correct to me. Looking at the AST:
```
TranslationUnitDecl
`-EnumDecl <line:1:1, line:3:1> line:1:1
`-EnumConstantDecl <line:2:5, col:14> col:5 secret '(unnamed enum at
line:1:1)'
`-ImplicitCastExpr <col:14> 'unsigned int' <IntegralCast>
`-ConstantExpr <col:14> 'bool'
|-value: Int 1
`-CXXBoolLiteralExpr <col:14> 'bool' true
```
I'd guess if the name is empty, we should not that its unnamed or similar.
TBH this is probably something that the compiler should produce a diagnostic
for, but AFAICT its allowed per language rules, even though it can never be
referenced/used. There's a historic use w/in classes for pre-C++11 code, but
not for anything at file scope, like we see here. Since its legal
syntactically, I suppose we need to do something reasonable, and thats likely
just print that is unnamed/anonymous. Given the special circumstance, we should
have another version w/in a class.
I've personally seen this construct before:
```c++
class FilePermissions {
public:
enum {
Read = 1 << 0, // 1
Write = 1 << 1, // 2
Execute = 1 << 2 // 4
};
void set(int flags);
};
// ... Used in some other code
FilePermissions p;
p.set(FilePermissions::Read | FilePermissions::Write);
```
Something along those lines would work fine. Debatable if that's more
appropriate for the `class` tests or for this file. I'm fine either way, so put
it where you think its most appropriate. Also fine to use a different example.
https://github.com/llvm/llvm-project/pull/181347
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits