name = p.find('declname')
param = Empty()
param.name = name.text if name is not None else ''
- param.type = parse_type(state, p.find('type'))
+ param_type = p.find('type')
+ if param_type is None:
+ logging.warning("{}: parameter {} of function {} has no type, ignoring the whole function as it's suspected to be a mishandled macro call".format(state.current, param.name, func.name))
+ return None
+ param.type = parse_type(state, param_type)
# Recombine parameter name and array information back
array = p.find('array')
--- /dev/null
+/** @file
+ * @brief A file.
+ */
+
+/** @brief A function-defining macro */
+#define DEFINE_FUNCTION(name) int function_ ## name(int param)
+
+/**
+@brief A function-defining macro call
+
+This one is misparsed as a function definition and because it doesn't do
+anything that would make it look suspicious, it will appear in the output.
+*/
+DEFINE_FUNCTION(a) {
+ return param;
+}
+
+/**
+@brief A function-defining macro call
+
+In this case the $ will however lead to the parameter to have a declname but
+not a type, which triggers a suspicion in the parser and so the whole function
+gets ignored.
+*/
+DEFINE_FUNCTION($) {
+ return param;
+}
--- /dev/null
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8" />
+ <title>File.h file | My Project</title>
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,600i%7CSource+Code+Pro:400,400i,600" />
+ <link rel="stylesheet" href="m-dark+documentation.compiled.css" />
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+</head>
+<body>
+<header><nav id="navigation">
+ <div class="m-container">
+ <div class="m-row">
+ <a href="index.html" id="m-navbar-brand" class="m-col-t-8 m-col-m-none m-left-m">My Project</a>
+ </div>
+ </div>
+</nav></header>
+<main><article>
+ <div class="m-container m-container-inflatable">
+ <div class="m-row">
+ <div class="m-col-l-10 m-push-l-1">
+ <h1>
+ File.h <span class="m-thin">file</span>
+ </h1>
+ <p>A file.</p>
+ <nav class="m-block m-default">
+ <h3>Contents</h3>
+ <ul>
+ <li>
+ Reference
+ <ul>
+ <li><a href="#func-members">Functions</a></li>
+ <li><a href="#define-members">Defines</a></li>
+ </ul>
+ </li>
+ </ul>
+ </nav>
+ <section id="func-members">
+ <h2><a href="#func-members">Functions</a></h2>
+ <dl class="m-doc">
+ <dt>
+ <span class="m-doc-wrap-bumper"><a href="#a720de5dd630a2721e555233c5242142a" class="m-doc">DEFINE_FUNCTION</a>(</span><span class="m-doc-wrap">a)</span>
+ </dt>
+ <dd>A function-defining macro call.</dd>
+ </dl>
+ </section>
+ <section id="define-members">
+ <h2><a href="#define-members">Defines</a></h2>
+ <dl class="m-doc">
+ <dt id="a85e81f41af5f02b030bf07f4967a0a08">
+ <span class="m-doc-wrap-bumper">#define <a href="#a85e81f41af5f02b030bf07f4967a0a08" class="m-doc-self">DEFINE_FUNCTION</a>(</span><span class="m-doc-wrap">name)</span>
+ </dt>
+ <dd>A function-defining macro.</dd>
+ </dl>
+ </section>
+ <section>
+ <h2>Function documentation</h2>
+ <section class="m-doc-details" id="a720de5dd630a2721e555233c5242142a"><div>
+ <h3>
+ <span class="m-doc-wrap-bumper"> </span><span class="m-doc-wrap"><span class="m-doc-wrap-bumper"><a href="#a720de5dd630a2721e555233c5242142a" class="m-doc-self">DEFINE_FUNCTION</a>(</span><span class="m-doc-wrap">a)</span></span>
+ </h3>
+ <p>A function-defining macro call.</p>
+<p>This one is misparsed as a function definition and because it doesn't do anything that would make it look suspicious, it will appear in the output.</p>
+ </div></section>
+ </section>
+ </div>
+ </div>
+ </div>
+</article></main>
+</body>
+</html>
def test(self):
self.run_doxygen(wildcard='structFoo.xml')
self.assertEqual(*self.actual_expected_contents('structFoo.html'))
+
+class MishandledMacroCall(IntegrationTestCase):
+ def test(self):
+ with self.assertLogs() as cm:
+ self.run_doxygen(wildcard='*.xml')
+ self.assertEqual(*self.actual_expected_contents('File_8h.html'))
+ self.assertEqual(cm.output, [
+ "WARNING:root:File_8h.xml: parameter $ of function DEFINE_FUNCTION has no type, ignoring the whole function as it's suspected to be a mishandled macro call"
+ ])