chiark / gitweb /
doxygen: it gets extra shitty when encountering decltype(auto).
authorVladimír Vondruš <mosra@centrum.cz>
Fri, 22 Feb 2019 22:58:59 +0000 (23:58 +0100)
committerVladimír Vondruš <mosra@centrum.cz>
Sat, 23 Feb 2019 00:10:00 +0000 (01:10 +0100)
Seriously, is the parser a box full of angry monkeys?! How is this
possible.

doxygen/dox2html5.py
doxygen/test/cpp_function_attributes/input.h
doxygen/test/cpp_function_attributes/structFoo.html

index b59d8e1fb435475b3cdb1f2957264632108b12bf..804d95fa00c0d935f5334641fc271e43430a4bee 100755 (executable)
@@ -1849,6 +1849,12 @@ def parse_func(state: State, element: ET.Element):
     elif func.type.startswith('constexpr'):
         func.type = func.type[10:]
         func.is_constexpr = True
+    # For some effing reason, when a constexpr function has decltype(auto)
+    # return type, Doxygen swaps the order of those two, causing the constexpr
+    # to be last. See the cpp_function_attributes test for a verification.
+    elif func.type.endswith('constexpr'):
+        func.type = func.type[:-10]
+        func.is_constexpr = True
     else:
         func.is_constexpr = False
     func.prefix = ''
index 2d97756ea28902b650e609457f51a4556aeb1f58..76ef644aa213364d6e460a63d1a2a823f5b26ca0 100644 (file)
@@ -29,6 +29,22 @@ struct Foo {
      * Details.
      */
     virtual void foo() const noexcept(false) = 0;
+
+    /**
+     * @brief Random type and constexpr together
+     *
+     * This is okay.
+     */
+    constexpr Foo& bar() noexcept;
+
+    /**
+     * @brief decltype(auto) and constexpr together
+     *
+     * For some reason, due to decltype(auto), Doxygen swaps the order, causing
+     * the constexpr to be hard to detect. Don't even ask how it handles
+     * trailing return types. It's just HORRIBLE.
+     */
+    constexpr decltype(auto) baz() noexcept;
 };
 
 /** @brief Base class */
index 3012f95de396afdedbe7e906aeb8d6f2d3ecb299..566e5e37b9f8107f5e01cd0e37906036526c8151 100644 (file)
               <span class="m-dox-wrap-bumper">void <a href="#a67e9f6865d19c8e7734b182143d5e9b3" class="m-dox">foo</a>(</span><span class="m-dox-wrap">) const <span class="m-label m-flat m-warning">pure virtual</span> <span class="m-label m-flat m-success">noexcept(…)</span></span>
             </dt>
             <dd>Const, conditional noexcept and a pure virtual.</dd>
+            <dt>
+              <span class="m-dox-wrap-bumper">auto <a href="#a6c32baeb1c9a472657fd3ee8c191aa07" class="m-dox">bar</a>(</span><span class="m-dox-wrap">) -&gt; <a href="structFoo.html" class="m-dox">Foo</a>&amp; <span class="m-label m-flat m-primary">constexpr</span> <span class="m-label m-flat m-success">noexcept</span></span>
+            </dt>
+            <dd>Random type and constexpr together.</dd>
+            <dt>
+              <span class="m-dox-wrap-bumper">auto <a href="#aab09b9411135eae10f8c3abab0a0db54" class="m-dox">baz</a>(</span><span class="m-dox-wrap">) -&gt; decltype(auto) <span class="m-label m-flat m-primary">constexpr</span> <span class="m-label m-flat m-success">noexcept</span></span>
+            </dt>
+            <dd>decltype(auto) and constexpr together</dd>
           </dl>
         </section>
         <section>
             <p>Const, conditional noexcept and a pure virtual.</p>
 <p>Details.</p>
           </div></section>
+          <section class="m-dox-details" id="a6c32baeb1c9a472657fd3ee8c191aa07"><div>
+            <h3>
+              <span class="m-dox-wrap-bumper"><a href="structFoo.html" class="m-dox">Foo</a>&amp; Foo::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#a6c32baeb1c9a472657fd3ee8c191aa07" class="m-dox-self">bar</a>(</span><span class="m-dox-wrap">) <span class="m-label m-primary">constexpr</span> <span class="m-label m-success">noexcept</span></span></span>
+            </h3>
+            <p>Random type and constexpr together.</p>
+<p>This is okay.</p>
+          </div></section>
+          <section class="m-dox-details" id="aab09b9411135eae10f8c3abab0a0db54"><div>
+            <h3>
+              <span class="m-dox-wrap-bumper">decltype(auto) Foo::<wbr /></span><span class="m-dox-wrap"><span class="m-dox-wrap-bumper"><a href="#aab09b9411135eae10f8c3abab0a0db54" class="m-dox-self">baz</a>(</span><span class="m-dox-wrap">) <span class="m-label m-primary">constexpr</span> <span class="m-label m-success">noexcept</span></span></span>
+            </h3>
+            <p>decltype(auto) and constexpr together</p>
+<p>For some reason, due to decltype(auto), Doxygen swaps the order, causing the constexpr to be hard to detect. Don&#x27;t even ask how it handles trailing return types. It&#x27;s just HORRIBLE.</p>
+          </div></section>
         </section>
       </div>
     </div>