summaryrefslogtreecommitdiffstats
path: root/libexec
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2021-09-02 15:52:07 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2021-09-07 08:28:09 +0200
commit6c174364491ea6674df64f26934f9418f7f40651 (patch)
tree4b7da9d3c41f43dc07fddf8a48b5b29cca7982ec /libexec
parent115d99b7de934f30d52fbcf56ee4ff170377dd26 (diff)
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 <alexandru.croitor@qt.io>
Diffstat (limited to 'libexec')
-rwxr-xr-xlibexec/syncqt.pl29
1 files changed, 28 insertions, 1 deletions
diff --git a/libexec/syncqt.pl b/libexec/syncqt.pl
index acdc469ba2..2f69e14f83 100755
--- a/libexec/syncqt.pl
+++ b/libexec/syncqt.pl
@@ -193,6 +193,33 @@ sub shouldMasterInclude {
}
######################################################################
+# 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"
# (out) clean, boolean, will be set to false if the header isn't clean
@@ -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 *.*\(\*([^\)]*)\)\(.*\);$/) {