War of the Worlds: C++ Namespaces vs Doxygen @addtogroup
· 3 min read
Five days after we taught our parser to read kind="group" files from Doxygen’s XML output (to save the “missing” free functions), our systematic parity check of the AST parser on a real corpus revealed wild architectural anomalies.
Doxygen is famous for mixing the visual structure of documentation (how humans want to read it) with the real semantics of C++ code (how the code works). The @addtogroup tag is a prime example of this. And our parser fell victim to this mixing on two independent fronts at once.
Trigger 1: Phantom Namespaces
We took the first hit from global functions without namespaces. A real example from the corpus: the global function cvFloor, documented inside the @addtogroup core_utils group.

In the XML file for this group, the cvFloor function lacked a <qualifiedname> tag entirely. Our parser, trying to determine the real C++ scope, used a fallback logic: since there is no exact name, take the name of the parent compound and attach it to the function.
But the parent compound was not a folder and not a namespace. It was the virtual group core_utils. As a result, our parser proudly declared that a function named core_utils::cvFloor existed in the project.
The parser naively confused the documentation group name with a real C++ namespace prefix, spawning a phantom namespace that had never existed in the code.
Trigger 2: The Enemy Within

The second bug turned out to be even more absurd in nature. This time, the victims were entities (for example, typedefs) that genuinely lay inside a C++ namespace, but were at the same time wrapped in @addtogroup.
In such cases, Doxygen behaved perfectly: it output an absolutely correct <qualifiedname> tag in the XML. Our top-level parser honestly read it. And then passed it down—to internal functions like _parse_type_alias_member.
And what did these functions do? They brazenly threw away the already calculated, correct Fully Qualified Name (FQN), took the raw name of the compound-group, and recalculated the FQN from scratch based on it! The parser itself was overwriting the correct information, replacing the real namespace with the group name. To cover this case with tests, we even had to write a synthetic fixture test_ns::InputArray that exactly mimicked the real behavior of the production code.
Separating Realities
To stop this madness, we had to strictly separate the worlds. We introduced a rule: compounds of the type group and file are “scopeless” (extra-structural).
This meant that their own names were strictly forbidden to be used as C++ prefixes in the fallback logic. And for the second bug, we rewrote the contracts of the internal functions: they no longer had the right to “guess” the FQN. The top level passed them an already verified scope (preferring <qualifiedname>), and they were obliged to use only that.
We drove visual grouping and the physical architecture of the code into different corners. But the @addtogroup tag was just the beginning. Next, real hardcore awaited us: we had to teach the strict libclang to understand specific legacy tags like @cond and @relates without running Doxygen at all. The paradox of parsing Doxygen tags without Doxygen—in the next episode.