diff options
author | Topi Reinio <topi.reinio@qt.io> | 2021-03-18 16:39:30 +0100 |
---|---|---|
committer | Topi Reinio <topi.reinio@qt.io> | 2021-03-19 12:18:17 +0100 |
commit | 526604ea5705ba9c61161da98dafda93cafc5fba (patch) | |
tree | 86d07b376184576a7e43e9580b7126abc47a4ade /src/qdoc/clangcodeparser.cpp | |
parent | 12780bcb5d7830ce4fdc2f28b5acf0340200e8da (diff) | |
download | qttools-526604ea5705ba9c61161da98dafda93cafc5fba.tar.gz |
qdoc: Correctly handle const property types
The property type defined in Q_PROPERTY may contain the const
qualifier. Store the qualifier and make the code a bit more
robust against ill-formatted property declarations.
Pick-to: 6.0 6.1
Fixes: QTBUG-91990
Change-Id: I6b06e4c8af8bb9dec3c467c6e19d9987b8340110
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Diffstat (limited to 'src/qdoc/clangcodeparser.cpp')
-rw-r--r-- | src/qdoc/clangcodeparser.cpp | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/qdoc/clangcodeparser.cpp b/src/qdoc/clangcodeparser.cpp index 3bc36f220..866b8119d 100644 --- a/src/qdoc/clangcodeparser.cpp +++ b/src/qdoc/clangcodeparser.cpp @@ -974,14 +974,22 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc) QString signature = spelling.mid(lpIdx + 1, rpIdx - lpIdx - 1); signature = signature.simplified(); - QStringList part; - part = signature.split(QChar(' ')); - if (part.first() == QLatin1String("enum")) - part.takeFirst(); // QTBUG-80027 - if (part.size() < 2) + QString type; + QString name; + QStringList parts = signature.split(QChar(' '), Qt::SkipEmptyParts); + if (parts.size() < 2) + return false; + if (parts.first() == QLatin1String("enum")) + parts.removeFirst(); // QTBUG-80027 + + type = parts.takeFirst(); + if (type == QLatin1String("const") && parts.size() > 0) + type += " " + parts.takeFirst(); + + if (parts.size() > 0) + name = parts.takeFirst(); + else return false; - QString type = part.at(0); - QString name = part.at(1); if (name.front() == QChar('*')) { type.append(QChar('*')); @@ -992,9 +1000,9 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc) property->setLocation(loc); property->setDataType(type); - int i = 2; - while (i < part.size()) { - QString key = part.at(i++); + int i = 0; + while (i < parts.size()) { + const QString &key = parts.at(i++); // Keywords with no associated values if (key == "CONSTANT") { property->setConstant(); @@ -1003,8 +1011,8 @@ bool ClangVisitor::parseProperty(const QString &spelling, const Location &loc) } else if (key == "REQUIRED") { property->setRequired(); } - if (i < part.size()) { - QString value = part.at(i++); + if (i < parts.size()) { + QString value = parts.at(i++); if (key == "READ") { qdb_->addPropertyFunction(property, value, PropertyNode::Getter); } else if (key == "WRITE") { |