summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Hanselmann <public@hansmi.ch>2015-12-18 13:35:04 +0100
committerMichael Hanselmann <public@hansmi.ch>2016-01-05 16:19:55 +0000
commitbdd4e502ffd81084f33181426df31ffcddde637c (patch)
treef0e00d91344edd9ca9cc0b7caa30d35e3dab0638
parentb2f1ca59b7cc7764d673f5ed806552f188ed6361 (diff)
lupdate: Merge class name extraction loops
The extraction of class names was split over two separate loops. One for plain identifiers (e.g. “class Foo”) and another for qualified identifiers (e.g. “class Foo::Bar::Baz”). C++11 introduced the "final" identifier which may appear immediately after the name in a class definition. Detecting and skipping that identifier will only need to be in a single place when the two loops are merged. Change-Id: Id9ddc1ccd01cabcb4616d8c025b553c5be5c5807 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
-rw-r--r--src/linguist/lupdate/cpp.cpp33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/linguist/lupdate/cpp.cpp b/src/linguist/lupdate/cpp.cpp
index 996167a64..9acae45aa 100644
--- a/src/linguist/lupdate/cpp.cpp
+++ b/src/linguist/lupdate/cpp.cpp
@@ -1805,28 +1805,27 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac
if (yyBraceDepth == namespaceDepths.count() && yyParenDepth == 0) {
NamespaceList quali;
HashString fct;
- do {
- /*
- This code should execute only once, but we play
- safe with impure definitions such as
- 'class Q_EXPORT QMessageBox', in which case
- 'QMessageBox' is the class name, not 'Q_EXPORT'.
- */
- text = yyWord;
- text.detach();
- fct.setValue(text);
- yyTok = getToken();
- } while (yyTok == Tok_Ident);
- while (yyTok == Tok_ColonColon) {
- yyTok = getToken();
- if (yyTok != Tok_Ident)
- break; // Oops ...
- quali << fct;
+
+ // Find class name including qualification
+ forever {
text = yyWord;
text.detach();
fct.setValue(text);
yyTok = getToken();
+
+ if (yyTok == Tok_ColonColon) {
+ quali << fct;
+ yyTok = getToken();
+ } else if (yyTok == Tok_Ident) {
+ // Handle impure definitions such as 'class Q_EXPORT QMessageBox', in
+ // which case 'QMessageBox' is the class name, not 'Q_EXPORT', by
+ // abandoning any qualification collected so far.
+ quali.clear();
+ } else {
+ break;
+ }
}
+
if (yyTok == Tok_Colon) {
// Skip any token until '{' since we might do things wrong if we find
// a '::' token here.