From bdd4e502ffd81084f33181426df31ffcddde637c Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Fri, 18 Dec 2015 13:35:04 +0100 Subject: lupdate: Merge class name extraction loops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/linguist/lupdate/cpp.cpp | 33 ++++++++++++++++----------------- 1 file 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. -- cgit v1.2.1