diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-11-03 11:41:06 +0100 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2020-11-03 19:36:34 +0000 |
commit | d3ed7dac8aa2f4ede0c409254b9dd44842086be0 (patch) | |
tree | b9fceef739824890f70a8e935e5d5bff8e7864eb /src/tools/moc | |
parent | ca85d3370fa59e124b5568e86dc406029829e10a (diff) |
moc: Handle include in enum, take 2
The existing logic broke down when we reentered the enumerator parsing
loop, and encountered a INCLUDE_MOC_END token in the first handleInclude
call. Fix this by restarting the loop in that case.
Amends d8a2456fbf18f60e2d1950585d93aa530df077bf.
Fixes: QTBUG-88125
Pick-to: 5.15
Change-Id: I87acaa986a81de53730eddc40bc7d48c15328aba
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/tools/moc')
-rw-r--r-- | src/tools/moc/moc.cpp | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index 15c35234c9..494adbda00 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -240,6 +240,12 @@ Type Moc::parseType() return type; } +enum class IncludeState { + IncludeBegin, + IncludeEnd, + NoInclude, +}; + bool Moc::parseEnum(EnumDef *def) { bool isTypdefEnum = false; // typedef enum { ... } Foo; @@ -260,18 +266,28 @@ bool Moc::parseEnum(EnumDef *def) } if (!test(LBRACE)) return false; - auto handleInclude = [this]() { - if (test(MOC_INCLUDE_BEGIN)) + auto handleInclude = [this]() -> IncludeState { + bool hadIncludeBegin = false; + if (test(MOC_INCLUDE_BEGIN)) { currentFilenames.push(symbol().unquotedLexem()); + // we do not return early to handle empty headers in one go + hadIncludeBegin = true; + } if (test(NOTOKEN)) { next(MOC_INCLUDE_END); currentFilenames.pop(); + return IncludeState::IncludeEnd; } + if (hadIncludeBegin) + return IncludeState::IncludeBegin; + else + return IncludeState::NoInclude; }; do { if (lookup() == RBRACE) // accept trailing comma break; - handleInclude(); + if ( handleInclude() == IncludeState::IncludeEnd) + continue; next(IDENTIFIER); def->values += lexem(); handleInclude(); |