DEV Community

Cover image for Missing in Action: Where @addtogroup Functions Hide
Flude team
Flude team

Posted on Originally published at blog.flude.guide

Missing in Action: Where @addtogroup Functions Hide

During the migration of our documentation generator to a native C++ AST parser (via libclang), we constantly pitted two models against each other: the old one, built from Doxygen XML dumps, and the new, native one. It was a long process of systematic parity checking across a massive real-world codebase.

On one such run, we noticed a strange anomaly. Hundreds of global functions—for example, cv::fastMalloc—looked as if the old Doxygen hadn't been able to parse them at all. They were in the native AST, but the Doxygen model was empty. We should have rejoiced (our new parser is cooler!), but we decided to get to the bottom of it.

Missing In Action addtogroup

It turned out the functions hadn't disappeared anywhere. They had been sitting in the Doxygen XML output the whole time; our XML parser simply refused to look at them.

The Blind Whitelist

In C++, code is physically grouped by files and namespaces. (We parsed classes and structs using a completely separate, independent mechanism). Therefore, our Doxygen-XML parser had a strict whitelist for so-called "compound" types: we only read nodes with kind="namespace" and kind="file".

But C++ developers have a habit: they love to visually group functions in documentation using the \defgroup or @addtogroup tags. When Doxygen sees such a tag, it rips the documented free functions out of their native files and stockpiles them in separate XML files with the type kind="group".

Our parser simply didn't know about this compound type. Encountering a "group," it silently skipped the file, leaving a huge swath of the global API overboard.

An Elegant Fix

Missing In Action Addtogroup Part 2

The solution was simple: we added group to the whitelist and ran these files through the same pipeline as namespaces.

We immediately built a small safeguard into this patch: when parsing a group, the parser had to prefer the exact <qualifiedname> tag (where Doxygen stored the real C++ path of the function), rather than naively trying to concatenate the visual group name with the function name.

The fix looked perfect and absolutely complete. We ran two consecutive runs on the full real-world C++ corpus. The result: 63 out of 63 tests green. The statistics of nodes found in the Doxygen model spiked upwards, perfectly matching the native parser in coverage of free functions.

We celebrated a clean, verified victory over legacy code.

But we only thought we had won. Five days later, during further systematic corpus parity checks, this little victory turned into an architectural disaster. How visual documentation groups tried to destroy real C++ namespaces—read about it in the next episode.


Originally published on our blog: https://blog.flude.guide/blog/missing-in-action-addtogroup

Also read us:

Top comments (0)