summaryrefslogtreecommitdiff
path: root/src/qdoc/clangcodeparser.cpp
diff options
context:
space:
mode:
authorMartin Smith <martin.smith@qt.io>2018-10-19 17:03:01 +0200
committerMartin Smith <martin.smith@qt.io>2018-12-03 08:55:57 +0000
commit7fea26a411ea3105ce2e27a360be29e2f356ac0a (patch)
treed2203b5c77790c6e057785391fe8063182252377 /src/qdoc/clangcodeparser.cpp
parent3daa8c3ceef4ee171414c549d8acf3d1bbfc20af (diff)
downloadqttools-7fea26a411ea3105ce2e27a360be29e2f356ac0a.tar.gz
qdoc: Do not print error for future functions
Some function declarations are marked as not existing until Qt 6.0 in both the .h and .cpp files, but they are documented in the .cpp file. qdoc can't tie the documentation for these functions to their declarations because of the way clang is used, and qdoc reports that reports the documentation as an error. This update let's qdoc ignore these functions and not print the error when they are marked with \since 6.0. This will also work with other future versions. This update also collects all the uses of #define COMMAND_xxx in one location, which was partially required by the \since 6.0 change. Change-Id: I55052359f387406da340c748768f8e76c0b39d53 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r--src/qdoc/clangcodeparser.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp
index acc3f2446..460c94365 100644
--- a/src/qdoc/clangcodeparser.cpp
+++ b/src/qdoc/clangcodeparser.cpp
@@ -1010,6 +1010,7 @@ ClangCodeParser::~ClangCodeParser()
void ClangCodeParser::initializeParser(const Config &config)
{
printParsingErrors_ = 1;
+ version_ = config.getString(CONFIG_VERSION);
const auto args = config.getStringList(CONFIG_INCLUDEPATHS);
includePaths_.resize(args.size());
std::transform(args.begin(), args.end(), includePaths_.begin(),
@@ -1309,6 +1310,13 @@ void ClangCodeParser::precompileHeaders()
clang_disposeIndex(index_);
}
+static float getUnpatchedVersion(QString t)
+{
+ if (t.count(QChar('.')) > 1)
+ t.truncate(t.lastIndexOf(QChar('.')));
+ return t.toFloat();
+}
+
/*!
Get ready to parse the C++ cpp file identified by \a filePath
and add its parsed contents to the database. \a location is
@@ -1390,12 +1398,20 @@ void ClangCodeParser::parseSourceFile(const Location& /*location*/, const QStrin
nodes.append(n);
docs.append(doc);
} else if (CodeParser::isWorthWarningAbout(doc)) {
- doc.location().warning(tr("Cannot tie this documentation to anything"),
- tr("qdoc found a /*! ... */ comment, but there was no "
- "topic command (e.g., '\\%1', '\\%2') in the "
- "comment and no function definition following "
- "the comment.")
- .arg(COMMAND_FN).arg(COMMAND_PAGE));
+ bool future = false;
+ if (doc.metaCommandsUsed().contains(COMMAND_SINCE)) {
+ QString sinceVersion = doc.metaCommandArgs(COMMAND_SINCE)[0].first;
+ if (getUnpatchedVersion(sinceVersion) > getUnpatchedVersion(version_))
+ future = true;
+ }
+ if (!future) {
+ doc.location().warning(tr("Cannot tie this documentation to anything"),
+ tr("qdoc found a /*! ... */ comment, but there was no "
+ "topic command (e.g., '\\%1', '\\%2') in the "
+ "comment and no function definition following "
+ "the comment.")
+ .arg(COMMAND_FN).arg(COMMAND_PAGE));
+ }
}
} else {
processTopicArgs(doc, topic, nodes, docs);