[Libreoffice-commits] core.git: compilerplugins/clang
LuboÅ¡ LuÅák (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jan 28 18:34:31 UTC 2020
compilerplugins/clang/sharedvisitor/generator.cxx | 28 ++++++++++++++--------
1 file changed, 18 insertions(+), 10 deletions(-)
New commits:
commit 1565bcaff401366937c800d8f4617df2b4f68271
Author: Luboš Luňák <l.lunak at collabora.com>
AuthorDate: Tue Jan 28 15:55:33 2020 +0100
Commit: Luboš Luňák <l.lunak at collabora.com>
CommitDate: Tue Jan 28 19:33:54 2020 +0100
avoid compilerplugin's sharedvisitor bailing out prematurely
The simplifyconstruct test can return false from a Visit*() function
(thus ending the whole traversal) because anyPluginActive() would
return false just because a plugin would be temporarily disabled
in Traverse*() because of its PreTraverse*() returning false. Keep
a count of temporarily disabled plugins to prevent this.
Change-Id: I413d88749257acff2220182d13e8fcd0f7289540
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87636
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak at collabora.com>
diff --git a/compilerplugins/clang/sharedvisitor/generator.cxx b/compilerplugins/clang/sharedvisitor/generator.cxx
index 38e6527a7bb3..e62b27fd6422 100644
--- a/compilerplugins/clang/sharedvisitor/generator.cxx
+++ b/compilerplugins/clang/sharedvisitor/generator.cxx
@@ -141,7 +141,15 @@ void generateVisitor( PluginType type )
" : FilteringPlugin(rData)\n";
for( const PluginInfo& plugin : plugins[ type ] )
output << " , " << plugin.variableName << "( nullptr )\n";
- output << " {}\n";
+ output << " , activeRefCount( 0 )\n";
+ output << " {}\n";
+
+ output <<
+" ~SharedRecursiveASTVisitor" << pluginTypeNames[ type ] << "()\n"
+" {\n"
+" if( activeRefCount != 0 )\n"
+" abort();\n"
+" }\n";
output <<
" virtual bool preRun() override\n"
@@ -251,7 +259,10 @@ void generateVisitor( PluginType type )
output << " if( !" << plugin.variableName << "->Pre" << traverse.name << "( arg ))\n";
// This will disable the plugin for the time of the traverse, until restored later,
// just like directly returning from Traverse* would skip that part.
+ output << " {\n";
output << " " << plugin.variableName << " = nullptr;\n";
+ output << " ++activeRefCount;\n";
+ output << " }\n";
output << " }\n";
}
}
@@ -271,6 +282,8 @@ void generateVisitor( PluginType type )
output << " save" << plugin.className << " = nullptr;\n";
output << " }\n";
}
+ output << " if( " << plugin.variableName << " == nullptr && save" << plugin.className << " != nullptr )\n";
+ output << " --activeRefCount;\n";
output << " " << plugin.variableName << " = save" << plugin.className << ";\n";
}
output << " return ret;\n";
@@ -282,21 +295,16 @@ void generateVisitor( PluginType type )
output <<
" bool anyPluginActive() const\n"
-" {\n";
- first = true;
+" {\n"
+" return activeRefCount > 0";
for( const PluginInfo& plugin : plugins[ type ] )
- {
- if( first )
- output << " return " << plugin.variableName << " != nullptr";
- else
- output << "\n || " << plugin.variableName << " != nullptr";
- first = false;
- }
+ output << "\n || " << plugin.variableName << " != nullptr";
output << ";\n";
output << " }\n";
for( const PluginInfo& plugin : plugins[ type ] )
output << " " << plugin.className << "* " << plugin.variableName << ";\n";
+ output << " int activeRefCount;\n";
output <<
"};\n"
More information about the Libreoffice-commits
mailing list