summaryrefslogtreecommitdiff
path: root/src/qdoc/clangcodeparser.cpp
diff options
context:
space:
mode:
authorLuca Di Sera <luca.disera@qt.io>2023-03-17 14:20:38 +0100
committerLuca Di Sera <luca.disera@qt.io>2023-03-19 16:04:41 +0100
commitbf03e5a11f4052e74da260bfedcf23f4761113af (patch)
tree2cf3b809db36a7eb56994de5d559319d95e75285 /src/qdoc/clangcodeparser.cpp
parent105791ef458d50f84387efbd8526671a8d8fd9a6 (diff)
downloadqttools-bf03e5a11f4052e74da260bfedcf23f4761113af.tar.gz
QDoc: Remove `CppCodeParser::metaCommands`
As part of extracting user-provided documentation, QDoc has to parse a variety of source files in a variety of languages. `CodeParser` is the base class of objects that take care of performing this parsing process in QDoc. When extracting the documentation in one of the `CodeParser`s QDoc generally tries to parse the extracted documentation in-place. The documentation has a series of available commands that might depend on the currently used parser. To support this process some of the `CodeParser` child classes provides series of methods to retrieve the required commands for each parser. `CppCodeParser`, the parser that provides the semantic for QDoc's comment-blocks, for example, provides `metaCommands`, to list the available "meta commands" in a comment-block. `metaCommands` returns a static member, `metaComamnds_`. This static member is initialized during the construction of an `CppCodeParser` instance, and the initialization is made so that it doesn't run more than once, albeit this is done in a non-thread-safe way. The initialization is based on `CppCodeParser::common_meta_commands`, as a base, plus some other commands that are not in `common_meta_commands`. Generally, this process could be better expressed by the use of a static with in-place initialization. There are two probable reasons why this has not been the way it was written in the past. Supposedly, when this code was written, there was no suitable way to initialize a `QSet<QString>`, the type of `metaCommands_`, in-place, as similar patterns can be found in other legacy parts of QDoc that are confirmed to have had this issue due to their age. Additionally, the expansion of the `COMMAND_*` macros, which form the content for `metaCommands_`, were, until recently, dependent on certain data being available in another part of the system, so that expanding them in a static context that would be processed before this data was available would incur into a series of errors. This dependency was removed in a recent patch, so that the issue is no more. Hence, the `metaCommands()` method is removed, along with `metaCommands_`, in favor of a public static, `meta_commands`, that is initialized in-place, to simplify the related code. All usages of `meta_commands` were modified to refer to `CppCodeParser::meta_commands`, keeping an equivalent semantic, as a consequence of the change. As the initialization of `metaCommands_` was the only thing that was being done in the constructor for `CppCodeParser`, the constructor was removed in favor of a default one. Change-Id: I6e54b95a50d07a394d727c0af8c409599a088d4c Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r--src/qdoc/clangcodeparser.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index b9aa27fbe..4589df9ed 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -1563,7 +1563,7 @@ void ClangCodeParser::parseSourceFile(const Location & /*location*/, const QStri
CXToken *tokens;
unsigned int numTokens = 0;
- const QSet<QString> &commands = CppCodeParser::topic_commands + metaCommands();
+ const QSet<QString> &commands = CppCodeParser::topic_commands + CppCodeParser::meta_commands;
clang_tokenize(tu, clang_getCursorExtent(tuCur), &tokens, &numTokens);
for (unsigned int i = 0; i < numTokens; ++i) {