diff options
author | Martin Smith <martin.smith@qt.io> | 2017-01-18 13:47:46 +0100 |
---|---|---|
committer | Martin Smith <martin.smith@qt.io> | 2017-08-10 07:34:00 +0000 |
commit | 015a0fdf3e89993efd4905c688f4f1de8b522cbb (patch) | |
tree | 273a70ee00ba8eb4510ad3e803c7bf3b36c447d5 /src/qdoc/cppcodeparser.cpp | |
parent | 816b967374aa714139ddc59676dd32702bed9f49 (diff) | |
download | qttools-015a0fdf3e89993efd4905c688f4f1de8b522cbb.tar.gz |
qdoc: A different way to fix the "signed" problem
The old qdoc parser is still used for parsing \fn
commands because clang can't be used to parse code
fragments. This causes a problem when the "signed"
reserved word is used because clang doesn't keep
it if it doesn't add anything to the type, while
the old qdoc parser always appends it to the type
under construction.
The fix here is to let the old qdoc parser hold
the "signed" reserved word aside until it knows
what the next lexeme is. Then it either appends
the held "signed" or discards it, depending on
what the next lexeme is. e.g., if the next word
is "int" discard "signed" but if the next word
is "char" append the held "signed" before
appending "char".
Change-Id: I67953d964cd09410126d64fa3305c669111e74ce
Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'src/qdoc/cppcodeparser.cpp')
-rw-r--r-- | src/qdoc/cppcodeparser.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/qdoc/cppcodeparser.cpp b/src/qdoc/cppcodeparser.cpp index d22cdffbb..a71c341a7 100644 --- a/src/qdoc/cppcodeparser.cpp +++ b/src/qdoc/cppcodeparser.cpp @@ -1099,11 +1099,24 @@ bool CppCodeParser::matchDataType(CodeChunk *dataType, QString *var, bool qProp) */ while (match(Tok_const) || match(Tok_volatile)) dataType->append(previousLexeme()); - while (match(Tok_signed) || match(Tok_unsigned) || - match(Tok_short) || match(Tok_long) || match(Tok_int64)) { - dataType->append(previousLexeme()); + QString pending; + while (tok == Tok_signed || tok == Tok_int || tok == Tok_unsigned || + tok == Tok_short || tok == Tok_long || tok == Tok_int64) { + if (tok == Tok_signed) + pending = lexeme(); + else { + if (tok == Tok_unsigned && !pending.isEmpty()) + dataType->append(pending); + pending.clear(); + dataType->append(lexeme()); + } + readToken(); virgin = false; } + if (!pending.isEmpty()) { + dataType->append(pending); + pending.clear(); + } while (match(Tok_const) || match(Tok_volatile)) dataType->append(previousLexeme()); |