From 6c174364491ea6674df64f26934f9418f7f40651 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 2 Sep 2021 15:52:07 +0200 Subject: Teach syncqt to filter out QT_DEPRECATED_* macros We already had code that filtered out QT_DEPRECATED_X("text"). But that isn't enough, because, by now, we have a true cornucopia of QT_DEPRECATED_* macros. And only some are called with an argument list. Move the filtering code into the subroutine filterDeprecationMacros, because our filtering is slightly more complex now: - Try to match a QT_DEPRECATED_* macro call. - Try to match balanced parentheses with a recursive regular expression. - Check whether the found balanced parentheses are directly behind QT_DEPRECATED_*, because only then it is the argument list of that macro. - Filter out what we've found. With this patch, syncqt doesn't discard deprecated classes anymore. Task-number: QTBUG-80347 Change-Id: I7872159639be330d5a039c98eac0c5007d9acb93 Reviewed-by: Alexandru Croitor --- libexec/syncqt.pl | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'libexec') diff --git a/libexec/syncqt.pl b/libexec/syncqt.pl index acdc469ba2..2f69e14f83 100755 --- a/libexec/syncqt.pl +++ b/libexec/syncqt.pl @@ -192,6 +192,33 @@ sub shouldMasterInclude { return 1; } +###################################################################### +# Syntax: filterDeprecationMacros(line) +# Params: line: a line of C++ source +# +# Purpose: Removes occurrences of QT_DEPRECATED_* macro calls. +# The calls may have an argument list that is also removed. +# Returns: The filtered line. +###################################################################### +sub filterDeprecationMacros { + my $line = $_[0]; + my $rest; + if ($line =~ /(.*\s+)QT_DEPRECATED_[[:upper:][:digit:]_]+\s*(.*)/) { + $line = $1; + $rest = $2; + + # Does the macro call have an argument list? If so, remove it. + # The regular expression matches balanced parenthesis anywhere in $rest. + # Therefore, we must check whether the match starts at index zero. + if ($rest =~ /\((?:[^)(]+|(?R))*+\)/ && $-[0] == 0) { + $line .= substr($rest, $+[0]); + } else { + $line .= $rest; + } + } + return $line; +} + ###################################################################### # Syntax: classNames(iheader, clean, requires) # Params: iheader, string, filename to parse for classname "symlinks" @@ -298,7 +325,7 @@ sub classNames { if($definition) { $definition =~ s=[\n\r]==g; - $definition =~ s/QT_DEPRECATED_X\s*\(\s*".*?"\s*\)//g; + $definition = filterDeprecationMacros($definition); my @symbols; my $post_kw = qr/Q_DECL_FINAL|final|sealed/; # add here macros and keywords that go after the class-name of a class definition if($definition =~ m/^ *typedef *.*\(\*([^\)]*)\)\(.*\);$/) { -- cgit v1.2.3