From f98f1a09575d4bf2cacace173401d2e14c9f3236 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Thu, 29 Aug 2019 11:32:28 +0200 Subject: Handle Q_DECL_NOEXCEPT_EXPR()'s more common cases Unfortunately, the way matching and purging is done gets into trouble if one line contains two matches to a pattern and only one of them has been changed. Since noexcept()'s condition often is itself a noexcept() expression, noexcept(noexcept(...)) happens and we need to not match it (as the inner noexcept never used the macro). So this only a partially handle the replacement, but at least it catches the more common cases. Added a FIXME comment explaining the problem that prevents solving this better. Change-Id: I14b555c67dd9521bdc42adbce82267745ae7a56a Reviewed-by: Frederik Gladhorn --- packaging-tools/resetboring.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/packaging-tools/resetboring.py b/packaging-tools/resetboring.py index 263b42091..5c3a28250 100755 --- a/packaging-tools/resetboring.py +++ b/packaging-tools/resetboring.py @@ -402,6 +402,12 @@ class Selector(object): # Select interesting changes, discard boring. only differences between them are boring. """ tokens = cls.__split(text) + # FIXME: if several recipes apply, the returned selection + # of variants should represent the result of applying each + # subset of those recipes; this includes the case of + # applying one recipe repeatedly, where each candidate + # application may be included or omitted independently. + # But this would complicate harmonize() ... for test, purge in cls.recipe: if test(tokens): tokens = purge(tokens) @@ -667,10 +673,14 @@ class Selector(object): # Select interesting changes, discard boring. # 5.10: common switch from while (0) to while (false) # 5.12: Q_DECL_EQ_DELETE -> = delete - # 5.14: qMove -> std::move + # 5.14: qMove -> std::move, Q_DECL_NOEXCEPT_EXPR(...) -> noexcept(...) for swap in ((('while', '(', '0', ')'), ('while', '(', 'false', ')')), (('Q_DECL_EQ_DELETE', ';'), ('=', 'delete', ';')), (('qMove',), ('std', '::', 'move')), + # Needs to happen before handling of Q_DECL_NOEXCEPT (as both replace "noexcept"): + # Gets complicated by the first case being common: + (('Q_DECL_NOEXCEPT_EXPR', '(', 'noexcept', '('), ('noexcept', '(', 'noexcept', '(')), + (('Q_DECL_NOEXCEPT_EXPR', '(', '('), ('noexcept', '(', '(')), ): def find(words, after=swap[1]): try: -- cgit v1.2.3